deltacloud-core 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. data/deltacloud-core.gemspec +4 -7
  2. data/lib/cimi/collections/address_templates.rb +4 -42
  3. data/lib/cimi/collections/addresses.rb +5 -43
  4. data/lib/cimi/collections/base.rb +11 -3
  5. data/lib/cimi/collections/cloud_entry_point.rb +1 -1
  6. data/lib/cimi/collections/credentials.rb +4 -43
  7. data/lib/cimi/collections/forwarding_group_templates.rb +2 -20
  8. data/lib/cimi/collections/forwarding_groups.rb +2 -21
  9. data/lib/cimi/collections/machine_configurations.rb +2 -20
  10. data/lib/cimi/collections/machine_images.rb +4 -42
  11. data/lib/cimi/collections/machine_templates.rb +4 -42
  12. data/lib/cimi/collections/machines.rb +14 -64
  13. data/lib/cimi/collections/network_configurations.rb +2 -20
  14. data/lib/cimi/collections/network_port_configurations.rb +2 -21
  15. data/lib/cimi/collections/network_port_templates.rb +2 -23
  16. data/lib/cimi/collections/network_ports.rb +6 -46
  17. data/lib/cimi/collections/network_templates.rb +2 -21
  18. data/lib/cimi/collections/networks.rb +4 -40
  19. data/lib/cimi/collections/resource_metadata.rb +2 -21
  20. data/lib/cimi/collections/system_templates.rb +4 -45
  21. data/lib/cimi/collections/systems.rb +65 -82
  22. data/lib/cimi/collections/volume_configurations.rb +4 -45
  23. data/lib/cimi/collections/volume_images.rb +4 -42
  24. data/lib/cimi/collections/volume_templates.rb +5 -44
  25. data/lib/cimi/collections/volumes.rb +4 -48
  26. data/lib/cimi/helpers.rb +1 -0
  27. data/lib/cimi/helpers/cimi_helper.rb +1 -1
  28. data/lib/cimi/helpers/cimi_rabbit_helper.rb +113 -0
  29. data/lib/cimi/helpers/database_helper.rb +1 -2
  30. data/lib/cimi/models.rb +12 -11
  31. data/lib/cimi/models/action.rb +0 -4
  32. data/lib/cimi/models/address.rb +0 -38
  33. data/lib/cimi/models/address_create.rb +0 -31
  34. data/lib/cimi/models/address_template.rb +0 -47
  35. data/lib/cimi/models/address_template_create.rb +0 -16
  36. data/lib/cimi/models/base.rb +2 -74
  37. data/lib/cimi/models/cloud_entry_point.rb +2 -30
  38. data/lib/cimi/models/collection.rb +8 -25
  39. data/lib/cimi/models/credential.rb +0 -34
  40. data/lib/cimi/models/credential_create.rb +0 -26
  41. data/lib/cimi/models/credential_template.rb +0 -2
  42. data/lib/cimi/models/disk.rb +0 -56
  43. data/lib/cimi/models/forwarding_group.rb +0 -8
  44. data/lib/cimi/models/forwarding_group_template.rb +0 -8
  45. data/lib/cimi/models/machine.rb +4 -129
  46. data/lib/cimi/models/machine_configuration.rb +0 -31
  47. data/lib/cimi/models/machine_create.rb +1 -29
  48. data/lib/cimi/models/machine_image.rb +0 -28
  49. data/lib/cimi/models/machine_image_create.rb +0 -19
  50. data/lib/cimi/models/machine_template.rb +5 -39
  51. data/lib/cimi/models/machine_template_create.rb +0 -12
  52. data/lib/cimi/models/machine_volume.rb +0 -65
  53. data/lib/cimi/models/network.rb +0 -32
  54. data/lib/cimi/models/network_configuration.rb +0 -15
  55. data/lib/cimi/models/network_create.rb +0 -23
  56. data/lib/cimi/models/network_port.rb +0 -73
  57. data/lib/cimi/models/network_port_configuration.rb +0 -8
  58. data/lib/cimi/models/network_port_template.rb +0 -8
  59. data/lib/cimi/models/network_template.rb +2 -12
  60. data/lib/cimi/models/resource.rb +0 -6
  61. data/lib/cimi/models/resource_metadata.rb +1 -95
  62. data/lib/cimi/models/schema.rb +28 -32
  63. data/lib/cimi/models/system.rb +15 -39
  64. data/lib/cimi/models/system_address.rb +26 -0
  65. data/lib/cimi/models/system_create.rb +20 -0
  66. data/lib/cimi/models/system_credential.rb +26 -0
  67. data/lib/cimi/models/system_forwarding_group.rb +26 -0
  68. data/lib/cimi/models/system_machine.rb +26 -0
  69. data/lib/cimi/models/system_network.rb +26 -0
  70. data/lib/cimi/models/system_network_port.rb +26 -0
  71. data/lib/cimi/models/system_system.rb +26 -0
  72. data/lib/cimi/models/system_template.rb +15 -31
  73. data/lib/cimi/models/system_volume.rb +26 -0
  74. data/lib/cimi/models/volume.rb +0 -59
  75. data/lib/cimi/models/volume_configuration.rb +1 -64
  76. data/lib/cimi/models/volume_configuration_create.rb +22 -0
  77. data/lib/cimi/models/volume_create.rb +0 -38
  78. data/lib/cimi/models/volume_image.rb +0 -30
  79. data/lib/cimi/models/volume_image_create.rb +0 -25
  80. data/lib/cimi/models/volume_template.rb +2 -43
  81. data/lib/cimi/models/volume_template_create.rb +0 -12
  82. data/lib/cimi/service.rb +82 -0
  83. data/lib/cimi/service/action.rb +21 -0
  84. data/lib/cimi/service/address.rb +56 -0
  85. data/lib/cimi/service/address_create.rb +45 -0
  86. data/lib/cimi/service/address_template.rb +71 -0
  87. data/lib/cimi/service/address_template_create.rb +34 -0
  88. data/lib/cimi/service/base.rb +266 -0
  89. data/lib/cimi/service/cloud_entry_point.rb +53 -0
  90. data/lib/cimi/service/credential.rb +52 -0
  91. data/lib/cimi/service/credential_create.rb +38 -0
  92. data/lib/cimi/service/credential_template.rb +20 -0
  93. data/lib/cimi/service/disk.rb +75 -0
  94. data/lib/cimi/service/forwarding_group.rb +26 -0
  95. data/lib/cimi/service/forwarding_group_template.rb +26 -0
  96. data/lib/cimi/service/machine.rb +154 -0
  97. data/lib/cimi/service/machine_configuration.rb +54 -0
  98. data/lib/cimi/service/machine_create.rb +49 -0
  99. data/lib/cimi/service/machine_image.rb +47 -0
  100. data/lib/cimi/service/machine_image_create.rb +35 -0
  101. data/lib/cimi/service/machine_template.rb +61 -0
  102. data/lib/cimi/service/machine_template_create.rb +29 -0
  103. data/lib/cimi/service/machine_volume.rb +74 -0
  104. data/lib/cimi/service/network.rb +51 -0
  105. data/lib/cimi/service/network_configuration.rb +36 -0
  106. data/lib/cimi/service/network_create.rb +39 -0
  107. data/lib/cimi/service/network_port.rb +97 -0
  108. data/lib/cimi/service/network_port_configuration.rb +26 -0
  109. data/lib/cimi/service/network_port_template.rb +26 -0
  110. data/lib/cimi/service/network_template.rb +28 -0
  111. data/lib/cimi/service/resource_metadata.rb +44 -0
  112. data/lib/cimi/service/system.rb +45 -0
  113. data/lib/cimi/service/system_address.rb +34 -0
  114. data/lib/cimi/service/system_create.rb +39 -0
  115. data/lib/cimi/service/system_credential.rb +34 -0
  116. data/lib/cimi/service/system_forwarding_group.rb +34 -0
  117. data/lib/cimi/service/system_machine.rb +34 -0
  118. data/lib/cimi/service/system_network.rb +34 -0
  119. data/lib/cimi/service/system_network_port.rb +34 -0
  120. data/lib/cimi/service/system_system.rb +34 -0
  121. data/lib/cimi/service/system_template.rb +32 -0
  122. data/lib/cimi/service/system_volume.rb +34 -0
  123. data/lib/cimi/service/volume.rb +81 -0
  124. data/lib/cimi/service/volume_configuration.rb +92 -0
  125. data/lib/cimi/service/volume_configuration_create.rb +29 -0
  126. data/lib/cimi/service/volume_create.rb +47 -0
  127. data/lib/cimi/service/volume_image.rb +44 -0
  128. data/lib/cimi/service/volume_image_create.rb +42 -0
  129. data/lib/cimi/service/volume_template.rb +61 -0
  130. data/lib/cimi/service/volume_template_create.rb +29 -0
  131. data/lib/db/entity.rb +16 -1
  132. data/lib/deltacloud/collections/addresses.rb +2 -2
  133. data/lib/deltacloud/collections/buckets.rb +16 -18
  134. data/lib/deltacloud/collections/drivers.rb +4 -4
  135. data/lib/deltacloud/collections/firewalls.rb +5 -5
  136. data/lib/deltacloud/collections/images.rb +3 -3
  137. data/lib/deltacloud/collections/instance_states.rb +4 -4
  138. data/lib/deltacloud/collections/instances.rb +22 -13
  139. data/lib/deltacloud/collections/keys.rb +2 -2
  140. data/lib/deltacloud/collections/load_balancers.rb +16 -13
  141. data/lib/deltacloud/collections/storage_snapshots.rb +3 -3
  142. data/lib/deltacloud/collections/storage_volumes.rb +5 -5
  143. data/lib/deltacloud/core_ext/ordered_hash.rb +0 -4
  144. data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +8 -0
  145. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +4 -3
  146. data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +266 -19
  147. data/lib/deltacloud/drivers/google/google_driver.rb +6 -0
  148. data/lib/deltacloud/drivers/mock/mock_driver.rb +2 -2
  149. data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +166 -54
  150. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +2 -0
  151. data/lib/deltacloud/helpers/blob_stream_helper.rb +0 -2
  152. data/lib/deltacloud/helpers/deltacloud_helper.rb +22 -22
  153. data/lib/deltacloud/helpers/driver_helper.rb +4 -7
  154. data/lib/deltacloud/helpers/rabbit_helper.rb +5 -0
  155. data/lib/deltacloud/server.rb +4 -4
  156. data/lib/deltacloud/version.rb +1 -1
  157. data/lib/deltacloud_rack.rb +6 -1
  158. data/lib/ec2/server.rb +6 -1
  159. data/tests/cimi/collections/common.rb +33 -0
  160. data/tests/cimi/collections/machines_test.rb +19 -0
  161. data/tests/cimi/collections/system_templates_test.rb +47 -0
  162. data/tests/cimi/collections/volumes_test.rb +42 -0
  163. data/tests/cimi/db/database_helper_test.rb +7 -4
  164. data/tests/deltacloud/drivers_test.rb +1 -1
  165. data/tests/drivers/ec2/common.rb +4 -1
  166. data/tests/drivers/fgcp/common.rb +1 -2
  167. data/tests/drivers/gogrid/common.rb +1 -2
  168. data/tests/drivers/google/common.rb +1 -1
  169. data/tests/drivers/models/address_test.rb +2 -2
  170. data/tests/drivers/models/base_test.rb +2 -2
  171. data/tests/drivers/models/blob_test.rb +2 -2
  172. data/tests/drivers/models/instance_address_test.rb +8 -8
  173. data/tests/drivers/models/instance_profile_test.rb +2 -2
  174. data/tests/drivers/models/keys_test.rb +4 -4
  175. data/tests/drivers/models/metrics_test.rb +3 -3
  176. data/tests/drivers/openstack/common.rb +1 -2
  177. data/views/addresses/_address.html.haml +3 -3
  178. data/views/addresses/associate.html.haml +3 -3
  179. data/views/addresses/index.html.haml +2 -2
  180. data/views/addresses/index.xml.haml +2 -2
  181. data/views/addresses/show.html.haml +7 -7
  182. data/views/addresses/show.xml.haml +9 -9
  183. data/views/api/show.html.haml +2 -2
  184. data/views/api/show.xml.haml +1 -1
  185. data/views/blobs/new.html.haml +1 -1
  186. data/views/blobs/show.html.haml +8 -8
  187. data/views/blobs/show.xml.haml +7 -7
  188. data/views/buckets/index.html.haml +1 -1
  189. data/views/buckets/index.xml.haml +2 -2
  190. data/views/buckets/show.html.haml +7 -7
  191. data/views/buckets/show.xml.haml +6 -6
  192. data/views/drivers/index.html.haml +1 -1
  193. data/views/drivers/index.xml.haml +1 -1
  194. data/views/drivers/show.html.haml +6 -6
  195. data/views/drivers/show.xml.haml +5 -5
  196. data/views/error.html.haml +2 -2
  197. data/views/errors/backend_capability_failure.xml.haml +3 -3
  198. data/views/errors/common.html.haml +7 -7
  199. data/views/errors/common.xml.haml +5 -5
  200. data/views/firewalls/index.html.haml +1 -1
  201. data/views/firewalls/index.xml.haml +1 -1
  202. data/views/firewalls/new_rule.html.haml +1 -1
  203. data/views/firewalls/show.html.haml +8 -8
  204. data/views/firewalls/show.xml.haml +9 -9
  205. data/views/hardware_profiles/index.html.haml +1 -1
  206. data/views/hardware_profiles/index.xml.haml +2 -2
  207. data/views/hardware_profiles/show.html.haml +3 -3
  208. data/views/hardware_profiles/show.xml.haml +4 -4
  209. data/views/images/index.html.haml +1 -1
  210. data/views/images/index.xml.haml +2 -2
  211. data/views/images/new.html.haml +2 -2
  212. data/views/images/show.html.haml +14 -14
  213. data/views/images/show.xml.haml +14 -14
  214. data/views/instance_states/show.html.haml +1 -1
  215. data/views/instance_states/show.png.erb +2 -2
  216. data/views/instance_states/show.xml.haml +1 -1
  217. data/views/instances/index.html.haml +1 -1
  218. data/views/instances/index.xml.haml +2 -2
  219. data/views/instances/new.html.haml +22 -14
  220. data/views/instances/run.html.haml +2 -2
  221. data/views/instances/run.xml.haml +3 -3
  222. data/views/instances/run_command.html.haml +4 -4
  223. data/views/instances/show.html.haml +27 -27
  224. data/views/instances/show.xml.haml +37 -37
  225. data/views/keys/index.html.haml +1 -1
  226. data/views/keys/index.xml.haml +2 -2
  227. data/views/keys/show.html.haml +10 -10
  228. data/views/keys/show.xml.haml +12 -12
  229. data/views/load_balancers/index.html.haml +1 -1
  230. data/views/load_balancers/index.xml.haml +2 -2
  231. data/views/load_balancers/new.html.haml +1 -8
  232. data/views/load_balancers/show.html.haml +10 -10
  233. data/views/load_balancers/show.xml.haml +9 -9
  234. data/views/metrics/index.html.haml +1 -1
  235. data/views/metrics/index.xml.haml +2 -2
  236. data/views/metrics/show.html.haml +2 -2
  237. data/views/metrics/show.xml.haml +3 -3
  238. data/views/realms/index.html.haml +1 -1
  239. data/views/realms/index.xml.haml +2 -2
  240. data/views/realms/show.html.haml +6 -6
  241. data/views/realms/show.xml.haml +5 -5
  242. data/views/storage_snapshots/index.html.haml +1 -1
  243. data/views/storage_snapshots/index.xml.haml +2 -2
  244. data/views/storage_snapshots/show.html.haml +6 -6
  245. data/views/storage_snapshots/show.xml.haml +4 -4
  246. data/views/storage_volumes/attach.html.haml +2 -2
  247. data/views/storage_volumes/index.html.haml +1 -1
  248. data/views/storage_volumes/index.xml.haml +2 -2
  249. data/views/storage_volumes/show.html.haml +19 -19
  250. data/views/storage_volumes/show.xml.haml +21 -21
  251. metadata +77 -65
  252. data/views/cimi/cloudEntryPoint/index.html.haml +0 -5
  253. data/views/cimi/cloudEntryPoint/index.xml.haml +0 -9
  254. data/views/cimi/collection/index.html.haml +0 -45
  255. data/views/cimi/collection/response.xml.haml +0 -3
  256. data/views/cimi/error.html.haml +0 -31
  257. data/views/cimi/errors/400.xml.haml +0 -3
  258. data/views/cimi/errors/401.xml.haml +0 -2
  259. data/views/cimi/errors/403.xml.haml +0 -2
  260. data/views/cimi/errors/404.xml.haml +0 -2
  261. data/views/cimi/errors/405.xml.haml +0 -5
  262. data/views/cimi/errors/500.xml.haml +0 -6
  263. data/views/cimi/errors/502.xml.haml +0 -7
  264. data/views/cimi/layout.html.haml +0 -32
  265. data/views/cimi/machine_configurations/show.html.haml +0 -159
  266. data/views/cimi/machine_configurations/show.xml.haml +0 -27
  267. data/views/cimi/machine_images/show.html.haml +0 -79
  268. data/views/cimi/machine_images/show.xml.haml +0 -17
  269. data/views/cimi/machines/show.html.haml +0 -177
  270. data/views/cimi/machines/show.xml.haml +0 -28
  271. data/views/cimi/volumes/show.html.haml +0 -68
  272. data/views/cimi/volumes/show.xml.haml +0 -17
  273. data/views/docs/collection.html.haml +0 -26
  274. data/views/docs/collection.xml.haml +0 -14
  275. data/views/docs/index.html.haml +0 -11
  276. data/views/docs/index.xml.haml +0 -5
  277. data/views/docs/operation.html.haml +0 -33
  278. data/views/docs/operation.xml.haml +0 -10
  279. data/views/root/index.html.haml +0 -4
