deltacloud-core 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/Rakefile +63 -7
  2. data/bin/deltacloudd +29 -17
  3. data/config.ru +5 -3
  4. data/config/drivers/ec2.yaml +9 -0
  5. data/config/drivers/google.yaml +3 -0
  6. data/config/drivers/openstack.yaml +3 -0
  7. data/deltacloud-core.gemspec +1 -1
  8. data/lib/cimi/dependencies.rb +62 -0
  9. data/lib/cimi/helpers/cimi_helper.rb +50 -0
  10. data/lib/cimi/model.rb +52 -0
  11. data/lib/cimi/model/action.rb +24 -0
  12. data/lib/cimi/model/base.rb +249 -0
  13. data/lib/cimi/model/cloud_entry_point.rb +48 -0
  14. data/lib/cimi/model/entity_metadata.rb +83 -0
  15. data/lib/cimi/model/entity_metadata_collection.rb +31 -0
  16. data/lib/cimi/model/errors.rb +40 -0
  17. data/lib/cimi/model/machine.rb +227 -0
  18. data/lib/cimi/model/machine_admin.rb +59 -0
  19. data/lib/cimi/model/machine_admin_collection.rb +34 -0
  20. data/lib/cimi/model/machine_collection.rb +34 -0
  21. data/lib/cimi/model/machine_configuration.rb +67 -0
  22. data/lib/cimi/model/machine_configuration_collection.rb +34 -0
  23. data/lib/cimi/model/machine_image.rb +46 -0
  24. data/lib/cimi/model/machine_image_collection.rb +34 -0
  25. data/lib/cimi/model/machine_template.rb +41 -0
  26. data/lib/cimi/model/machine_template_collection.rb +34 -0
  27. data/lib/cimi/model/network.rb +69 -0
  28. data/lib/cimi/model/network_collection.rb +34 -0
  29. data/lib/cimi/model/network_configuration.rb +50 -0
  30. data/lib/cimi/model/network_configuration_collection.rb +34 -0
  31. data/lib/cimi/model/network_template.rb +26 -0
  32. data/lib/cimi/model/schema.rb +277 -0
  33. data/lib/cimi/model/volume.rb +103 -0
  34. data/lib/cimi/model/volume_collection.rb +34 -0
  35. data/lib/cimi/model/volume_configuration.rb +60 -0
  36. data/lib/cimi/model/volume_configuration_collection.rb +34 -0
  37. data/lib/cimi/model/volume_image.rb +49 -0
  38. data/lib/cimi/model/volume_image_collection.rb +34 -0
  39. data/lib/cimi/model/volume_template.rb +23 -0
  40. data/lib/cimi/model/volume_template_collection.rb +34 -0
  41. data/lib/cimi/server.rb +575 -0
  42. data/lib/deltacloud/base_driver/base_driver.rb +11 -1
  43. data/lib/deltacloud/core_ext.rb +2 -0
  44. data/lib/deltacloud/core_ext/array.rb +25 -0
  45. data/lib/deltacloud/core_ext/hash.rb +7 -0
  46. data/lib/deltacloud/core_ext/proc.rb +31 -0
  47. data/lib/deltacloud/core_ext/string.rb +15 -0
  48. data/lib/deltacloud/drivers/condor/condor_driver.rb +2 -1
  49. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +32 -10
  50. data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +1 -1
  51. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +1 -1
  52. data/lib/deltacloud/drivers/google/google_driver.rb +233 -0
  53. data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +7 -2
  54. data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +7 -2
  55. data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +7 -2
  56. data/lib/deltacloud/drivers/mock/mock_client.rb +17 -0
  57. data/lib/deltacloud/drivers/mock/mock_driver.rb +82 -8
  58. data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +1 -1
  59. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +47 -0
  60. data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +8 -8
  61. data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +122 -49
  62. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +42 -22
  63. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +1 -1
  64. data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -2
  65. data/lib/deltacloud/drivers/terremark/terremark_driver.rb +2 -2
  66. data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +25 -4
  67. data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +35 -12
  68. data/lib/deltacloud/hardware_profile.rb +34 -10
  69. data/lib/deltacloud/helpers/application_helper.rb +3 -28
  70. data/lib/deltacloud/helpers/blob_stream.rb +2 -1
  71. data/lib/deltacloud/models.rb +2 -0
  72. data/lib/deltacloud/models/bucket.rb +1 -1
  73. data/lib/deltacloud/models/image.rb +1 -1
  74. data/lib/deltacloud/models/instance.rb +2 -1
  75. data/lib/deltacloud/models/instance_address.rb +56 -0
  76. data/lib/deltacloud/models/provider.rb +27 -0
  77. data/{server.rb → lib/deltacloud/server.rb} +72 -14
  78. data/lib/deltacloud/validation.rb +31 -10
  79. data/lib/sinatra/rabbit.rb +34 -26
  80. data/lib/sinatra/rack_accept.rb +5 -5
  81. data/lib/sinatra/rack_matrix_params.rb +6 -2
  82. data/lib/sinatra/rack_syslog.rb +3 -3
  83. data/lib/sinatra/static_assets.rb +1 -1
  84. data/lib/sinatra/url_for.rb +1 -7
  85. data/public/images/bread-bg.png +0 -0
  86. data/public/images/logo-wide.png +0 -0
  87. data/public/images/topbar-bg.png +0 -0
  88. data/public/javascripts/application.js +5 -0
  89. data/public/javascripts/cmwgapp.js +249 -0
  90. data/public/javascripts/jquery-1.4.2.min.js +154 -0
  91. data/public/javascripts/jquery.mobile-1.0rc1.min.js +170 -0
  92. data/public/stylesheets/images/icons-18-black.png +0 -0
  93. data/public/stylesheets/images/icons-18-white.png +0 -0
  94. data/public/stylesheets/images/icons-36-black.png +0 -0
  95. data/public/stylesheets/images/icons-36-white.png +0 -0
  96. data/public/stylesheets/jquery.mobile-1.0rc1.min.css +12 -0
  97. data/public/stylesheets/new.css +4 -0
  98. data/support/fedora/deltacloud-core.init +20 -13
  99. data/tests/cimi/features/step_definitions/common_steps.rb +59 -0
  100. data/tests/cimi/features/step_definitions/machine_images_steps.rb +0 -0
  101. data/tests/cimi/features/step_definitions/machines_steps.rb +99 -0
  102. data/tests/cimi/features/step_definitions/volumes_steps.rb +115 -0
  103. data/tests/cimi/features/support/env.rb +53 -0
  104. data/tests/common.rb +89 -11
  105. data/tests/core_ext/string.rb +31 -0
  106. data/tests/drivers/google/api_test.rb +35 -0
  107. data/tests/drivers/google/buckets_test.rb +116 -0
  108. data/tests/drivers/google/setup.rb +38 -0
  109. data/tests/drivers/mock/instances_test.rb +20 -5
  110. data/tests/drivers/openstack/api_test.rb +41 -0
  111. data/tests/drivers/openstack/hardware_profiles_test.rb +53 -0
  112. data/tests/drivers/openstack/images_test.rb +40 -0
  113. data/tests/drivers/openstack/instances_test.rb +163 -0
  114. data/tests/drivers/openstack/realms_test.rb +36 -0
  115. data/tests/drivers/openstack/setup.rb +20 -0
  116. data/tests/drivers/rackspace/buckets_test.rb +145 -0
  117. data/tests/drivers/rackspace/setup.rb +3 -3
  118. data/tests/drivers/rhevm/api_test.rb +1 -1
  119. data/tests/drivers/rhevm/images_test.rb +2 -2
  120. data/tests/drivers/rhevm/instances_test.rb +10 -12
  121. data/tests/drivers/rhevm/realms_test.rb +4 -4
  122. data/tests/drivers/rhevm/setup.rb +3 -3
  123. data/tests/rabbit_test.rb +1 -1
  124. data/views/api/show.html.haml +13 -0
  125. data/views/cimi/cloudEntryPoint/index.html.haml +5 -0
  126. data/views/cimi/cloudEntryPoint/index.xml.haml +9 -0
  127. data/views/cimi/collection/index.html.haml +45 -0
  128. data/views/cimi/collection/response.xml.haml +3 -0
  129. data/views/cimi/error.html.haml +31 -0
  130. data/views/cimi/errors/400.html.haml +41 -0
  131. data/views/cimi/errors/400.xml.haml +3 -0
  132. data/views/cimi/errors/401.html.haml +41 -0
  133. data/views/cimi/errors/401.xml.haml +2 -0
  134. data/views/cimi/errors/403.html.haml +42 -0
  135. data/views/cimi/errors/403.xml.haml +2 -0
  136. data/views/cimi/errors/404.html.haml +29 -0
  137. data/views/cimi/errors/404.xml.haml +2 -0
  138. data/views/cimi/errors/405.html.haml +29 -0
  139. data/views/cimi/errors/405.xml.haml +5 -0
  140. data/views/cimi/errors/500.html.haml +43 -0
  141. data/views/cimi/errors/500.xml.haml +6 -0
  142. data/views/cimi/errors/502.html.haml +43 -0
  143. data/views/cimi/errors/502.xml.haml +7 -0
  144. data/views/cimi/errors/backend_capability_failure.html.haml +29 -0
  145. data/views/cimi/layout.html.haml +32 -0
  146. data/views/cimi/machine_configurations/show.html.haml +159 -0
  147. data/views/cimi/machine_configurations/show.xml.haml +27 -0
  148. data/views/cimi/machine_images/show.html.haml +79 -0
  149. data/views/cimi/machine_images/show.xml.haml +17 -0
  150. data/views/cimi/machines/show.html.haml +177 -0
  151. data/views/cimi/machines/show.xml.haml +28 -0
  152. data/views/cimi/volumes/show.html.haml +68 -0
  153. data/views/cimi/volumes/show.xml.haml +17 -0
  154. data/views/drivers/show.html.haml +10 -5
  155. data/views/drivers/show.xml.haml +9 -4
  156. data/views/error.html.haml +2 -2
  157. data/views/errors/500.xml.haml +7 -1
  158. data/views/instances/index.html.haml +1 -1
  159. data/views/instances/new.html.haml +19 -16
  160. data/views/instances/show.html.haml +7 -2
  161. data/views/instances/show.xml.haml +8 -7
  162. data/views/layout.html.haml +2 -2
  163. data/views/storage_volumes/show.html.haml +1 -1
  164. metadata +296 -204
  165. data/public/javascripts/jquery.mobile-1.0b1.min.js +0 -146
  166. data/public/stylesheets/jquery.mobile-1.0b1.min.css +0 -8
