%h1 View/Edit machine %form{ :action => machines_url } %input{ :name => :id, :type => :hidden, :value => @dmtfitem["uri"] }/ %input{ :name => :xmlRootNode, :type => :hidden, :value => @xml_root_node }/ %input{ :name => :refreshURI, :type => :hidden, :value => machines_url }/ %p %label Name: %p %input{ :name => :name, :size => 50, :value => @dmtfitem["name"], :style => "width:50%;" } %input{ :name => :created, :type => :hidden, :size => 50, :value => @dmtfitem["created"] } %p %br %label Description: %p %textarea{ :name => :description, :cols => 50, :rows => 4, :style => "width:50%;" } #{@dmtfitem['description']} %p %br %label Properties: %p %table{ :style => "width:50%;", :id => "propertyTable"} - if @dmtfitem["property"] - if @dmtfitem["property"]["name"] && @dmtfitem["property"]["content"] - property_object = {"#{@dmtfitem['property']['name']}" => {"content" => @dmtfitem["property"]["content"]}} - else - property_object = @dmtfitem["property"] - iter = -1 - property_object.each_pair do |key, value| - iter += 1 %tr %td %input{ :name => "param_name_" + iter.to_s, :size => 25, :value => key } %td %input{ :name => "param_value_" + iter.to_s, :size => 25, :value => value["content"] } %td %input{ :type => :button, :value => "Remove", :onClick => "return removeProperty(this)" } %input{ :type => :button, :name => "commit", :value => "Add new property", :onClick => "return AddNewPproperty('propertyTable')" } %p %br %label Status: %p %input{ :name => :status, :size => 50, :value => @dmtfitem["status"], :style => "width:50%;" } %p %br %label CPU: %p %input{ :name => :cpu, :size => 50, :value => @dmtfitem["cpu"], :style => "width:50%;" } %br %label Memory: %p %input{ :name => :memory_quantity, :size => 20, :value => @dmtfitem["memory"]["quantity"], :style => "width:10%;" }       %input{ :name => :memory_units, :size => 20, :value => @dmtfitem["memory"]["units"], :style => "width:10%;" } %br %label Disk: %p %table{ :style => "width:50%;", :id => "diskTable"} - if @dmtfitem["disk"] - if @dmtfitem["disk"].kind_of?(Array) - property_object = @dmtfitem["disk"] - else - property_object = [@dmtfitem["disk"]] - iter = -1 %tr %td %label Quantity %td %label Units %td %label GuestInterface %td   - property_object.each do |disk| - iter += 1 %tr %td %input{ :name => "disk_quantity_" + iter.to_s, :size => 10, :value => disk["capacity"]["quantity"] } %td %input{ :name => "disk_units_" + iter.to_s, :size => 10, :value => disk["capacity"]["units"] } %td %input{ :name => "disk_guestInterface_" + iter.to_s, :size => 20, :value => disk["guestInterface"] } %td %input{ :type => :button, :value => "Remove", :onClick => "return removeProperty(this)" } %input{ :type => :button, :name => "commit", :value => "Add new disk", :onClick => "return addDiskRow('diskTable')" } %br %label EntityMetadata: %br %label TODO Need to handle volumes: %p %br %label TODO Need to handle network interfaces: :javascript function fixupXml(theNode) { var xmlData = ""; xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>"; xmlData += getStandardData(theNode); xmlData += "" + $(theNode.form).attr("cpu").value + ""; xmlData += "" var index=0; subDisk = "" while ($(theNode.form).attr("disk_quantity_" + index)) { if ($(theNode.form).attr("disk_quantity_" + index).value != null && $(theNode.form).attr("disk_quantity_" + index).value.length > 0) { subDisk += ""; subDisk += "" + $(theNode.form).attr("disk_guestInterface_" + index).value + ""; } index++; } if (subDisk.length > 0) { xmlData += "" + subDisk + ""; } //we handle entityMetadata here if ($(theNode.form).attr("entityMetadata").value) { xmlData += $(theNode.form).attr("entityMetadata").value } xmlData += ""; return xmlData; } function addDiskRow(tableId) { var tbl = document.getElementById(tableId); var lastRow = tbl.rows.length; // if there's no header row in the table, then iteration = lastRow + 1 var iteration = lastRow - 1; var row = tbl.insertRow(lastRow); elNames = ['disk_quantity_', 'disk_units_', 'disk_guestInterface_']; elSizes = [10, 10, 20] elValues = ["200", "megabyte", ""] for (var index=0; index