@@ -21,59 +21,17 @@ module CIMI::Collections
21
21
  collection :systems do
22
22
  description 'List all systems'
23
23
 
24
- operation :index, :with_capability => :systems do
25
- description "List all systems"
26
- control do
27
- systems = System.list(self).select_by(params['$select']).filter_by(params['$filter'])
28
- respond_to do |format|
29
- format.xml { systems.to_xml }
30
- format.json { systems.to_json }
31
- end
32
- end
33
- end
34
-
35
- operation :show, :with_capability => :systems do
36
- description "Show specific system."
37
- control do
38
- system = System.find(params[:id], self)
39
- respond_to do |format|
40
- format.xml { system.to_xml }
41
- format.json { system.to_json }
42
- end
43
- end
44
- end
45
-
46
- operation :create, :with_capability => :create_system do
47
- description "Create a new System entity."
48
- control do
49
- if grab_content_type(request.content_type, request.body) == :json
50
- new_system = System.create_from_json(request.body.read, self)
51
- else
52
- new_system = System.create_from_xml(request.body.read, self)
53
- end
54
- headers_for_create new_system
55
- respond_to do |format|
56
- format.json { new_system.to_json }
57
- format.xml { new_system.to_xml }
58
- end
59
- end
60
- end
61
-
62
- operation :destroy, :with_capability => :destroy_system do
63
- description "Delete a specified system."
64
- control do
65
- System.delete!(params[:id], self)
66
- no_content_with_status(200)
67
- end
68
- end
24
+ generate_index_operation :with_capability => :systems
25
+ generate_show_operation :with_capability => :systems
26
+ generate_create_operation :with_capability => :create_system
27
+ generate_delete_operation :with_capability => :destroy_system
69
28
 