@@ -0,0 +1,5 @@
1
+ %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
2
+ %message
3
+ Requested method not allowed
4
+ %method
5
+ =request.env['REQUEST_METHOD']
@@ -0,0 +1,43 @@
1
+ %div{ :'data-role' => :content, :'data-theme' => 'b'}
2
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
3
+ %li{ :'data-role' => 'list-divider'} Server message
4
+ %li
5
+ %h3=[@error.class.name, @error.message].join(' - ')
6
+ %li{ :'data-role' => 'list-divider'} Original request URI
7
+ %li
8
+ %a{ :href => request.env['REQUEST_URI'], :'data-ajax' => 'false'}
9
+ %span=request.env['REQUEST_URI']
10
+ %span{ :class => 'ui-li-count'} Retry
11
+ %li{ :'data-role' => 'list-divider'} Error details
12
+ %li
13
+ - if @error.class.method_defined? :details
14
+ %p= @error.details
15
+ - else
16
+ %em No details
17
+
18
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
19
+ %h3 Backtrace
20
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
21
+ %li
22
+ %pre=@error.backtrace.join("\n")
23
+
24
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
25
+ %h3 Parameters
26
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
27
+ - if params.keys.empty?
28
+ %li{ :'data-role' => 'list-divider'} No parameters
29
+ - params.each do |key, value|
30
+ - next if value.inspect.to_s == '#'
31
+ %li{ :'data-role' => 'list-divider'}=key
32
+ %li
33
+ %span{:style => 'font-weight:normal;'}=value.inspect
34
+
35
+
36
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
37
+ %h3 Request details
38
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
39
+ - request.env.each do |key, value|
40
+ - next if value.inspect.to_s == '#'
41
+ %li{ :'data-role' => 'list-divider'}=key
42
+ %li
43
+ %span{:style => 'font-weight:normal;'}=value.inspect
@@ -0,0 +1,6 @@
1
+ %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
2
+ %kind backend_error
3
+ %message< #{cdata @error.message}
4
+ %backend{ :driver => driver_symbol }
5
+ %code=response.status
6
+ %backtrace< #{cdata @error.backtrace.join("\n")}
@@ -0,0 +1,43 @@
1
+ %div{ :'data-role' => :content, :'data-theme' => 'b'}
2
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
3
+ %li{ :'data-role' => 'list-divider'} Server message
4
+ %li
5
+ %h3=[@error.class.name, @error.message].join(' - ')
6
+ %li{ :'data-role' => 'list-divider'} Original request URI
7
+ %li
8
+ %a{ :href => request.env['REQUEST_URI'], :'data-ajax' => 'false'}
9
+ %span=request.env['REQUEST_URI']
10
+ %span{ :class => 'ui-li-count'} Retry
11
+ %li{ :'data-role' => 'list-divider'} Error details
12
+ %li
13
+ - if @error.class.method_defined? :details
14
+ %p= @error.details
15
+ - else
16
+ %em No details
17
+
18
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
19
+ %h3 Backtrace
20
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
21
+ %li
22
+ %pre=@error.backtrace.join("\n")
23
+
24
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
25
+ %h3 Parameters
26
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
27
+ - if params.keys.empty?
28
+ %li{ :'data-role' => 'list-divider'} No parameters
29
+ - params.each do |key, value|
30
+ - next if value.inspect.to_s == '#'
31
+ %li{ :'data-role' => 'list-divider'}=key
32
+ %li
33
+ %span{:style => 'font-weight:normal;'}=value.inspect
34
+
35
+
36
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
37
+ %h3 Request details
38
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
39
+ - request.env.each do |key, value|
40
+ - next if value.inspect.to_s == '#'
41
+ %li{ :'data-role' => 'list-divider'}=key
42
+ %li
43
+ %span{:style => 'font-weight:normal;'}=value.inspect
@@ -0,0 +1,7 @@
1
+ %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
2
+ %kind backend_error
3
+ %backend{ :driver => driver_symbol }
4
+ %code= @error.code
5
+ - if @error.respond_to?(:details) && @error.details
6
+ %details< #{cdata @error.details.join("\n")}
7
+ %message< #{cdata @error.message}
@@ -0,0 +1,29 @@
1
+ %div{ :'data-role' => :content, :'data-theme' => 'b'}
2
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
3
+ %li{ :'data-role' => 'list-divider'} Server message
4
+ %li
5
+ %h3 Backend capability failure
6
+ %li{ :'data-role' => 'list-divider'} Original request URI
7
+ %li
8
+ %a{ :href => request.env['REQUEST_URI'], :'data-ajax' => 'false'}
9
+ %span=request.env['REQUEST_URI']
10
+ %span{ :class => 'ui-li-count'} Retry
11
+
12
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
13
+ %h3 Parameters
14
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
15
+ - if params.keys.empty?
16
+ %li{ :'data-role' => 'list-divider'} No parameters
17
+ - params.each do |key, value|
18
+ %li{ :'data-role' => 'list-divider'}=key
19
+ %li
20
+ %span{:style => 'font-weight:normal;'}=value.inspect
21
+
22
+
23
+ %div{ 'data-role' => :collapsible, 'data-collapsed' => "true"}
24
+ %h3 Request details
25
+ %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'e'}
26
+ - request.env.each do |key, value|
27
+ %li{ :'data-role' => 'list-divider'}=key
28
+ %li
29
+ %span{:style => 'font-weight:normal;'}=value.inspect
@@ -0,0 +1,32 @@
1
+ !!!
2
+ !!! XML
3
+
4
+ %html
5
+ %head
6
+ = stylesheet_link_tag '/stylesheets/compiled/screen.css', :media => 'screen, projection'
7
+ = stylesheet_link_tag '/stylesheets/compiled/print.css', :media => 'print'
8
+ /[if lt IE 8]
9
+ = stylesheet_link_tag '/stylesheets/compiled/ie.css', :media => 'screen, projection'
10
+ = stylesheet_link_tag '/stylesheets/compiled/application.css', :media => 'screen, projection'
11
+ %script{:type => "text/javascript", :src => "/javascripts/jquery-1.4.2.min.js" }
12
+ %script{:type => "text/javascript", :src => "/javascripts/application.js" }
13
+ %script{:type => "text/javascript", :src => "/javascripts/cmwgapp.js" }
14
+ %body
15
+ #wrapper
16
+ #header
17
+ = link_to image_tag( "/images/logo-wide.png" ), settings.root_url
18
+ = bread_crumb_ext
19
+ #content
20
+ = yield
21
+ #footer
22
+ #formats
23
+ Format:
24
+ =link_to_format(:xml)
25
+ |
26
+ =link_to_format(:json)
27
+ #driver_info
28
+ Driver: #{driver_symbol} | API version: #{settings.version}
29
+ #copyright
30
+ Copyright 2009-2011
31
+ %a{:href => 'http://incubator.apache.org/deltacloud/'} The Apache Software Foundation
32
+ and individual contributors.
@@ -0,0 +1,159 @@
1
+ %h1 View/Edit machine configuration
2
+
3
+ %form{ :action => machine_configurations_url }
4
+ %input{ :name => :id, :type => :hidden, :value => @dmtfitem["uri"] }/
5
+ %input{ :name => :xmlRootNode, :type => :hidden, :value => @xml_root_node }/
6
+ %input{ :name => :refreshURI, :type => :hidden, :value => machine_configurations_url }/
7
+ %p
8
+ %label
9
+ Name:
10
+ %p
11
+ %input{ :name => :name, :size => 50, :value => @dmtfitem["name"], :style => "width:50%;" }
12
+ %input{ :name => :created, :type => :hidden, :size => 50, :value => @dmtfitem["created"] }
13
+ %p
14
+ %br
15
+ %label
16
+ Description:
17
+ %p
18
+ %textarea{ :name => :description, :cols => 50, :rows => 4, :style => "width:50%;" } #{@dmtfitem['description']}
19
+ %p
20
+ %br
21
+ %label
22
+ Properties:
23
+ %p
24
+ %table{ :style => "width:50%;", :id => "propertyTable"}
25
+ - if @dmtfitem["property"]
26
+ - if @dmtfitem["property"]["name"] && @dmtfitem["property"]["content"]
27
+ - property_object = {"#{@dmtfitem['property']['name']}" => {"content" => @dmtfitem["property"]["content"]}}
28
+ - else
29
+ - property_object = @dmtfitem["property"]
30
+
31
+ - iter = -1
32
+ - property_object.each_pair do |key, value|
33
+ - iter += 1
34
+ %tr
35
+ %td
36
+ %input{ :name => "param_name_" + iter.to_s, :size => 30, :value => key }
37
+ %td
38
+ %input{ :name => "param_value_" + iter.to_s, :size => 30, :value => value["content"] }
39
+ %td
40
+ %input{ :type => :button, :value => "Remove", :onClick => "return removeProperty(this)" }
41
+ %input{ :type => :button, :name => "commit", :value => "Add new property", :onClick => "return AddNewPproperty('propertyTable')" }
42
+ %p
43
+ %br
44
+ %label
45
+ Cpu:
46
+ %p
47
+ %input{ :name => :cpu, :size => 50, :value => @dmtfitem["cpu"], :style => "width:50%;" }
48
+ %br
49
+ %label
50
+ Memory:
51
+ %p
52
+ %input{ :name => :memory_quantity, :size => 20, :value => @dmtfitem["memory"]["quantity"], :style => "width:10%;" } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
53
+ %input{ :name => :memory_units, :size => 20, :value => @dmtfitem["memory"]["units"], :style => "width:10%;" }
54
+ %br
55
+ %label
56
+ Disk:
57
+ %p
58
+ %table{ :style => "width:50%;", :id => "diskTable"}
59
+ - if @dmtfitem["disk"]
60
+ - if @dmtfitem["disk"].kind_of?(Array)
61
+ - property_object = @dmtfitem["disk"]
62
+ - else
63
+ - property_object = [@dmtfitem["disk"]]
64
+
65
+ - iter = -1
66
+ %tr
67
+ %td
68
+ %label
69
+ Quantity
70
+ %td
71
+ %label
72
+ Units
73
+ %td
74
+ %label
75
+ GuestInterface
76
+ %td &nbsp;
77
+ - property_object.each do |disk|
78
+ - iter += 1
79
+ %tr
80
+ %td
81
+ %input{ :name => "disk_quantity_" + iter.to_s, :size => 10, :value => disk["capacity"]["quantity"] }
82
+ %td
83
+ %input{ :name => "disk_units_" + iter.to_s, :size => 10, :value => disk["capacity"]["units"] }
84
+ %td
85
+ %input{ :name => "disk_guestInterface_" + iter.to_s, :size => 30, :value => disk["guestInterface"] }
86
+ %td
87
+ %input{ :type => :button, :value => "Remove", :onClick => "return removeProperty(this)" }
88
+ %input{ :type => :button, :name => "commit", :value => "Add new disk", :onClick => "return addDiskRow('diskTable')" }
89
+
90
+ %br
91
+ %label
92
+ EntityMetadata:
93
+ %br
94
+
95
+ :javascript
96
+ function fixupXml(theNode) {
97
+ var xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
98
+ xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
99
+ xmlData += getStandardData(theNode);
100
+ xmlData += "<cpu>" + $(theNode.form).attr("cpu").value + "</cpu>";
101
+ xmlData += "<memory quantity='" + $(theNode.form).attr("memory_quantity").value + "' units='";
102
+ xmlData += $(theNode.form).attr("memory_units").value + "' />"
103
+
104
+ var index=0;
105
+ subDisk = ""
106
+ while ($(theNode.form).attr("disk_quantity_" + index)) {
107
+ if ($(theNode.form).attr("disk_quantity_" + index).value != null &&
108
+ $(theNode.form).attr("disk_quantity_" + index).value.length > 0) {
109
+ subDisk += "<capacity quantity='" + $(theNode.form).attr("disk_quantity_" + index).value + "' units='" +
110
+ $(theNode.form).attr("disk_units_" + index).value + "' />";
111
+ subDisk += "<guestInterface>" + $(theNode.form).attr("disk_guestInterface_" + index).value + "</guestInterface>";
112
+ }
113
+ index++;
114
+ }
115
+ if (subDisk.length > 0) {
116
+ xmlData += "<disk>" + subDisk + "</disk>";
117
+ }
118
+
119
+ xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
120
+
121
+ return xmlData;
122
+ }
123
+
124
+ function addDiskRow(tableId) {
125
+ var tbl = document.getElementById(tableId);
126
+ var lastRow = tbl.rows.length;
127
+ // if there's no header row in the table, then iteration = lastRow + 1
128
+ var iteration = lastRow - 1;
129
+ var row = tbl.insertRow(lastRow);
130
+
131
+ elNames = ['disk_quantity_', 'disk_units_', 'disk_guestInterface_'];
132
+ elSizes = [10, 10, 30]
133
+ elValues = ["200", "megabyte", ""]
134
+
135
+ for (var index=0; index<elNames.length; index++) {
136
+ var aCellTD = row.insertCell(index);
137
+ var aCell = document.createElement('input');
138
+ aCell.type = 'text';
139
+ aCell.name = elNames[index] + iteration;
140
+ aCell.id = aCell.name;
141
+ aCell.size = elSizes[index];
142
+ aCell.value = elValues[index];
143
+ aCellTD.appendChild(aCell);
144
+ }
145
+
146
+ // select cell
147
+ var cellRightBut = row.insertCell(elNames.length);
148
+ var er = document.createElement('input');
149
+ er.type = 'button';
150
+ er.name = 'param_remove' + iteration;
151
+ er.id = 'param_remove' + iteration;
152
+ er.value = "Remove";
153
+ er.tableRow = row
154
+ $(er).click(function() {
155
+ removeProperty(this);
156
+ })
157
+
158
+ cellRightBut.appendChild(er);
159
+ }
@@ -0,0 +1,27 @@
1
+ - unless defined?(partial)
2
+ !!! XML
3
+ %MachineConfiguration{ :xmlns => CMWG_NAMESPACE }
4
+ %uri=machine_configurations_url + "/" + @dmtfitem["uri"]
5
+ %name=@dmtfitem["name"]
6
+ %description=@dmtfitem["description"]
7
+ %created=@dmtfitem["created"]
8
+ - if @dmtfitem["property"]
9
+ - if @dmtfitem["property"]["name"] && @dmtfitem["property"]["content"]
10
+ - property_object = {"#{@dmtfitem['property']['name']}" => {"content" => @dmtfitem["property"]["content"]}}
11
+ - else
12
+ - property_object = @dmtfitem["property"]
13
+ - property_object.each_pair do |key, value|
14
+ %property{ :name => key}=value["content"]
15
+ %cpu=@dmtfitem["cpu"]
16
+ %memory{ :quantity => @dmtfitem["memory"]["quantity"], :units => @dmtfitem["memory"]["units"] }
17
+ - if @dmtfitem["disk"]
18
+ - if @dmtfitem["disk"].kind_of?(Array)
19
+ - property_object = @dmtfitem["disk"]
20
+ - else
21
+ - property_object = [@dmtfitem["disk"]]
22
+ - property_object.each do |disk|
23
+ %disk
24
+ %capacity{ :quantity => disk["capacity"]["quantity"], :units => disk["capacity"]["units"] }
25
+ %guestInterface= disk["guestInterface"]
26
+ %operation{ :rel => "edit", :href => machine_configurations_url + "/" + @dmtfitem["uri"] }
27
+ %operation{ :rel => "delete", :href => machine_configurations_url + "/" + @dmtfitem["uri"] }
@@ -0,0 +1,79 @@
1
+ %h1 View/Edit machine image
2
+
3
+ %form{ :action => machine_images_url }
4
+ %input{ :name => :id, :type => :hidden, :value => @dmtfitem["uri"] }/
5
+ %input{ :name => :xmlRootNode, :type => :hidden, :value => @xml_root_node }/
6
+ %input{ :name => :refreshURI, :type => :hidden, :value => machine_images_url }/
7
+ %p
8
+ %label
9
+ Name:
10
+ %p
11
+ %input{ :name => :name, :size => 50, :value => @dmtfitem["name"], :style => "width:50%;" }
12
+ %input{ :name => :created, :type => :hidden, :size => 50, :value => @dmtfitem["created"] }
13
+ %p
14
+ %br
15
+ %label
16
+ Description:
17
+ %p
18
+ %textarea{ :name => :description, :cols => 50, :rows => 4, :style => "width:50%;" } #{@dmtfitem['description']}
19
+ %p
20
+ %br
21
+ %label
22
+ Properties:
23
+ %p
24
+ %table{ :style => "width:50%;", :id => "propertyTable"}
25
+ - if @dmtfitem["property"]
26
+ - if @dmtfitem["property"]["name"] && @dmtfitem["property"]["content"]
27
+ - property_object = {"#{@dmtfitem['property']['name']}" => {"content" => @dmtfitem["property"]["content"]}}
28
+ - else
29
+ - property_object = @dmtfitem["property"]
30
+
31
+ - iter = -1
32
+ - property_object.each_pair do |key, value|
33
+ - iter += 1
34
+ %tr
35
+ %td
36
+ %input{ :name => "param_name_" + iter.to_s, :size => 30, :value => key }
37
+ %td
38
+ %input{ :name => "param_value_" + iter.to_s, :size => 30, :value => value["content"] }
39
+ %td
40
+ %input{ :type => :button, :value => "Remove", :onClick => "return removeProperty(this)" }
41
+ %input{ :type => :button, :name => "commit", :value => "Add new property", :onClick => "return AddNewPproperty('propertyTable')" }
42
+ %p
43
+ %br
44
+ %label
45
+ Image Location:
46
+ %p
47
+ %input{ :name => :imageLocation, :size => 50, :value => @dmtfitem["imageLocation"], :style => "width:50%;" }
48
+ %br
49
+ %label
50
+ Image Data:
51
+ %p
52
+ %textarea{:style=> "width:50%;height:100px;", :name => "imageData"}
53
+ %br
54
+ %label
55
+ EntityMetadata:
56
+ %br
57
+ %div{:style => "width:90%;"}
58
+ %pre
59
+ - if @metadata
60
+ = convert_xml_to_html @metadata
61
+ %br
62
+
63
+ :javascript
64
+ function fixupXml(theNode) {
65
+ var xmlData = "<?xml version='1.0' encoding='utf-8' ?>";
66
+ xmlData += "<" + $(theNode.form).attr("xmlRootNode").value + " xmlns='http://www.dmtf.org/cimi'>";
67
+ xmlData += getStandardData(theNode);
68
+ xmlData += "<imageLocation href='" + $(theNode.form).attr("imageLocation").value + "' />";
69
+ xmlData += "<imageData>" + $(theNode.form).attr("imageData").value + "</imageData>";
70
+
71
+ //we handle entityMetadata here
72
+ if ($(theNode.form).attr("entityMetadata") != null && $(theNode.form).attr("entityMetadata").value) {
73
+ xmlData += $(theNode.form).attr("entityMetadata").value
74
+ }
75
+
76
+ xmlData += "</" + $(theNode.form).attr("xmlRootNode").value + ">";
77
+
78
+ return xmlData;
79
+ }
@@ -0,0 +1,17 @@
1
+ - unless defined?(partial)
2
+ !!! XML
3
+ %MachineImage{ :xmlns => CMWG_NAMESPACE }
4
+ %uri=machine_images_url + "/" + @dmtfitem["uri"]
5
+ %name=@dmtfitem["name"]
6
+ %description=@dmtfitem["description"]
7
+ %created=@dmtfitem["created"]
8
+ - if @dmtfitem["property"]
9
+ - if @dmtfitem["property"]["name"] && @dmtfitem["property"]["content"]
10
+ - property_object = {"#{@dmtfitem['property']['name']}" => {"content" => @dmtfitem["property"]["content"]}}
11
+ - else
12
+ - property_object = @dmtfitem["property"]
13
+ - property_object.each_pair do |key, value|
14
+ %property{ :name => key}=value["content"]
15
+ %imageLocation{ :href => @dmtfitem["imageLocation"]}
16
+ %operation{ :rel => "edit", :href => machine_images_url + "/" + @dmtfitem["uri"] }
17
+ %operation{ :rel => "delete", :href => machine_images_url + "/" + @dmtfitem["uri"] }