deltacloud-core 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/Rakefile +2 -1
  2. data/bin/deltacloudd +11 -5
  3. data/config.ru +3 -3
  4. data/deltacloud-core.gemspec +24 -18
  5. data/lib/cimi/collections/address_templates.rb +3 -3
  6. data/lib/cimi/collections/addresses.rb +6 -5
  7. data/lib/cimi/collections/entity_metadata.rb +0 -2
  8. data/lib/cimi/collections/machine_admins.rb +5 -5
  9. data/lib/cimi/collections/machine_configurations.rb +2 -2
  10. data/lib/cimi/collections/machine_images.rb +3 -3
  11. data/lib/cimi/collections/machines.rb +32 -10
  12. data/lib/cimi/collections/network_configurations.rb +4 -3
  13. data/lib/cimi/collections/network_templates.rb +4 -3
  14. data/lib/cimi/collections/networks.rb +8 -8
  15. data/lib/cimi/collections/routing_group_templates.rb +4 -3
  16. data/lib/cimi/collections/routing_groups.rb +4 -3
  17. data/lib/cimi/collections/volume_configurations.rb +3 -3
  18. data/lib/cimi/collections/volume_images.rb +3 -3
  19. data/lib/cimi/collections/volumes.rb +4 -3
  20. data/lib/cimi/collections/vsp_configurations.rb +4 -3
  21. data/lib/cimi/collections/vsp_templates.rb +4 -3
  22. data/lib/cimi/collections/vsps.rb +8 -7
  23. data/lib/cimi/helpers.rb +1 -1
  24. data/lib/cimi/helpers/cimi_helper.rb +11 -1
  25. data/lib/cimi/models.rb +4 -0
  26. data/lib/cimi/models/base.rb +11 -1
  27. data/lib/cimi/models/cloud_entry_point.rb +7 -14
  28. data/lib/cimi/models/disk.rb +40 -0
  29. data/lib/cimi/models/disk_collection.rb +38 -0
  30. data/lib/cimi/models/machine.rb +9 -43
  31. data/lib/cimi/models/machine_collection.rb +7 -4
  32. data/lib/cimi/models/machine_configuration.rb +8 -15
  33. data/lib/cimi/models/machine_configuration_collection.rb +6 -4
  34. data/lib/cimi/models/machine_image_collection.rb +6 -4
  35. data/lib/cimi/models/machine_template_collection.rb +6 -4
  36. data/lib/cimi/models/machine_volume.rb +42 -0
  37. data/lib/cimi/models/machine_volume_collection.rb +34 -0
  38. data/lib/cimi/models/network.rb +5 -9
  39. data/lib/cimi/models/network_collection.rb +6 -5
  40. data/lib/cimi/models/schema.rb +20 -0
  41. data/lib/cimi/models/volume_collection.rb +6 -4
  42. data/lib/cimi/models/volume_configuration_collection.rb +6 -4
  43. data/lib/cimi/models/volume_image_collection.rb +6 -4
  44. data/lib/cimi/models/volume_template_collection.rb +6 -4
  45. data/lib/deltacloud/api.rb +3 -3
  46. data/lib/deltacloud/collections/addresses.rb +1 -1
  47. data/lib/deltacloud/collections/firewalls.rb +4 -2
  48. data/lib/deltacloud/collections/keys.rb +1 -1
  49. data/lib/deltacloud/collections/load_balancers.rb +1 -1
  50. data/lib/deltacloud/collections/storage_volumes.rb +4 -4
  51. data/lib/deltacloud/drivers/base_driver.rb +12 -20
  52. data/lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb +294 -0
  53. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +38 -6
  54. data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +4 -0
  55. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +40 -4
  56. data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +8 -7
  57. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +422 -416
  58. data/lib/deltacloud/drivers/google/google_driver.rb +2 -1
  59. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +30 -16
  60. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +1 -0
  61. data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +3 -9
  62. data/lib/deltacloud/helpers/deltacloud_helper.rb +0 -2
  63. data/lib/deltacloud/models/firewall_rule.rb +2 -0
  64. data/lib/deltacloud/models/hardware_profile.rb +61 -59
  65. data/{tests/deprecated/core_ext/string.rb → lib/deltacloud/version.rb} +3 -15
  66. data/lib/deltacloud_rack.rb +1 -0
  67. data/lib/ec2/server.rb +5 -3
  68. data/lib/sinatra/rack_accept.rb +53 -53
  69. data/lib/sinatra/rack_etag.rb +1 -1
  70. data/tests/cimi/collections/cloud_entry_point_test.rb +11 -2
  71. data/tests/deltacloud/common.rb +1 -1
  72. data/tests/deltacloud/rack_test.rb +3 -3
  73. data/tests/drivers/base/base_driver_test.rb +6 -2
  74. data/tests/drivers/base/common.rb +1 -0
  75. data/tests/drivers/base/library_test.rb +6 -2
  76. data/tests/drivers/ec2/common.rb +34 -15
  77. data/tests/drivers/ec2/images_test.rb +2 -3
  78. data/tests/drivers/ec2/instance_test.rb +12 -2
  79. data/tests/drivers/ec2/keys_test.rb +2 -2
  80. data/tests/drivers/ec2/realms_test.rb +7 -3
  81. data/tests/drivers/ec2/storage_snapshots_test.rb +2 -3
  82. data/tests/drivers/gogrid/common.rb +24 -0
  83. data/tests/drivers/gogrid/hardware_profiles_test.rb +51 -0
  84. data/tests/drivers/gogrid/images_test.rb +57 -0
  85. data/tests/drivers/gogrid/instances_test.rb +92 -0
  86. data/tests/drivers/gogrid/realms_test.rb +45 -0
  87. data/tests/drivers/google/buckets_test.rb +105 -0
  88. data/tests/drivers/google/common.rb +20 -0
  89. data/tests/drivers/mock/common.rb +1 -0
  90. data/tests/drivers/mock/images_test.rb +3 -2
  91. data/tests/drivers/mock/instances_test.rb +3 -2
  92. data/tests/drivers/mock/keys_test.rb +3 -2
  93. data/tests/drivers/mock/realms_test.rb +3 -2
  94. data/tests/drivers/mock/storage_snapshots_test.rb +3 -2
  95. data/tests/drivers/mock/storage_volumes_test.rb +3 -2
  96. data/tests/drivers/models/address_test.rb +3 -3
  97. data/tests/drivers/models/base_test.rb +4 -2
  98. data/tests/drivers/models/blob_test.rb +3 -3
  99. data/tests/drivers/models/common.rb +3 -0
  100. data/tests/drivers/models/hardware_profile_test.rb +5 -4
  101. data/tests/drivers/models/instance_address_test.rb +3 -3
  102. data/tests/drivers/models/instance_profile_test.rb +3 -3
  103. data/tests/drivers/models/instance_test.rb +3 -3
  104. data/tests/drivers/models/keys_test.rb +3 -3
  105. data/tests/drivers/models/metrics_test.rb +3 -3
  106. data/tests/drivers/openstack/common.rb +26 -0
  107. data/tests/drivers/openstack/hardware_profiles_test.rb +46 -0
  108. data/tests/drivers/openstack/images_test.rb +50 -0
  109. data/tests/drivers/openstack/instances_test.rb +66 -0
  110. data/tests/drivers/openstack/keys_test.rb +61 -0
  111. data/tests/drivers/openstack/realms_test.rb +46 -0
  112. data/tests/drivers/rhevm/common.rb +2 -0
  113. data/tests/drivers/rhevm/images_test.rb +3 -4
  114. data/tests/drivers/rhevm/instance_test.rb +2 -2
  115. data/tests/drivers/rhevm/provider_test.rb +2 -2
  116. data/tests/drivers/rhevm/realms_test.rb +2 -3
  117. data/tests/ec2/common.rb +5 -4
  118. data/tests/ec2/server_test.rb +3 -2
  119. data/tests/helpers/rack/common.rb +3 -0
  120. data/tests/helpers/rack/rack_accept_test.rb +65 -0
  121. data/tests/helpers/rack/rack_date_test.rb +27 -0
  122. data/tests/helpers/rack/rack_driver_select_test.rb +53 -0
  123. data/tests/helpers/rack/rack_etag_test.rb +29 -0
  124. data/tests/helpers/rack/rack_matrix_params_test.rb +72 -0
  125. data/tests/test_helper.rb +44 -36
  126. data/views/hardware_profiles/index.html.haml +1 -1
  127. data/views/hardware_profiles/show.html.haml +2 -2
  128. data/views/hardware_profiles/show.xml.haml +2 -1
  129. data/views/images/show.html.haml +6 -5
  130. metadata +74 -117
  131. data/tests/deprecated/api/common.rb +0 -1
  132. data/tests/deprecated/api/driver_test.rb +0 -79
  133. data/tests/deprecated/api/library_test.rb +0 -6
  134. data/tests/deprecated/cimi/features/step_definitions/common_steps.rb +0 -59
  135. data/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb +0 -0
  136. data/tests/deprecated/cimi/features/step_definitions/machines_steps.rb +0 -100
  137. data/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb +0 -115
  138. data/tests/deprecated/cimi/features/support/env.rb +0 -75
  139. data/tests/deprecated/common.rb +0 -279
  140. data/tests/deprecated/drivers/ec2/api_test.rb +0 -19
  141. data/tests/deprecated/drivers/ec2/common.rb +0 -23
  142. data/tests/deprecated/drivers/ec2/drivers_test.rb +0 -120
  143. data/tests/deprecated/drivers/ec2/hardware_profiles_test.rb +0 -224
  144. data/tests/deprecated/drivers/ec2/images_test.rb +0 -230
  145. data/tests/deprecated/drivers/ec2/instances_test.rb +0 -356
  146. data/tests/deprecated/drivers/ec2/keys_test.rb +0 -181
  147. data/tests/deprecated/drivers/ec2/realms_test.rb +0 -146
  148. data/tests/deprecated/drivers/fgcp/api_test.rb +0 -47
  149. data/tests/deprecated/drivers/fgcp/hardware_profiles_test.rb +0 -54
  150. data/tests/deprecated/drivers/fgcp/realms_test.rb +0 -42
  151. data/tests/deprecated/drivers/fgcp/setup.rb +0 -13
  152. data/tests/deprecated/drivers/google/api_test.rb +0 -19
  153. data/tests/deprecated/drivers/google/buckets_test.rb +0 -100
  154. data/tests/deprecated/drivers/google/common.rb +0 -54
  155. data/tests/deprecated/drivers/mock/api_test.rb +0 -10
  156. data/tests/deprecated/drivers/mock/buckets_test.rb +0 -195
  157. data/tests/deprecated/drivers/mock/common.rb +0 -7
  158. data/tests/deprecated/drivers/mock/drivers_test.rb +0 -123
  159. data/tests/deprecated/drivers/mock/hardware_profiles_test.rb +0 -224
  160. data/tests/deprecated/drivers/mock/images_test.rb +0 -197
  161. data/tests/deprecated/drivers/mock/instances_test.rb +0 -343
  162. data/tests/deprecated/drivers/mock/keys_test.rb +0 -161
  163. data/tests/deprecated/drivers/mock/realms_test.rb +0 -132
  164. data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +0 -114
  165. data/tests/deprecated/drivers/mock/storage_volumes_test.rb +0 -122
  166. data/tests/deprecated/drivers/openstack/api_test.rb +0 -46
  167. data/tests/deprecated/drivers/openstack/common.rb +0 -21
  168. data/tests/deprecated/drivers/openstack/hardware_profiles_test.rb +0 -64
  169. data/tests/deprecated/drivers/openstack/images_test.rb +0 -46
  170. data/tests/deprecated/drivers/openstack/instances_test.rb +0 -208
  171. data/tests/deprecated/drivers/openstack/realms_test.rb +0 -40
  172. data/tests/deprecated/drivers/rackspace/api_test.rb +0 -46
  173. data/tests/deprecated/drivers/rackspace/buckets_test.rb +0 -150
  174. data/tests/deprecated/drivers/rackspace/common.rb +0 -16
  175. data/tests/deprecated/drivers/rackspace/hardware_profiles_test.rb +0 -58
  176. data/tests/deprecated/drivers/rackspace/images_test.rb +0 -45
  177. data/tests/deprecated/drivers/rackspace/instances_test.rb +0 -166
  178. data/tests/deprecated/drivers/rackspace/realms_test.rb +0 -41
  179. data/tests/deprecated/drivers/rhevm/api_test.rb +0 -45
  180. data/tests/deprecated/drivers/rhevm/common.rb +0 -21
  181. data/tests/deprecated/drivers/rhevm/hardware_profiles_test.rb +0 -58
  182. data/tests/deprecated/drivers/rhevm/images_test.rb +0 -48
  183. data/tests/deprecated/drivers/rhevm/instances_test.rb +0 -182
  184. data/tests/deprecated/drivers/rhevm/realms_test.rb +0 -40
  185. data/tests/deprecated/minitest_common.rb +0 -58
  186. data/tests/deprecated/minitest_common_api_test.rb +0 -115
  187. data/tests/deprecated/rabbit_test.rb +0 -52