70
29
  action :stop, :with_capability => :stop_system do
71
30
  description "Stop specific system."
72
31
  param :id, :string, :required
73
32
  control do
74
33
  system = System.find(params[:id], self)
75
- action = Action.parse(request.body,
76
- request.content_type)
34
+ action = Action.parse(self)
77
35
  system.perform(action, self) do |operation|
78
36
  no_content_with_status(202) if operation.success?
79
37
  # Handle errors using operation.failure?
@@ -149,45 +107,70 @@ module CIMI::Collections
149
107
  end
150
108
  end
151
109
 
152
- #use rabbit subcollections for volumes index/show:
153
- collection :volumes, :with_id => :vol_id do
154
-
155
- operation :index, :with_capability => :storage_volumes do
156
- description "Retrieve the System's SystemVolumeCollection"
157
- control do
158
- volumes = CIMI::Model::SystemVolume.collection_for_system(params[:id], self)
159
- respond_to do |format|
160
- format.json {volumes.to_json}
161
- format.xml {volumes.to_xml}
162
- end
163
- end
164
- end
110
+ collection :systems, :with_id => :ent_id do
111
+ description 'List system\'s systems'
112
+ generate_system_subcollection_index_operation :with_capability => :system_systems
113
+ generate_system_subcollection_show_operation :with_capability => :system_systems
114
+ generate_add_to_system_operation :with_capability => :add_system_to_system
115
+ generate_remove_from_system_operation :with_capability => :remove_system_from_system
116
+ end
165
117
 
