You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by lu...@redhat.com on 2011/10/11 01:16:42 UTC
[PATCH 7/7] cimi views: rename dirs for collections for consistency
From: David Lutterkort <lu...@redhat.com>
Signed-off-by: David Lutterkort <lu...@redhat.com>
---
server/lib/cimi/server.rb | 8 +-
server/views/cimi/machine/show.html.haml | 177 --------------------
.../cimi/machine_configuration/show.html.haml | 159 ------------------
.../cimi/machine_configurations/show.html.haml | 159 ++++++++++++++++++
server/views/cimi/machine_image/show.html.haml | 79 ---------
server/views/cimi/machine_images/show.html.haml | 79 +++++++++
server/views/cimi/machines/show.html.haml | 177 ++++++++++++++++++++
7 files changed, 419 insertions(+), 419 deletions(-)
delete mode 100644 server/views/cimi/machine/show.html.haml
delete mode 100644 server/views/cimi/machine_configuration/show.html.haml
create mode 100644 server/views/cimi/machine_configurations/show.html.haml
delete mode 100644 server/views/cimi/machine_image/show.html.haml
create mode 100644 server/views/cimi/machine_images/show.html.haml
create mode 100644 server/views/cimi/machines/show.html.haml
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 2b4848e..63a414c 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -131,7 +131,7 @@ EOS
"href" => machine_configuration_url(@profile.name) }
#mixin actual values get from profile
@dmtfitem = resource_default["dmtfitem"].merge resource_value
- show_resource "machine_configuration/show", "MachineConfiguration"
+ show_resource "machine_configurations/show", "MachineConfiguration"
else
report_error(404)
end
@@ -177,7 +177,7 @@ EOS
"uri" => @image.id,"href" => machine_image_url(@image.id) }
#mixin actual values get from the specific image
@dmtfitem = resource_default["dmtfitem"].merge resource_value
- show_resource "machine_image/show", "MachineImage"
+ show_resource "machine_images/show", "MachineImage"
else
report_error(404)
end
@@ -224,7 +224,7 @@ EOS
"href" => machine_url(@machine.id) }
#mixin actual values get from the specific image
@dmtfitem = resource_default["dmtfitem"].merge resource_value
- show_resource "machine/show", "Machine"
+ show_resource "machines/show", "Machine"
else
report_error(404)
end
@@ -272,7 +272,7 @@ EOS
"capacity" => { "quantity" => @volume.capacity, "units" => "gigabyte"} }
#mixin actual values get from the specific image
@dmtfitem = resource_default["dmtfitem"].merge resource_value
- show_resource "volume/show", "Volume"
+ show_resource "volumes/show", "Volume"
else
report_error(404)
end
diff --git a/server/views/cimi/machine/show.html.haml b/server/views/cimi/machine/show.html.haml
deleted file mode 100644
index c29ddff..0000000
--- a/server/views/cimi/machine/show.html.haml
+++ /dev/null
@@ -1,177 +0,0 @@
-%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 = "<?xml version='1.0' encoding='utf-8' ?>";
- xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
- xmlData += getStandardData(theNode);
- xmlData += "<cpu>" + $(theNode.form).attr("cpu").value + "</cpu>";
- xmlData += "<memory quantity='" + $(theNode.form).attr("memory_quantity").value + "' units='";
- xmlData += $(theNode.form).attr("memory_units").value + "' />"
-
- 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 += "<capacity quantity='" + $(theNode.form).attr("disk_quantity_" + index).value + "' units='" +
- $(theNode.form).attr("disk_units_" + index).value + "' />";
- subDisk += "<guestInterface>" + $(theNode.form).attr("disk_guestInterface_" + index).value + "</guestInterface>";
- }
- index++;
- }
- if (subDisk.length > 0) {
- xmlData += "<disk>" + subDisk + "</disk>";
- }
-
- //we handle entityMetadata here
- if ($(theNode.form).attr("entityMetadata").value) {
- xmlData += $(theNode.form).attr("entityMetadata").value
- }
-
- xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
-
- 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<elNames.length; index++) {
- var aCellTD = row.insertCell(index);
- var aCell = document.createElement('input');
- aCell.type = 'text';
- aCell.name = elNames[index] + iteration;
- aCell.id = aCell.name;
- aCell.size = elSizes[index];
- aCell.value = elValues[index];
- aCellTD.appendChild(aCell);
- }
-
- // select cell
- var cellRightBut = row.insertCell(elNames.length);
- var er = document.createElement('input');
- er.type = 'button';
- er.name = 'param_remove' + iteration;
- er.id = 'param_remove' + iteration;
- er.value = "Remove";
- er.tableRow = row
- $(er).click(function() {
- removeProperty(this);
- })
-
- cellRightBut.appendChild(er);
-
- }
\ No newline at end of file
diff --git a/server/views/cimi/machine_configuration/show.html.haml b/server/views/cimi/machine_configuration/show.html.haml
deleted file mode 100644
index 38dc867..0000000
--- a/server/views/cimi/machine_configuration/show.html.haml
+++ /dev/null
@@ -1,159 +0,0 @@
-%h1 View/Edit machine configuration
-
-%form{ :action => machine_configurations_url }
- %input{ :name => :id, :type => :hidden, :value => @dmtfitem["uri"] }/
- %input{ :name => :xmlRootNode, :type => :hidden, :value => @xml_root_node }/
- %input{ :name => :refreshURI, :type => :hidden, :value => machine_configurations_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 => 30, :value => key }
- %td
- %input{ :name => "param_value_" + iter.to_s, :size => 30, :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
- 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 => 30, :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
-
-:javascript
- function fixupXml(theNode) {
- var xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
- xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
- xmlData += getStandardData(theNode);
- xmlData += "<cpu>" + $(theNode.form).attr("cpu").value + "</cpu>";
- xmlData += "<memory quantity='" + $(theNode.form).attr("memory_quantity").value + "' units='";
- xmlData += $(theNode.form).attr("memory_units").value + "' />"
-
- 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 += "<capacity quantity='" + $(theNode.form).attr("disk_quantity_" + index).value + "' units='" +
- $(theNode.form).attr("disk_units_" + index).value + "' />";
- subDisk += "<guestInterface>" + $(theNode.form).attr("disk_guestInterface_" + index).value + "</guestInterface>";
- }
- index++;
- }
- if (subDisk.length > 0) {
- xmlData += "<disk>" + subDisk + "</disk>";
- }
-
- xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
-
- 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, 30]
- elValues = ["200", "megabyte", ""]
-
- for (var index=0; index<elNames.length; index++) {
- var aCellTD = row.insertCell(index);
- var aCell = document.createElement('input');
- aCell.type = 'text';
- aCell.name = elNames[index] + iteration;
- aCell.id = aCell.name;
- aCell.size = elSizes[index];
- aCell.value = elValues[index];
- aCellTD.appendChild(aCell);
- }
-
- // select cell
- var cellRightBut = row.insertCell(elNames.length);
- var er = document.createElement('input');
- er.type = 'button';
- er.name = 'param_remove' + iteration;
- er.id = 'param_remove' + iteration;
- er.value = "Remove";
- er.tableRow = row
- $(er).click(function() {
- removeProperty(this);
- })
-
- cellRightBut.appendChild(er);
- }
\ No newline at end of file
diff --git a/server/views/cimi/machine_configurations/show.html.haml b/server/views/cimi/machine_configurations/show.html.haml
new file mode 100644
index 0000000..38dc867
--- /dev/null
+++ b/server/views/cimi/machine_configurations/show.html.haml
@@ -0,0 +1,159 @@
+%h1 View/Edit machine configuration
+
+%form{ :action => machine_configurations_url }
+ %input{ :name => :id, :type => :hidden, :value => @dmtfitem["uri"] }/
+ %input{ :name => :xmlRootNode, :type => :hidden, :value => @xml_root_node }/
+ %input{ :name => :refreshURI, :type => :hidden, :value => machine_configurations_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 => 30, :value => key }
+ %td
+ %input{ :name => "param_value_" + iter.to_s, :size => 30, :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
+ 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 => 30, :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
+
+:javascript
+ function fixupXml(theNode) {
+ var xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
+ xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
+ xmlData += getStandardData(theNode);
+ xmlData += "<cpu>" + $(theNode.form).attr("cpu").value + "</cpu>";
+ xmlData += "<memory quantity='" + $(theNode.form).attr("memory_quantity").value + "' units='";
+ xmlData += $(theNode.form).attr("memory_units").value + "' />"
+
+ 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 += "<capacity quantity='" + $(theNode.form).attr("disk_quantity_" + index).value + "' units='" +
+ $(theNode.form).attr("disk_units_" + index).value + "' />";
+ subDisk += "<guestInterface>" + $(theNode.form).attr("disk_guestInterface_" + index).value + "</guestInterface>";
+ }
+ index++;
+ }
+ if (subDisk.length > 0) {
+ xmlData += "<disk>" + subDisk + "</disk>";
+ }
+
+ xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
+
+ 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, 30]
+ elValues = ["200", "megabyte", ""]
+
+ for (var index=0; index<elNames.length; index++) {
+ var aCellTD = row.insertCell(index);
+ var aCell = document.createElement('input');
+ aCell.type = 'text';
+ aCell.name = elNames[index] + iteration;
+ aCell.id = aCell.name;
+ aCell.size = elSizes[index];
+ aCell.value = elValues[index];
+ aCellTD.appendChild(aCell);
+ }
+
+ // select cell
+ var cellRightBut = row.insertCell(elNames.length);
+ var er = document.createElement('input');
+ er.type = 'button';
+ er.name = 'param_remove' + iteration;
+ er.id = 'param_remove' + iteration;
+ er.value = "Remove";
+ er.tableRow = row
+ $(er).click(function() {
+ removeProperty(this);
+ })
+
+ cellRightBut.appendChild(er);
+ }
\ No newline at end of file
diff --git a/server/views/cimi/machine_image/show.html.haml b/server/views/cimi/machine_image/show.html.haml
deleted file mode 100644
index 1c3a28e..0000000
--- a/server/views/cimi/machine_image/show.html.haml
+++ /dev/null
@@ -1,79 +0,0 @@
-%h1 View/Edit machine image
-
-%form{ :action => machine_images_url }
- %input{ :name => :id, :type => :hidden, :value => @dmtfitem["uri"] }/
- %input{ :name => :xmlRootNode, :type => :hidden, :value => @xml_root_node }/
- %input{ :name => :refreshURI, :type => :hidden, :value => machine_images_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 => 30, :value => key }
- %td
- %input{ :name => "param_value_" + iter.to_s, :size => 30, :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
- Image Location:
- %p
- %input{ :name => :imageLocation, :size => 50, :value => @dmtfitem["imageLocation"], :style => "width:50%;" }
- %br
- %label
- Image Data:
- %p
- %textarea{:style=> "width:50%;height:100px;", :name => "imageData"}
- %br
- %label
- EntityMetadata:
- %br
- %div{:style => "width:90%;"}
- %pre
- - if @metadata
- = convert_xml_to_html @metadata
- %br
-
-:javascript
- function fixupXml(theNode) {
- var xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
- xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
- xmlData += getStandardData(theNode);
- xmlData += "<imageLocation href='" + $(theNode.form).attr("imageLocation").value + "' />";
- xmlData += "<imageData>" + $(theNode.form).attr("imageData").value + "</imageData>";
-
- //we handle entityMetadata here
- if ($(theNode.form).attr("entityMetadata") != null && $(theNode.form).attr("entityMetadata").value) {
- xmlData += $(theNode.form).attr("entityMetadata").value
- }
-
- xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
-
- return xmlData;
- }
\ No newline at end of file
diff --git a/server/views/cimi/machine_images/show.html.haml b/server/views/cimi/machine_images/show.html.haml
new file mode 100644
index 0000000..1c3a28e
--- /dev/null
+++ b/server/views/cimi/machine_images/show.html.haml
@@ -0,0 +1,79 @@
+%h1 View/Edit machine image
+
+%form{ :action => machine_images_url }
+ %input{ :name => :id, :type => :hidden, :value => @dmtfitem["uri"] }/
+ %input{ :name => :xmlRootNode, :type => :hidden, :value => @xml_root_node }/
+ %input{ :name => :refreshURI, :type => :hidden, :value => machine_images_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 => 30, :value => key }
+ %td
+ %input{ :name => "param_value_" + iter.to_s, :size => 30, :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
+ Image Location:
+ %p
+ %input{ :name => :imageLocation, :size => 50, :value => @dmtfitem["imageLocation"], :style => "width:50%;" }
+ %br
+ %label
+ Image Data:
+ %p
+ %textarea{:style=> "width:50%;height:100px;", :name => "imageData"}
+ %br
+ %label
+ EntityMetadata:
+ %br
+ %div{:style => "width:90%;"}
+ %pre
+ - if @metadata
+ = convert_xml_to_html @metadata
+ %br
+
+:javascript
+ function fixupXml(theNode) {
+ var xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
+ xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
+ xmlData += getStandardData(theNode);
+ xmlData += "<imageLocation href='" + $(theNode.form).attr("imageLocation").value + "' />";
+ xmlData += "<imageData>" + $(theNode.form).attr("imageData").value + "</imageData>";
+
+ //we handle entityMetadata here
+ if ($(theNode.form).attr("entityMetadata") != null && $(theNode.form).attr("entityMetadata").value) {
+ xmlData += $(theNode.form).attr("entityMetadata").value
+ }
+
+ xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
+
+ return xmlData;
+ }
\ No newline at end of file
diff --git a/server/views/cimi/machines/show.html.haml b/server/views/cimi/machines/show.html.haml
new file mode 100644
index 0000000..c29ddff
--- /dev/null
+++ b/server/views/cimi/machines/show.html.haml
@@ -0,0 +1,177 @@
+%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 = "<?xml version='1.0' encoding='utf-8' ?>";
+ xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
+ xmlData += getStandardData(theNode);
+ xmlData += "<cpu>" + $(theNode.form).attr("cpu").value + "</cpu>";
+ xmlData += "<memory quantity='" + $(theNode.form).attr("memory_quantity").value + "' units='";
+ xmlData += $(theNode.form).attr("memory_units").value + "' />"
+
+ 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 += "<capacity quantity='" + $(theNode.form).attr("disk_quantity_" + index).value + "' units='" +
+ $(theNode.form).attr("disk_units_" + index).value + "' />";
+ subDisk += "<guestInterface>" + $(theNode.form).attr("disk_guestInterface_" + index).value + "</guestInterface>";
+ }
+ index++;
+ }
+ if (subDisk.length > 0) {
+ xmlData += "<disk>" + subDisk + "</disk>";
+ }
+
+ //we handle entityMetadata here
+ if ($(theNode.form).attr("entityMetadata").value) {
+ xmlData += $(theNode.form).attr("entityMetadata").value
+ }
+
+ xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
+
+ 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<elNames.length; index++) {
+ var aCellTD = row.insertCell(index);
+ var aCell = document.createElement('input');
+ aCell.type = 'text';
+ aCell.name = elNames[index] + iteration;
+ aCell.id = aCell.name;
+ aCell.size = elSizes[index];
+ aCell.value = elValues[index];
+ aCellTD.appendChild(aCell);
+ }
+
+ // select cell
+ var cellRightBut = row.insertCell(elNames.length);
+ var er = document.createElement('input');
+ er.type = 'button';
+ er.name = 'param_remove' + iteration;
+ er.id = 'param_remove' + iteration;
+ er.value = "Remove";
+ er.tableRow = row
+ $(er).click(function() {
+ removeProperty(this);
+ })
+
+ cellRightBut.appendChild(er);
+
+ }
\ No newline at end of file
--
1.7.6