@@ -16,10 +16,11 @@
16
16
  module CIMI::Collections
17
17
  class NetworkTemplates < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
+
20
21
  collection :network_templates do
21
22
 
22
- operation :index do
23
+ operation :index, :with_capability => :network_templates do
23
24
  description 'List all Network Templates in the NetworkTemplateCollection'
24
25
  param :CIMISelect, :string, :optional
25
26
  control do
@@ -31,7 +32,7 @@ module CIMI::Collections
31
32
  end
32
33
  end
33
34
 
34
- operation :show do
35
+ operation :show, :with_capability => :network_template do
35
36
  description 'Show a specific Network Template'
36
37
  control do
37
38
  network_template = NetworkTemplate.find(params[:id], self)
@@ -16,12 +16,12 @@
16
16
  module CIMI::Collections
17
17
  class Networks < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
20
 
21
21
  collection :networks do
22
22
  description 'A Network represents an abstraction of a layer 2 broadcast domain'
23
23
 
24
- operation :index do
24
+ operation :index, :with_capability => :networks do
25
25
  description "List all Networks"
26
26
  param :CIMISelect, :string, :optional
27
27
  control do
@@ -33,7 +33,7 @@ module CIMI::Collections
33
33
  end
34
34
  end
35
35
 
36
- operation :show do
36
+ operation :show, :with_capability => :networks do
37
37
  description "Show a specific Network"