166
- operation :show, :with_capability => :storage_volumes do
167
- description "Retrieve a System's specific SystemVolume"
168
- control do
169
- volume = CIMI::Model::SystemVolume.find(params[:id], self, params[:vol_id])
170
- respond_to do |format|
171
- format.json {volume.to_json}
172
- format.xml {volume.to_xml}
173
- end
174
- end
175
- end
118
+ collection :machines, :with_id => :ent_id do
119
+ description 'List system\'s machines'
120
+ generate_system_subcollection_index_operation :with_capability => :system_machines
121
+ generate_system_subcollection_show_operation :with_capability => :system_machines
122
+ generate_add_to_system_operation :with_capability => :add_machine_to_system
123
+ generate_remove_from_system_operation :with_capability => :remove_machine_from_system
124
+ end
176
125
 
177
- operation :destroy, :with_capability => :detach_storage_volume do
178
- description "Remove/detach a volume from the System's SystemVolumeCollection"
179
- control do
180
- system_volume = CIMI::Model::SystemVolume.find(params[:id], self, params[:vol_id])
181
- location = system_volume.initial_location
182
- system_volumes = System.detach_volume(params[:vol_id], location, self)
183
- respond_to do |format|
184
- format.json{ system_volumes.to_json}
185
- format.xml{ system_volumes.to_xml}
186
- end
187
- end
188
- end
126
+ collection :credentials, :with_id => :ent_id do
127
+ description 'List system\'s credentials'
128
+ generate_system_subcollection_index_operation :with_capability => :system_credentials
129
+ generate_system_subcollection_show_operation :with_capability => :system_credentials
130
+ generate_add_to_system_operation :with_capability => :add_credential_to_system
131
+ generate_remove_from_system_operation :with_capability => :remove_credential_from_system
132
+ end
189
133
 
134
+ collection :volumes, :with_id => :ent_id do
135
+ description 'List system\'s volumes'
136
+ generate_system_subcollection_index_operation :with_capability => :system_volumes
137
+ generate_system_subcollection_show_operation :with_capability => :system_volumes
138
+ generate_add_to_system_operation :with_capability => :add_volume_to_system
139
+ generate_remove_from_system_operation :with_capability => :remove_volume_from_system
190
140
  end
141
+
142
+ collection :networks, :with_id => :ent_id do
143
+ description 'List system\'s networks'
144
+ generate_system_subcollection_index_operation :with_capability => :system_networks
145
+ generate_system_subcollection_show_operation :with_capability => :system_networks
146
+ generate_add_to_system_operation :with_capability => :add_network_to_system
147
+ generate_remove_from_system_operation :with_capability => :remove_network_from_system
148
+ end
149
+
150
+ collection :network_ports, :with_id => :ent_id do
151
+ description 'List system\'s network ports'
152
+ generate_system_subcollection_index_operation :with_capability => :system_network_ports
153
+ generate_system_subcollection_show_operation :with_capability => :system_network_ports
154
+ generate_add_to_system_operation :with_capability => :add_network_port_to_system
155
+ generate_remove_from_system_operation :with_capability => :remove_network_port_from_system
156
+ end
157
+
158
+ collection :addresses, :with_id => :ent_id do
159
+ description 'List system\'s addresses'
160
+ generate_system_subcollection_index_operation :with_capability => :system_addresses
161
+ generate_system_subcollection_show_operation :with_capability => :system_addresses
162
+ generate_add_to_system_operation :with_capability => :add_addresses_to_system
163
+ generate_remove_from_system_operation :with_capability => :remove_addresses_from_system
164
+ end
165
+
166
+ collection :forwarding_groups, :with_id => :ent_id do
167
+ description 'List system\'s forwarding groups'
168
+ generate_system_subcollection_index_operation :with_capability => :system_forwarding_groups
169
+ generate_system_subcollection_show_operation :with_capability => :system_forwarding_groups
170
+ generate_add_to_system_operation :with_capability => :add_forwarding_groups_to_system
171
+ generate_remove_from_system_operation :with_capability => :remove_forwarding_groups_from_system
172
+ end
173
+
191
174
  end