38
38
  control do
39
39
  network = Network.find(params[:id], self)
@@ -44,7 +44,7 @@ module CIMI::Collections
44
44
  end
45
45
  end
46
46
 
47
- operation :create do
47
+ operation :create, :with_capability => :create_network do
48
48
  description "Create a new Network"
49
49
  control do
50
50
  if request.content_type.end_with?("json")
@@ -59,7 +59,7 @@ module CIMI::Collections
59
59
  end
60
60
  end
61
61
 
62
- operation :destroy do
62
+ operation :destroy, :with_capability => :delete_network do
63
63
  description "Delete a specified Network"
64
64
  param :id, :string, :required
65
65
  control do
@@ -68,7 +68,7 @@ module CIMI::Collections
68
68
  end
69
69
  end
70
70
 
71
- action :start do
71
+ action :start, :with_capability => :start_network do
72
72
  description "Start specific network."
73
73
  control do
74
74
  network = Network.find(params[:id], self)
@@ -85,7 +85,7 @@ module CIMI::Collections
85
85
  end
86
86
  end
87
87
 
88
- action :stop do
88
+ action :stop, :with_capability => :stop_network do
89
89
  description "Stop specific network."
90
90
  control do
91
91
  network = Network.find(params[:id], self)
@@ -102,7 +102,7 @@ module CIMI::Collections
102
102
  end