192
175
 
193
176
  end
@@ -20,51 +20,10 @@ module CIMI::Collections
20
20
 
21
21
  collection :volume_configurations do
22
22
 
23
- operation :index, :with_capability => :storage_volumes do
24
- description "Get list all VolumeConfigurations"
25
- control do
26
- volume_configuration = VolumeConfiguration.list(self).select_by(params['$select'])
27
- respond_to do |format|
28
- format.xml { volume_configuration.to_xml }
29
- format.json { volume_configuration.to_json }
30
- end
31
- end
32
- end
33
-
34
- operation :show, :with_capability => :storage_volume do
35
- description "Get a specific VolumeConfiguration"
36
- control do
37
- volume_config = VolumeConfiguration.find(params[:id], self)
38
- respond_to do |format|
39
- format.xml { volume_config.to_xml }
40
- format.json { volume_config.json }
41
- end
42
- end
43
- end
44
-
45
- operation :create, :with_capability => :create_storage_volume do
46
- description "Create new VolumeConfiguration"
47
- control do
48
- if current_content_type == :json
49
- new_config = CIMI::Model::VolumeConfiguration.create_from_json(request.body.read, self)
50
- else
51
- new_config = CIMI::Model::VolumeConfiguration.create_from_xml(request.body.read, self)
52
- end
53
- headers_for_create new_config
54
- respond_to do |format|
55
- format.json { new_config.to_json }
56
- format.xml { new_config.to_xml }
57
- end
58
- end
59
- end
60
-
61
- operation :destroy, :with_capability => :destroy_storage_volume do
62
- description "Delete a specified VolumeConfiguration"
63
- control do
64
- CIMI::Model::VolumeConfiguration.delete!(params[:id], self)
65
- no_content_with_status(200)
66
- end
67
- end
23
+ generate_index_operation :with_capability => :storage_volumes
24
+ generate_show_operation :with_capability => :storage_volume
25
+ generate_create_operation :with_capability => :create_storage_volume
26
+ generate_delete_operation :with_capability => :storage_volume
68
27
 
69
28
  end
70
29
 