103
103
  end
104
104
 
105
- action :suspend do
105
+ action :suspend, :with_capability => :suspend_network do
106
106
  description "Suspend specific network."
107
107
  control do
108
108
  network = Network.find(params[:id], self)
@@ -16,10 +16,11 @@
16
16
  module CIMI::Collections
17
17
  class RoutingGroupTemplates < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
+
20
21
  collection :routing_group_templates do
21
22
 
22
- operation :index do
23
+ operation :index, :with_capability => :routing_groups do
23
24
  description 'List all RoutingGroupTemplates in the RoutingGroupTemplateCollection'
24
25
  param :CIMISelect, :string, :optional
25
26
  control do
@@ -31,7 +32,7 @@ module CIMI::Collections
31
32
  end
32
33
  end
33
34
 
34
- operation :show do
35
+ operation :show, :with_capability => :routing_group do
35
36
  description 'Show a specific RoutingGroupTemplate'
36
37
  control do
37
38
  routing_group_template = RoutingGroupTemplate.find(params[:id], self)
@@ -16,10 +16,11 @@
16
16
  module CIMI::Collections
17
17
  class RoutingGroups < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
+
20
21
  collection :routing_groups do
21
22
 
22
- operation :index do
23
+ operation :index, :with_capability => :routing_groups do
23
24
  description 'List all RoutingGroups in the RoutingGroupsCollection'
24
25
  param :CIMISelect, :string, :optional
25
26
  control do
@@ -31,7 +32,7 @@ module CIMI::Collections
31
32
  end
32
33
  end
33
34
 
34
- operation :show do
35
+ operation :show, :with_capability => :routing_group do
35
36
  description 'Show a specific RoutingGroup'
36
37
  control do
37
38
  routing_group = RoutingGroup.find(params[:id], self)
@@ -16,11 +16,11 @@
16
16
  module CIMI::Collections
17
17
  class VolumeConfigurations < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
20
 
21
21
  collection :volume_configurations do
22
22
 
23
- operation :index do
23
+ operation :index, :with_capability => :storage_volumes do
24
24
  description "Get list all VolumeConfigurations"
25
25
  param :CIMISelect, :string, :optional
26
26
  control do
@@ -32,7 +32,7 @@ module CIMI::Collections
32
32
  end
33
33
  end
34
34
 
35
- operation :show do
35
+ operation :show, :with_capability => :storage_volume do
36
36
  description "Get a specific VolumeConfiguration"
37
37
  control do
38
38
  volume_config = VolumeConfiguration.find(params[:id], self)
@@ -16,12 +16,12 @@
16
16
  module CIMI::Collections
17
17
  class VolumeImages < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
20
 
21
21
  collection :volume_images do
22
22
  description 'This entity represents an image that could be place on a pre-loaded volume.'
23
23
 
24
- operation :index do
24
+ operation :index, :with_capability => :storage_snapshots do
25
25
  description "List all volumes images"
26
26
  param :CIMISelect, :string, :optional
27
27
  control do
@@ -33,7 +33,7 @@ module CIMI::Collections
33
33
  end
34
34
  end
35
35
 
36
- operation :show do
36
+ operation :show, :with_capability => :storage_snapshot do
37
37
  description "Show a specific volume image"
38
38
  control do
39
39
  volume_image = VolumeImage.find(params[:id], self)
@@ -16,10 +16,11 @@
16
16
  module CIMI::Collections
17
17
  class Volumes < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
+
20
21
  collection :volumes do
21
22
 
22
- operation :index do
23
+ operation :index, :with_capability => :storage_volumes do
23
24
  description "List all volumes"
24
25
  param :CIMISelect, :string, :optional
25
26
  control do
@@ -31,7 +32,7 @@ module CIMI::Collections
31
32
  end
32
33
  end
33
34
 
34
- operation :show do
35
+ operation :show, :with_capability => :storage_volume do
35
36
  description "Show specific Volume."
36
37
  control do
37
38
  volume = Volume.find(params[:id], self)
@@ -16,10 +16,11 @@
16
16
  module CIMI::Collections
17
17
  class VspConfigurations < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
+
20
21
  collection :vsp_configurations do
21
22
 
22
- operation :index do
23
+ operation :index, :with_capability => :vsp_configurations do
23
24
  description 'List all VSPConfigurations in the VSPConfigurationCollection'
24
25
  param :CIMISelect, :string, :optional
25
26
  control do
@@ -31,7 +32,7 @@ module CIMI::Collections
31
32
  end
32
33
  end
33
34
 
34
- operation :show do
35
+ operation :show, :with_capability => :vsp_configuration do
35
36
  description 'Show a specific VSPConfiguration'