@@ -21,48 +21,10 @@ module CIMI::Collections
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, :with_capability => :storage_snapshots do
25
- description "List all volumes images"
26
- control do
27
- volume_images = VolumeImage.list(self).select_by(params['$select'])
28
- respond_to do |format|
29
- format.xml { volume_images.to_xml }
30
- format.json { volume_images.to_json }
31
- end
32
- end
33
- end
34
-
35
- operation :show, :with_capability => :storage_snapshot do
36
- description "Show a specific volume image"
37
- control do
38
- volume_image = VolumeImage.find(params[:id], self)
39
- respond_to do |format|
40
- format.xml { volume_image.to_xml }
41
- format.json { volume_image.to_json }
42
- end
43
- end
44
- end
45
-
46
- operation :create, :with_capability => :create_storage_snapshot do
47
- description "Create a new volume image."
48
- control do
49
- img = CIMI::Model::VolumeImageCreate.parse(request.body, request.content_type)
50
- volume_image = img.create(self)
51
- headers_for_create volume_image
52
- respond_to do |format|
53
- format.xml { volume_image.to_xml }
54
- format.json { volume_image.to_json }
55
- end
56
- end
57
- end
58
-
59
- operation :destroy, :with_capability => :destroy_storage_snapshot do
60
- description "Delete a specified VolumeImage"
61
- control do
62
- CIMI::Model::VolumeImage.delete!(params[:id], self)
63
- no_content_with_status 200
64
- end
65
- end
24
+ generate_index_operation :with_capability => :storage_snapshots
25
+ generate_show_operation :with_capability => :storage_snapshot
26
+ generate_create_operation :with_capability => :create_storage_snapshot
27
+ generate_delete_operation :with_capability => :destroy_storage_snapshot
66
28
 
67
29
  end
68
30
 
@@ -20,51 +20,12 @@ module CIMI::Collections
20
20
 
21
21
  collection :volume_templates do
22
22
 
23
- operation :index, :with_capability => :storage_volumes do
24
- description "Retrieve the Volume Template Collection"
25
- control do
26
- volume_template = VolumeTemplate.list(self).select_by(params['$select'])
27
- respond_to do |format|
28
- format.xml { volume_template.to_xml }
29
- format.json { volume_template.to_json }
30
- end
31
- end
32
- end
23
+ generate_index_operation :with_capability => :storage_volumes
24
+ generate_show_operation :with_capability => :storage_volume
25
+ generate_create_operation :with_capability => :create_storage_volume
26
+ generate_delete_operation :with_capability => :destroy_storage_volume
33
27
 
34
- operation :show, :with_capability => :storage_volume do
35
- description "Get a specific VolumeTemplate"
36
- control do
37
- volume_template = VolumeTemplate.find(params[:id], self)
38
- respond_to do |format|
39
- format.xml { volume_template.to_xml }
40
- format.json { volume_template.json }
41
- end
42
- end
43
- end
44
-
45
- operation :create, :with_capability => :create_storage_volume do
46
- description "Create new VolumeTemplate"
47
- control do
48
- puts request.body
49
- vol = CIMI::Model::VolumeTemplateCreate.parse(request.body, request.content_type)
50
- new_template = vol.create(self)
51
- headers_for_create new_template
52
- respond_to do |format|
53
- format.json { new_template.to_json }
54
- format.xml { new_template.to_xml }
55
- end
56
- end
57
- end
58
-
59
- operation :destroy, :with_capability => :destroy_storage_volume do
60
- description "Delete a specified VolumeTemplate"
61
- control do
62
- CIMI::Model::VolumeTemplate.delete!(params[:id], self)
63
- no_content_with_status(200)
64
- end
65
- end
66
-
67
- end
28
+ end
68
29
 
69
30
  end
70
31
  end
@@ -19,54 +19,10 @@ module CIMI::Collections
19
19
  set :capability, lambda { |m| driver.respond_to? m }
20
20
 
21
21
  collection :volumes do
22
-
23
- operation :index, :with_capability => :storage_volumes do
24
- description "List all volumes"
25
- control do
26
- volumes = Volume.list(self).select_by(params['$select'])
27
- respond_to do |format|
28
- format.xml { volumes.to_xml }
29
- format.json { volumes.to_json }
30
- end
31
- end
32
- end
33
-
34
- operation :show, :with_capability => :storage_volume do
35
- description "Show specific Volume."
36
- control do
37
- volume = Volume.find(params[:id], self)
38
- if volume
39
- respond_to do |format|
40
- format.xml { volume.to_xml }
41
- format.json { volume.to_json }
42
- end
43
- else
44
- report_error(404)
45
- end
46
- end
47
- end
48
-
49
- operation :create, :with_capability => :create_storage_volume do
50
- description "Create a new Volume."
51
- control do
52
- vol = CIMI::Model::VolumeCreate.parse(request.body, request.content_type)
53
- new_volume = vol.create(self)
54
- headers_for_create new_volume
55
- respond_to do |format|
56
- format.json { new_volume.to_json }
57
- format.xml { new_volume.to_xml }
58
- end
59
- end
60
- end
61
-
62
- operation :destroy, :with_capability => :destroy_storage_volume do
63
- description "Delete a specified Volume"
64
- control do
65
- Volume.delete!(params[:id], self)
66
- no_content_with_status(200)
67
- end
68
- end
69
-
22
+ generate_index_operation :with_capability => :storage_volumes
23
+ generate_show_operation :with_capability => :storage_volume
24
+ generate_create_operation :with_capability => :create_storage_volume
25
+ generate_delete_operation :with_capability => :destroy_storage_volume
70
26
  end