36
37
  control do
37
38
  vsp_config = VSPConfiguration.find(params[:id], self)
@@ -16,12 +16,13 @@
16
16
  module CIMI::Collections
17
17
  class VspTemplates < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
+
20
21
  collection :vsp_templates do
21
22
 
22
23
  description 'The VSP Template is a set of Configuration values for realizing a VSP. A VSP Template may be used to create multiple VSPs'
23
24
 
24
- operation :index do
25
+ operation :index, :with_capability => :vsp_templates do
25
26
  description 'List all VSPTemplates in the VSPTemplateCollection'
26
27
  param :CIMISelect, :string, :optional
27
28
  control do
@@ -33,7 +34,7 @@ module CIMI::Collections
33
34
  end
34
35
  end
35
36
 
36
- operation :show do
37
+ operation :show, :with_capability => :vsp_template do
37
38
  description 'Show a specific VSPTemplate'
38
39
  control do
39
40
  vsp_template = VSPTemplate.find(params[:id], self)
@@ -16,12 +16,13 @@
16
16
  module CIMI::Collections
17
17
  class Vsps < Base
18
18
 
19
- check_capability :for => lambda { |m| driver.respond_to? m }
19
+ set :capability, lambda { |m| driver.respond_to? m }
20
+
20
21
  collection :vsps do
21
22
 
22
23
  description 'A VSP represents the connection parameters of a network port'
23
24
 
24
- operation :index do
25
+ operation :index, :with_capability => :vsps do
25
26
  description 'List all VSPs in the VSPCollection'
26
27
  param :CIMISelect, :string, :optional
27
28
  control do
@@ -33,7 +34,7 @@ module CIMI::Collections
33
34
  end
34
35
  end
35
36
 
36
- operation :show do
37
+ operation :show, :with_capability => :vsp do
37
38
  description 'Show a specific VSP'
38
39
  control do
39
40
  vsp = VSP.find(params[:id], self)
@@ -44,7 +45,7 @@ module CIMI::Collections
44
45
  end
45
46
  end
46
47
 
47
- operation :create do
48
+ operation :create, :with_capability => :create_vsp do
48
49
  description "Create a new VSP"
49
50
  control do
50
51
  if request.content_type.end_with?("json")
@@ -59,7 +60,7 @@ module CIMI::Collections
59
60
  end
60
61
  end
61
62
 
62
- operation :destroy do
63
+ operation :destroy, :with_capability => :delete_vsp do
63
64
  description "Delete a specified VSP"
64
65
  control do
65
66
  CIMI::Model::VSP.delete!(params[:id], self)
@@ -67,7 +68,7 @@ module CIMI::Collections
67
68
  end
68
69
  end
69
70
 
70
- action :start do
71
+ action :start, :with_capability => :start_vsp do
71
72
  description "Start specific VSP."
72
73
  param :id, :string, :required
73
74
  control do
@@ -85,7 +86,7 @@ module CIMI::Collections
85
86
  end
86
87
  end
87
88
 
88
- action :stop do
89
+ action :stop, :with_capability => :stop_vsp do
89
90
  description "Stop specific VSP."
90
91
  control do
91
92
  vsp = VSP.find(params[:id], self)
@@ -86,7 +86,7 @@ module CIMI::Collections
86
86
  end
87
87
 
88
88
  after do
89
- headers 'X-CIMI-Specification-Version' => Deltacloud[:cimi].version
89
+ headers 'CIMI-Specification-Version' => Deltacloud[:cimi].version
90
90
  end
91
91
 
92
92
  def self.new_route_for(route, &block)
@@ -20,12 +20,22 @@ module CIMIHelper
20
20
  status code
21
21
  end
22
22
 
23
-
24
23
  def href_id(href, entity)
25
24
  split_on = self.send(:"#{entity.to_s}_url")
26
25
  href.split("#{split_on}/").last
27
26
  end
28
27
 
28
+ def to_kibibyte(value, unit)
29
+ case unit
30
+ when "GB"
31
+ value*1024*1024
32
+ when "MB"
33
+ value*1024
34
+ else
35
+ nil # should probably be exploding something here...
36
+ end
37
+ end
38
+
29
39
  end