71
27
 
72
28
 
@@ -35,4 +35,5 @@ require_relative '../deltacloud/helpers/deltacloud_helper'
35
35
  require_relative '../deltacloud/helpers/rabbit_helper'
36
36
 
37
37
  require_relative './helpers/cimi_helper'
38
+ require_relative './helpers/cimi_rabbit_helper'
38
39
  require_relative './helpers/database_helper'
@@ -72,7 +72,7 @@ module CIMI
72
72
  end
73
73
 
74
74
  def deltacloud_create_method_for(cimi_entity)
75
- case cimi_entity
75
+ case cimi_entity.to_s
76
76
  when "machine" then "create_instance"
77
77
  when "machine_configuration" then "create_hardware_profile"
78
78
  when "machine_image" then "create_image"
@@ -0,0 +1,113 @@
1
+ module CIMI
2
+ module RabbitHelper
3
+
4
+ def generate_delete_operation(opts={})
5
+ collection_name = @collection_name.to_s.singularize.camelize
6
+ operation :destroy, :with_capability => opts[:with_capability] do
7
+ description "Delete specified Credential entity"
8
+ control do
9
+ CIMI::Service.const_get(collection_name).delete!(params[:id], self)
10
+ no_content_with_status(200)
11
+ end
12
+ end
13
+ end
14
+
15
+ def generate_create_operation(opts={})
16
+ collection_name = @collection_name.to_s.singularize.camelize
17
+ operation :create, :with_capability => opts[:with_capability] do
18
+ description "Create new #{collection_name} entity"
19
+ control do
20
+ ent = CIMI::Service.const_get("#{collection_name}Create").parse(self).create
21
+ headers_for_create ent
22
+ respond_to do |format|
23
+ format.json { ent.to_json }
24
+ format.xml { ent.to_xml }
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ def generate_index_operation(opts={})
31
+ collection_name = @collection_name.to_s.singularize.camelize
32
+ operation :index, :with_capability => opts[:with_capability] do
33
+ description "List all entities in #{collection_name} collection"
34
+ control do
35
+ ent = CIMI::Service.const_get(collection_name).list(self)
36
+ respond_to do |format|
37
+ format.xml { ent.to_xml }
38
+ format.json { ent.to_json }
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ def generate_show_operation(opts={})
45
+ collection_name = @collection_name.to_s.singularize.camelize
46
+ operation :show, :with_capability => opts[:with_capability] do
47
+ description "Show details about #{collection_name} entity"
48
+ control do
49
+ ent = CIMI::Service.const_get(collection_name).find(params[:id], self)
50
+ respond_to do |format|
51
+ format.xml { ent.to_xml }
52
+ format.json { ent.to_json }
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ def generate_remove_from_system_operation(opts={})
59
+ collection_name = "System#{@collection_name.to_s.singularize.camelize}"
60
+ operation :destroy, :with_capability => opts[:with_capability] do
61
+ description "Remove specified #{collection_name} entity from System"
62
+ control do
63
+ CIMI::Service.const_get(collection_name).delete!(params[:id], self, params[:ent_id])
64
+ no_content_with_status(200)
65
+ end
66
+ end
67
+ end
68
+
69
+ def generate_add_to_system_operation(opts={})
70
+ collection_name = "System#{@collection_name.to_s.singularize.camelize}"
71
+ operation :create, :with_capability => opts[:with_capability] do
72
+ description "Add specified #{collection_name} entity to System"
73
+ control do
74
+ ent = CIMI::Service.const_get("#{collection_name}Create").parse(params[:id], self).create
75
+ headers_for_create ent
76
+ respond_to do |format|
77
+ format.json { ent.to_json }
78
+ format.xml { ent.to_xml }
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ def generate_system_subcollection_index_operation(opts={})
85
+ collection_name = "System#{@collection_name.to_s.singularize.camelize}"
86
+ operation :index, :with_capability => opts[:with_capability] do
87
+ description "List all entities in System's #{collection_name} collection"
88
+ control do
89
+ ent = CIMI::Service.const_get(collection_name).collection_for_system(params[:id], self)
90
+ respond_to do |format|
91
+ format.xml { ent.to_xml }
92
+ format.json { ent.to_json }
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ def generate_system_subcollection_show_operation(opts={})
99
+ collection_name = "System#{@collection_name.to_s.singularize.camelize}"
100
+ operation :show, :with_capability => opts[:with_capability] do
101
+ description "Show details of System's #{collection_name} entity"
102
+ control do
103
+ ent = CIMI::Service.const_get(collection_name).find(params[:id], self, params[:ent_id])
104
+ respond_to do |format|
105
+ format.xml { ent.to_xml }
106
+ format.json { ent.to_json }
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ end
113
+ end