30
40
 
31
41
  class Array
@@ -64,3 +64,7 @@ require_relative './models/address'
64
64
  require_relative './models/address_collection'
65
65
  require_relative './models/address_template'
66
66
  require_relative './models/address_template_collection'
67
+ require_relative './models/disk'
68
+ require_relative './models/disk_collection'
69
+ require_relative './models/machine_volume'
70
+ require_relative './models/machine_volume_collection'
@@ -107,7 +107,7 @@ class CIMI::Model::Base
107
107
  @schema_duped
108
108
  end
109
109
 
110
- private :'clone_base_schema', :'base_schema_cloned?'
110
+ private :clone_base_schema, :base_schema_cloned?
111
111
 
112
112
  def inherited(child)
113
113
  child.instance_eval do
@@ -168,6 +168,16 @@ class CIMI::Model::Base
168
168
  model
169
169
  end
170
170
 
171
+ def self.parse(text, content_type)
172
+ if content_type == "application/xml"
173
+ from_xml(text)
174
+ elsif content_type == "application/json"
175
+ from_json(text)
176
+ else
177
+ raise "Can not parse content type #{content_type}"
178
+ end
179
+ end
180
+
171
181
  #
172
182
  # Serialize
173
183
  #
@@ -16,19 +16,11 @@
16
16
  class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
17
17
 
18
18
  text :base_uri, :xml_name => "baseURI", :json_name => "baseURI"
19
+
19
20
  array :entity_metadata do
20
21
  scalar :href
21
22
  end
22
23
 
23
- DELTACLOUD_MAPPINGS = { "MachineImages" => "images",
24
- "MachineConfigurations" => "hardware_profiles",
25
- "Machines" => "instances",
26
- "Volumes" => "storage_volumes",
27
- "MachineAdmins" => "keys",
28
- "VolumeImages" => "storage_snapshots",
29
- }
30
-
31
-
32
24
  def self.create(context)
33
25
  self.new(entities(context).merge({
34
26
  :name => context.driver.name,
@@ -42,12 +34,13 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
42
34
 
43
35
  # Return an Hash of the CIMI root entities used in CloudEntryPoint
44
36
  def self.entities(context)
45
- CIMI::Model.root_entities.inject({}) do |result, entity|
46
- if DELTACLOUD_MAPPINGS[entity]
47
- next result unless context.driver.respond_to?(DELTACLOUD_MAPPINGS[entity])
37
+ CIMI::Collections.cimi_modules.inject({}) do |supported_entities, m|
38
+ m.collections.each do |c|
39
+ index_operation_capability = c.operation(:index).required_capability
40
+ next if m.settings.respond_to?(:capability) and !m.settings.capability(index_operation_capability)
41
+ supported_entities[c.collection_name.to_s] = { :href => context.send(:"#{c.collection_name}_url") }
48
42
  end
49
- result[entity.underscore] = { :href => context.send(:"#{entity.underscore}_url") }
50
- result
43
+ supported_entities
51
44
  end
52
45
  end
53
46
 
@@ -0,0 +1,40 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership. The
4
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the
6
+ # License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ class CIMI::Model::Disk < CIMI::Model::Base
17
+
18
+ text :capacity
19
+ text :initial_location
20
+
21
+ array :operations do
22
+ scalar :rel, :href
23
+ end
24
+
25
+ def self.find(instance, machine_config, context, id=:all)
26
+ if id == :all
27
+ storage_override = instance.instance_profile.overrides.find { |p, v| p == :storage }
28
+ capacity = storage_override.nil? ? machine_config.disks[0][:capacity] : context.to_kibibyte(storage_override[1].to_i, "MB")
29
+ name = instance.id+"_disk_#{capacity}" #assuming one disk for now...
30
+ [ self.new(
31
+ :id => context.machine_url(instance.id)+"/disks/#{name}",
32
+ :name => name,
33
+ :description => "DiskCollection for Machine #{instance.id}",
34
+ :created => instance.launch_time,
35
+ :capacity => capacity
36
+ ) ]
37
+ else
38
+ end
39
+ end
40
+ end