fog-ecloud 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rubocop.yml +20 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +17 -0
  7. data/CONTRIBUTING.md +18 -0
  8. data/CONTRIBUTORS.md +16 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.md +20 -0
  11. data/README.md +38 -0
  12. data/Rakefile +18 -0
  13. data/fog-ecloud.gemspec +35 -0
  14. data/gemfiles/Gemfile.1.9.2- +8 -0
  15. data/gemfiles/Gemfile.1.9.3+ +7 -0
  16. data/lib/fog/ecloud/collection.rb +24 -0
  17. data/lib/fog/ecloud/compute.rb +824 -0
  18. data/lib/fog/ecloud/core.rb +32 -0
  19. data/lib/fog/ecloud/generate_collection.rb +127 -0
  20. data/lib/fog/ecloud/ipaddr.rb +5 -0
  21. data/lib/fog/ecloud/mock_data_classes.rb +766 -0
  22. data/lib/fog/ecloud/model.rb +20 -0
  23. data/lib/fog/ecloud/models/compute/admin_organization.rb +43 -0
  24. data/lib/fog/ecloud/models/compute/admin_organizations.rb +21 -0
  25. data/lib/fog/ecloud/models/compute/api_key.rb +20 -0
  26. data/lib/fog/ecloud/models/compute/api_keys.rb +26 -0
  27. data/lib/fog/ecloud/models/compute/association.rb +23 -0
  28. data/lib/fog/ecloud/models/compute/associations.rb +34 -0
  29. data/lib/fog/ecloud/models/compute/authentication_level.rb +21 -0
  30. data/lib/fog/ecloud/models/compute/authentication_levels.rb +26 -0
  31. data/lib/fog/ecloud/models/compute/backup_internet_service.rb +45 -0
  32. data/lib/fog/ecloud/models/compute/backup_internet_services.rb +41 -0
  33. data/lib/fog/ecloud/models/compute/catalog.rb +39 -0
  34. data/lib/fog/ecloud/models/compute/catalog_configuration.rb +22 -0
  35. data/lib/fog/ecloud/models/compute/catalog_configurations.rb +26 -0
  36. data/lib/fog/ecloud/models/compute/catalog_item.rb +24 -0
  37. data/lib/fog/ecloud/models/compute/compute_pool.rb +70 -0
  38. data/lib/fog/ecloud/models/compute/compute_pools.rb +33 -0
  39. data/lib/fog/ecloud/models/compute/cpu_usage_detail.rb +16 -0
  40. data/lib/fog/ecloud/models/compute/cpu_usage_detail_summary.rb +26 -0
  41. data/lib/fog/ecloud/models/compute/detached_disk.rb +27 -0
  42. data/lib/fog/ecloud/models/compute/detached_disks.rb +26 -0
  43. data/lib/fog/ecloud/models/compute/environment.rb +111 -0
  44. data/lib/fog/ecloud/models/compute/environments.rb +39 -0
  45. data/lib/fog/ecloud/models/compute/firewall_acl.rb +27 -0
  46. data/lib/fog/ecloud/models/compute/firewall_acls.rb +27 -0
  47. data/lib/fog/ecloud/models/compute/group.rb +41 -0
  48. data/lib/fog/ecloud/models/compute/groups.rb +38 -0
  49. data/lib/fog/ecloud/models/compute/guest_process.rb +15 -0
  50. data/lib/fog/ecloud/models/compute/guest_processes.rb +26 -0
  51. data/lib/fog/ecloud/models/compute/hardware_configuration.rb +18 -0
  52. data/lib/fog/ecloud/models/compute/hardware_configurations.rb +26 -0
  53. data/lib/fog/ecloud/models/compute/internet_service.rb +97 -0
  54. data/lib/fog/ecloud/models/compute/internet_services.rb +44 -0
  55. data/lib/fog/ecloud/models/compute/ip_address.rb +39 -0
  56. data/lib/fog/ecloud/models/compute/ip_addresses.rb +32 -0
  57. data/lib/fog/ecloud/models/compute/layout.rb +20 -0
  58. data/lib/fog/ecloud/models/compute/layouts.rb +26 -0
  59. data/lib/fog/ecloud/models/compute/location.rb +22 -0
  60. data/lib/fog/ecloud/models/compute/locations.rb +28 -0
  61. data/lib/fog/ecloud/models/compute/login_banner.rb +16 -0
  62. data/lib/fog/ecloud/models/compute/login_banners.rb +26 -0
  63. data/lib/fog/ecloud/models/compute/memory_usage_detail.rb +16 -0
  64. data/lib/fog/ecloud/models/compute/memory_usage_detail_summary.rb +26 -0
  65. data/lib/fog/ecloud/models/compute/monitor.rb +46 -0
  66. data/lib/fog/ecloud/models/compute/monitors.rb +30 -0
  67. data/lib/fog/ecloud/models/compute/network.rb +46 -0
  68. data/lib/fog/ecloud/models/compute/networks.rb +32 -0
  69. data/lib/fog/ecloud/models/compute/node.rb +45 -0
  70. data/lib/fog/ecloud/models/compute/nodes.rb +42 -0
  71. data/lib/fog/ecloud/models/compute/operating_system.rb +16 -0
  72. data/lib/fog/ecloud/models/compute/operating_system_families.rb +26 -0
  73. data/lib/fog/ecloud/models/compute/operating_system_family.rb +21 -0
  74. data/lib/fog/ecloud/models/compute/operating_systems.rb +25 -0
  75. data/lib/fog/ecloud/models/compute/organization.rb +78 -0
  76. data/lib/fog/ecloud/models/compute/organizations.rb +38 -0
  77. data/lib/fog/ecloud/models/compute/password_complexity_rule.rb +49 -0
  78. data/lib/fog/ecloud/models/compute/password_complexity_rules.rb +26 -0
  79. data/lib/fog/ecloud/models/compute/physical_device.rb +21 -0
  80. data/lib/fog/ecloud/models/compute/physical_devices.rb +26 -0
  81. data/lib/fog/ecloud/models/compute/public_ip.rb +26 -0
  82. data/lib/fog/ecloud/models/compute/public_ips.rb +31 -0
  83. data/lib/fog/ecloud/models/compute/rnat.rb +27 -0
  84. data/lib/fog/ecloud/models/compute/rnats.rb +26 -0
  85. data/lib/fog/ecloud/models/compute/role.rb +23 -0
  86. data/lib/fog/ecloud/models/compute/roles.rb +36 -0
  87. data/lib/fog/ecloud/models/compute/row.rb +56 -0
  88. data/lib/fog/ecloud/models/compute/rows.rb +39 -0
  89. data/lib/fog/ecloud/models/compute/server.rb +323 -0
  90. data/lib/fog/ecloud/models/compute/server_configuration_option.rb +16 -0
  91. data/lib/fog/ecloud/models/compute/server_configuration_options.rb +26 -0
  92. data/lib/fog/ecloud/models/compute/servers.rb +65 -0
  93. data/lib/fog/ecloud/models/compute/ssh_key.rb +19 -0
  94. data/lib/fog/ecloud/models/compute/ssh_keys.rb +26 -0
  95. data/lib/fog/ecloud/models/compute/storage_usage_detail.rb +16 -0
  96. data/lib/fog/ecloud/models/compute/storage_usage_detail_summary.rb +26 -0
  97. data/lib/fog/ecloud/models/compute/support_ticket.rb +28 -0
  98. data/lib/fog/ecloud/models/compute/support_tickets.rb +26 -0
  99. data/lib/fog/ecloud/models/compute/tag.rb +13 -0
  100. data/lib/fog/ecloud/models/compute/tags.rb +26 -0
  101. data/lib/fog/ecloud/models/compute/task.rb +23 -0
  102. data/lib/fog/ecloud/models/compute/tasks.rb +29 -0
  103. data/lib/fog/ecloud/models/compute/template.rb +23 -0
  104. data/lib/fog/ecloud/models/compute/templates.rb +41 -0
  105. data/lib/fog/ecloud/models/compute/trusted_network_group.rb +33 -0
  106. data/lib/fog/ecloud/models/compute/trusted_network_groups.rb +27 -0
  107. data/lib/fog/ecloud/models/compute/user.rb +35 -0
  108. data/lib/fog/ecloud/models/compute/users.rb +26 -0
  109. data/lib/fog/ecloud/models/compute/virtual_machine_assigned_ip.rb +32 -0
  110. data/lib/fog/ecloud/models/compute/virtual_machine_assigned_ips.rb +26 -0
  111. data/lib/fog/ecloud/requests/compute/admin_disable_support_access.rb +9 -0
  112. data/lib/fog/ecloud/requests/compute/admin_edit_authentication_levels.rb +32 -0
  113. data/lib/fog/ecloud/requests/compute/admin_edit_login_banner.rb +30 -0
  114. data/lib/fog/ecloud/requests/compute/admin_edit_password_complexity_rules.rb +72 -0
  115. data/lib/fog/ecloud/requests/compute/admin_enable_support_access.rb +9 -0
  116. data/lib/fog/ecloud/requests/compute/backup_internet_service_create.rb +47 -0
  117. data/lib/fog/ecloud/requests/compute/backup_internet_service_delete.rb +9 -0
  118. data/lib/fog/ecloud/requests/compute/backup_internet_service_edit.rb +47 -0
  119. data/lib/fog/ecloud/requests/compute/compute_pool_edit.rb +35 -0
  120. data/lib/fog/ecloud/requests/compute/firewall_acls_create.rb +78 -0
  121. data/lib/fog/ecloud/requests/compute/firewall_acls_delete.rb +9 -0
  122. data/lib/fog/ecloud/requests/compute/get_admin_organization.rb +23 -0
  123. data/lib/fog/ecloud/requests/compute/get_api_key.rb +9 -0
  124. data/lib/fog/ecloud/requests/compute/get_api_keys.rb +9 -0
  125. data/lib/fog/ecloud/requests/compute/get_association.rb +9 -0
  126. data/lib/fog/ecloud/requests/compute/get_associations.rb +9 -0
  127. data/lib/fog/ecloud/requests/compute/get_authentication_level.rb +9 -0
  128. data/lib/fog/ecloud/requests/compute/get_authentication_levels.rb +9 -0
  129. data/lib/fog/ecloud/requests/compute/get_backup_internet_service.rb +9 -0
  130. data/lib/fog/ecloud/requests/compute/get_backup_internet_services.rb +9 -0
  131. data/lib/fog/ecloud/requests/compute/get_catalog.rb +9 -0
  132. data/lib/fog/ecloud/requests/compute/get_catalog_configuration.rb +9 -0
  133. data/lib/fog/ecloud/requests/compute/get_catalog_configurations.rb +9 -0
  134. data/lib/fog/ecloud/requests/compute/get_catalog_item.rb +9 -0
  135. data/lib/fog/ecloud/requests/compute/get_compute_pool.rb +21 -0
  136. data/lib/fog/ecloud/requests/compute/get_compute_pools.rb +31 -0
  137. data/lib/fog/ecloud/requests/compute/get_cpu_usage_detail.rb +9 -0
  138. data/lib/fog/ecloud/requests/compute/get_cpu_usage_detail_summary.rb +9 -0
  139. data/lib/fog/ecloud/requests/compute/get_detached_disk.rb +21 -0
  140. data/lib/fog/ecloud/requests/compute/get_detached_disks.rb +31 -0
  141. data/lib/fog/ecloud/requests/compute/get_environment.rb +31 -0
  142. data/lib/fog/ecloud/requests/compute/get_environments.rb +0 -0
  143. data/lib/fog/ecloud/requests/compute/get_firewall_acl.rb +9 -0
  144. data/lib/fog/ecloud/requests/compute/get_firewall_acls.rb +9 -0
  145. data/lib/fog/ecloud/requests/compute/get_group.rb +18 -0
  146. data/lib/fog/ecloud/requests/compute/get_groups.rb +18 -0
  147. data/lib/fog/ecloud/requests/compute/get_guest_process.rb +9 -0
  148. data/lib/fog/ecloud/requests/compute/get_guest_processes.rb +9 -0
  149. data/lib/fog/ecloud/requests/compute/get_hardware_configuration.rb +29 -0
  150. data/lib/fog/ecloud/requests/compute/get_hardware_configurations.rb +14 -0
  151. data/lib/fog/ecloud/requests/compute/get_internet_service.rb +21 -0
  152. data/lib/fog/ecloud/requests/compute/get_internet_services.rb +18 -0
  153. data/lib/fog/ecloud/requests/compute/get_ip_address.rb +20 -0
  154. data/lib/fog/ecloud/requests/compute/get_layout.rb +18 -0
  155. data/lib/fog/ecloud/requests/compute/get_layouts.rb +18 -0
  156. data/lib/fog/ecloud/requests/compute/get_location.rb +9 -0
  157. data/lib/fog/ecloud/requests/compute/get_locations.rb +9 -0
  158. data/lib/fog/ecloud/requests/compute/get_login_banner.rb +9 -0
  159. data/lib/fog/ecloud/requests/compute/get_login_banners.rb +9 -0
  160. data/lib/fog/ecloud/requests/compute/get_memory_usage_detail.rb +9 -0
  161. data/lib/fog/ecloud/requests/compute/get_memory_usage_detail_summary.rb +9 -0
  162. data/lib/fog/ecloud/requests/compute/get_monitor.rb +9 -0
  163. data/lib/fog/ecloud/requests/compute/get_monitors.rb +9 -0
  164. data/lib/fog/ecloud/requests/compute/get_network.rb +21 -0
  165. data/lib/fog/ecloud/requests/compute/get_network_summary.rb +9 -0
  166. data/lib/fog/ecloud/requests/compute/get_networks.rb +30 -0
  167. data/lib/fog/ecloud/requests/compute/get_node.rb +21 -0
  168. data/lib/fog/ecloud/requests/compute/get_nodes.rb +18 -0
  169. data/lib/fog/ecloud/requests/compute/get_operating_system.rb +24 -0
  170. data/lib/fog/ecloud/requests/compute/get_operating_system_families.rb +30 -0
  171. data/lib/fog/ecloud/requests/compute/get_organization.rb +24 -0
  172. data/lib/fog/ecloud/requests/compute/get_organizations.rb +23 -0
  173. data/lib/fog/ecloud/requests/compute/get_password_complexity_rule.rb +9 -0
  174. data/lib/fog/ecloud/requests/compute/get_password_complexity_rules.rb +9 -0
  175. data/lib/fog/ecloud/requests/compute/get_physical_device.rb +9 -0
  176. data/lib/fog/ecloud/requests/compute/get_physical_devices.rb +9 -0
  177. data/lib/fog/ecloud/requests/compute/get_process.rb +9 -0
  178. data/lib/fog/ecloud/requests/compute/get_processes.rb +9 -0
  179. data/lib/fog/ecloud/requests/compute/get_public_ip.rb +21 -0
  180. data/lib/fog/ecloud/requests/compute/get_public_ips.rb +31 -0
  181. data/lib/fog/ecloud/requests/compute/get_rnat.rb +9 -0
  182. data/lib/fog/ecloud/requests/compute/get_rnats.rb +9 -0
  183. data/lib/fog/ecloud/requests/compute/get_role.rb +9 -0
  184. data/lib/fog/ecloud/requests/compute/get_roles.rb +9 -0
  185. data/lib/fog/ecloud/requests/compute/get_row.rb +18 -0
  186. data/lib/fog/ecloud/requests/compute/get_rows.rb +12 -0
  187. data/lib/fog/ecloud/requests/compute/get_server.rb +21 -0
  188. data/lib/fog/ecloud/requests/compute/get_server_configuration_option.rb +9 -0
  189. data/lib/fog/ecloud/requests/compute/get_server_configuration_options.rb +9 -0
  190. data/lib/fog/ecloud/requests/compute/get_servers.rb +42 -0
  191. data/lib/fog/ecloud/requests/compute/get_ssh_key.rb +21 -0
  192. data/lib/fog/ecloud/requests/compute/get_ssh_keys.rb +30 -0
  193. data/lib/fog/ecloud/requests/compute/get_storage_usage_detail.rb +9 -0
  194. data/lib/fog/ecloud/requests/compute/get_storage_usage_detail_summary.rb +9 -0
  195. data/lib/fog/ecloud/requests/compute/get_support_ticket.rb +9 -0
  196. data/lib/fog/ecloud/requests/compute/get_support_tickets.rb +9 -0
  197. data/lib/fog/ecloud/requests/compute/get_tag.rb +9 -0
  198. data/lib/fog/ecloud/requests/compute/get_tags.rb +9 -0
  199. data/lib/fog/ecloud/requests/compute/get_task.rb +13 -0
  200. data/lib/fog/ecloud/requests/compute/get_tasks.rb +9 -0
  201. data/lib/fog/ecloud/requests/compute/get_template.rb +21 -0
  202. data/lib/fog/ecloud/requests/compute/get_templates.rb +48 -0
  203. data/lib/fog/ecloud/requests/compute/get_trusted_network_group.rb +9 -0
  204. data/lib/fog/ecloud/requests/compute/get_trusted_network_groups.rb +9 -0
  205. data/lib/fog/ecloud/requests/compute/get_user.rb +9 -0
  206. data/lib/fog/ecloud/requests/compute/get_users.rb +9 -0
  207. data/lib/fog/ecloud/requests/compute/get_virtual_machine_assigned_ips.rb +42 -0
  208. data/lib/fog/ecloud/requests/compute/groups_create.rb +31 -0
  209. data/lib/fog/ecloud/requests/compute/groups_delete.rb +26 -0
  210. data/lib/fog/ecloud/requests/compute/groups_edit.rb +29 -0
  211. data/lib/fog/ecloud/requests/compute/groups_movedown.rb +9 -0
  212. data/lib/fog/ecloud/requests/compute/groups_moveup.rb +9 -0
  213. data/lib/fog/ecloud/requests/compute/internet_service_create.rb +102 -0
  214. data/lib/fog/ecloud/requests/compute/internet_service_delete.rb +33 -0
  215. data/lib/fog/ecloud/requests/compute/internet_service_edit.rb +58 -0
  216. data/lib/fog/ecloud/requests/compute/monitors_create_default.rb +9 -0
  217. data/lib/fog/ecloud/requests/compute/monitors_create_ecv.rb +40 -0
  218. data/lib/fog/ecloud/requests/compute/monitors_create_http.rb +44 -0
  219. data/lib/fog/ecloud/requests/compute/monitors_create_loopback.rb +9 -0
  220. data/lib/fog/ecloud/requests/compute/monitors_create_ping.rb +35 -0
  221. data/lib/fog/ecloud/requests/compute/monitors_disable.rb +9 -0
  222. data/lib/fog/ecloud/requests/compute/monitors_edit_ecv.rb +40 -0
  223. data/lib/fog/ecloud/requests/compute/monitors_edit_http.rb +44 -0
  224. data/lib/fog/ecloud/requests/compute/monitors_edit_ping.rb +35 -0
  225. data/lib/fog/ecloud/requests/compute/monitors_enable.rb +9 -0
  226. data/lib/fog/ecloud/requests/compute/node_service_create.rb +93 -0
  227. data/lib/fog/ecloud/requests/compute/node_service_delete.rb +33 -0
  228. data/lib/fog/ecloud/requests/compute/node_service_edit.rb +39 -0
  229. data/lib/fog/ecloud/requests/compute/power_off.rb +9 -0
  230. data/lib/fog/ecloud/requests/compute/power_on.rb +9 -0
  231. data/lib/fog/ecloud/requests/compute/power_reset.rb +9 -0
  232. data/lib/fog/ecloud/requests/compute/power_shutdown.rb +9 -0
  233. data/lib/fog/ecloud/requests/compute/public_ip_activate.rb +9 -0
  234. data/lib/fog/ecloud/requests/compute/rnat_associations_create_device.rb +32 -0
  235. data/lib/fog/ecloud/requests/compute/rnat_associations_delete.rb +9 -0
  236. data/lib/fog/ecloud/requests/compute/rnat_associations_edit_network.rb +31 -0
  237. data/lib/fog/ecloud/requests/compute/rows_create.rb +29 -0
  238. data/lib/fog/ecloud/requests/compute/rows_delete.rb +21 -0
  239. data/lib/fog/ecloud/requests/compute/rows_edit.rb +29 -0
  240. data/lib/fog/ecloud/requests/compute/rows_movedown.rb +9 -0
  241. data/lib/fog/ecloud/requests/compute/rows_moveup.rb +9 -0
  242. data/lib/fog/ecloud/requests/compute/trusted_network_groups_create.rb +51 -0
  243. data/lib/fog/ecloud/requests/compute/trusted_network_groups_delete.rb +9 -0
  244. data/lib/fog/ecloud/requests/compute/trusted_network_groups_edit.rb +51 -0
  245. data/lib/fog/ecloud/requests/compute/virtual_machine_attach_disk.rb +61 -0
  246. data/lib/fog/ecloud/requests/compute/virtual_machine_copy.rb +116 -0
  247. data/lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb +43 -0
  248. data/lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb +244 -0
  249. data/lib/fog/ecloud/requests/compute/virtual_machine_delete.rb +46 -0
  250. data/lib/fog/ecloud/requests/compute/virtual_machine_detach_disk.rb +70 -0
  251. data/lib/fog/ecloud/requests/compute/virtual_machine_edit.rb +45 -0
  252. data/lib/fog/ecloud/requests/compute/virtual_machine_edit_assigned_ips.rb +80 -0
  253. data/lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb +75 -0
  254. data/lib/fog/ecloud/requests/compute/virtual_machine_import.rb +179 -0
  255. data/lib/fog/ecloud/requests/compute/virtual_machine_upload_file.rb +28 -0
  256. data/lib/fog/ecloud/version.rb +5 -0
  257. data/lib/fog/ecloud.rb +8 -0
  258. data/spec/minitest_helper.rb +31 -0
  259. data/tests/compute/helper.rb +27 -0
  260. data/tests/compute/models/admin_organization_tests.rb +16 -0
  261. data/tests/compute/models/compute_pool_tests.rb +17 -0
  262. data/tests/compute/models/detached_disk_tests.rb +26 -0
  263. data/tests/compute/models/environment_tests.rb +23 -0
  264. data/tests/compute/models/internet_service_tests.rb +28 -0
  265. data/tests/compute/models/ip_address_tests.rb +19 -0
  266. data/tests/compute/models/network_tests.rb +17 -0
  267. data/tests/compute/models/operating_system_families_tests.rb +13 -0
  268. data/tests/compute/models/operating_system_tests.rb +22 -0
  269. data/tests/compute/models/organization_tests.rb +21 -0
  270. data/tests/compute/models/public_ip_tests.rb +19 -0
  271. data/tests/compute/models/server_tests.rb +25 -0
  272. data/tests/compute/models/ssh_key_tests.rb +19 -0
  273. data/tests/compute/models/template_tests.rb +20 -0
  274. data/tests/helper.rb +24 -0
  275. data/tests/helpers/collection_helper.rb +97 -0
  276. data/tests/helpers/compute/flavors_helper.rb +32 -0
  277. data/tests/helpers/compute/server_helper.rb +25 -0
  278. data/tests/helpers/compute/servers_helper.rb +10 -0
  279. data/tests/helpers/formats_helper.rb +98 -0
  280. data/tests/helpers/formats_helper_tests.rb +110 -0
  281. data/tests/helpers/mock_helper.rb +115 -0
  282. data/tests/helpers/model_helper.rb +31 -0
  283. data/tests/helpers/responds_to_helper.rb +11 -0
  284. data/tests/helpers/schema_validator_tests.rb +107 -0
  285. data/tests/helpers/succeeds_helper.rb +9 -0
  286. metadata +457 -0
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ class Real
5
+ basic_request :rows_delete, 204, 'DELETE'
6
+ end
7
+
8
+ class Mock
9
+ def rows_delete(uri)
10
+ row_id = id_from_uri(uri)
11
+ self.data[:rows].delete(row_id)
12
+ self.data[:layouts].values.each do |layout|
13
+ layout[:Rows][:Row].delete_if { |r| r[:id] == row_id }
14
+ end
15
+
16
+ response(:body => nil, :status => 204)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ class Real
5
+ include Shared
6
+
7
+ def rows_edit(data)
8
+ validate_data([:name], data)
9
+
10
+ request(
11
+ :body => generate_rows_edit_request(data),
12
+ :expects => 204,
13
+ :method => "PUT",
14
+ :headers => {},
15
+ :uri => data[:uri],
16
+ :parse => false
17
+ )
18
+ end
19
+
20
+ private
21
+
22
+ def generate_rows_edit_request(data)
23
+ xml = Builder::XmlMarkup.new
24
+ xml.LayoutRow(:name => data[:name])
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ class Real
5
+ basic_request :rows_movedown, 204, 'POST'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ class Real
5
+ basic_request :rows_moveup, 204, 'POST'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ class Real
5
+ include Shared
6
+
7
+ def trusted_network_groups_create(data)
8
+ validate_data([:name], data)
9
+ unless (data[:hosts] || data[:networks])
10
+ raise ArgumentError.new("Required data missing: Either hosts or networks must be present")
11
+ end
12
+
13
+ request(
14
+ :body => generate_create_trusted_network_groups_request(data),
15
+ :expects => 201,
16
+ :method => "POST",
17
+ :headers => {},
18
+ :uri => data[:uri],
19
+ :parse => true
20
+ )
21
+ end
22
+
23
+ private
24
+
25
+ def generate_create_trusted_network_groups_request(data)
26
+ xml = Builder::XmlMarkup.new
27
+ xml.CreateTrustedNetworkGroup(:name => data[:name]) do
28
+ if data[:hosts]
29
+ xml.Hosts do
30
+ data[:hosts].each do |ip|
31
+ xml.IpAddress ip
32
+ end
33
+ end
34
+ end
35
+ if data[:networks]
36
+ xml.Networks do
37
+ data[:networks].each do |network|
38
+ address, subnet = network.split('/')
39
+ xml.Network do
40
+ xml.Address address
41
+ xml.Size subnet
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,9 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ class Real
5
+ basic_request :trusted_network_groups_delete, 202, 'DELETE'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ class Real
5
+ include Shared
6
+
7
+ def trusted_network_groups_edit(data)
8
+ validate_data([:name], data)
9
+ unless (data[:hosts] || data[:networks])
10
+ raise ArgumentError.new("Required data missing: Either hosts or networks must be present")
11
+ end
12
+
13
+ request(
14
+ :body => generate_edit_trusted_network_groups_request(data),
15
+ :expects => 202,
16
+ :method => "PUT",
17
+ :headers => {},
18
+ :uri => data[:uri],
19
+ :parse => true
20
+ )
21
+ end
22
+
23
+ private
24
+
25
+ def generate_edit_trusted_network_groups_request(data)
26
+ xml = Builder::XmlMarkup.new
27
+ xml.TrustedNetworkGroup(:name => data[:name]) do
28
+ if data[:hosts]
29
+ xml.Hosts do
30
+ data[:hosts].each do |ip|
31
+ xml.IpAddress ip
32
+ end
33
+ end
34
+ end
35
+ if data[:networks]
36
+ xml.Networks do
37
+ data[:networks].each do |network|
38
+ address, subnet = network.split('/')
39
+ xml.Network do
40
+ xml.Address address
41
+ xml.Size subnet
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,61 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ module Shared
5
+ def build_request_body_attach_disk(options)
6
+ xml = Builder::XmlMarkup.new
7
+ xml.AttachDisks(:name => options[:name]) do
8
+ xml.DetachedDisks do
9
+ xml.DetachedDisk(:href => options[:href], :name => options[:name], :type => "application/vnd.tmrk.cloud.detachedDisk")
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ class Real
16
+ def virtual_machine_attach_disk(href, options)
17
+ body = build_request_body_attach_disk(options)
18
+ request(
19
+ :expects => 202,
20
+ :method => 'POST',
21
+ :headers => {},
22
+ :body => body,
23
+ :uri => href,
24
+ :parse => true
25
+ )
26
+ end
27
+ end
28
+
29
+ class Mock
30
+ def virtual_machine_attach_disk(href, options)
31
+ server_id = href.match(/(\d+)/)[1].to_i
32
+ server = self.data[:servers][server_id]
33
+ compute_pool_id = server[:compute_pool_id]
34
+ compute_pool = self.data[:compute_pools][compute_pool_id]
35
+ detached_disk_id = options[:href].match(/(\d+)/)[1].to_i
36
+ detached_disk = self.data[:detached_disks][detached_disk_id]
37
+ new_index = (server[:HardwareConfiguration][:Disks][:Disk].map { |h| h[:Index].to_i }.sort.last + 1).to_s
38
+ detached_disk[:Index] = new_index
39
+ server[:HardwareConfiguration][:Disks][:Disk] << Fog::Ecloud.keep(detached_disk, :Index, :Size, :Name)
40
+
41
+ self.data[:detached_disks].delete(detached_disk_id)
42
+
43
+ task_id = Fog::Mock.random_numbers(10).to_i
44
+ task = {
45
+ :id => task_id,
46
+ :href => "/cloudapi/ecloud/tasks/#{task_id}",
47
+ :type => "application/vnd.tmrk.cloud.task",
48
+ :Operation => "Attach Disk",
49
+ :Status => "Complete",
50
+ :ImpactedItem => Fog::Ecloud.keep(server, :href, :type),
51
+ :StartTime => Time.now.iso8601,
52
+ :CompletedTime => Time.now.iso8601,
53
+ :InitiatedBy => {},
54
+ }
55
+ self.data[:tasks][task_id] = task
56
+ response(:body => task)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,116 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ module Shared
5
+ def validate_create_server_options_copy(template_uri, options)
6
+ required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri, :source]
7
+ if options[:customization] == :windows
8
+ required_opts.push(:windows_password)
9
+ else
10
+ required_opts.push(:ssh_key_uri)
11
+ end
12
+ unless required_opts.all? { |opt| options.key?(opt) }
13
+ raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
14
+ end
15
+
16
+ options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
17
+ options[:network_uri].map! do |uri|
18
+ network = get_network(uri).body
19
+ if options[:ips]
20
+ ip = options[:ips][options[:network_uri].index(uri)]
21
+ end
22
+ {:href => uri, :name => network[:name], :ip => ip}
23
+ end
24
+ options
25
+ end
26
+
27
+ def build_request_body_copy(options)
28
+ xml = Builder::XmlMarkup.new
29
+ xml.CopyVirtualMachine(:name => options[:name]) do
30
+ xml.Source(:href => options[:source], :type => "application/vnd.tmrk.cloud.virtualMachine")
31
+ xml.ProcessorCount options[:cpus]
32
+ xml.Memory do
33
+ xml.Unit "MB"
34
+ xml.Value options[:memory]
35
+ end
36
+ xml.Layout do
37
+ xml.NewRow options[:row]
38
+ xml.NewGroup options[:group]
39
+ end
40
+ if options[:customization] == :windows
41
+ xml.WindowsCustomization do
42
+ xml.NetworkSettings do
43
+ xml.NetworkAdapterSettings do
44
+ options[:network_uri].each do |uri|
45
+ xml.NetworkAdapter do
46
+ xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network")
47
+ xml.IpAddress uri[:ip]
48
+ end
49
+ end
50
+ end
51
+ if options[:dns_settings]
52
+ xml.DnsSettings do
53
+ xml.PrimaryDns options[:dns_settings][:primary_dns]
54
+ if options[:dns_settings][:secondary_dns]
55
+ xml.SecondaryDns options[:dns_settings][:secondary_dns]
56
+ end
57
+ end
58
+ end
59
+ end
60
+ xml.Password options[:windows_password]
61
+ if options[:windows_license_key]
62
+ xml.LicenseKey options[:windows_license_key]
63
+ end
64
+ end
65
+ else
66
+ xml.LinuxCustomization do
67
+ xml.NetworkSettings do
68
+ xml.NetworkAdapterSettings do
69
+ options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
70
+ options[:network_uri].each do |uri|
71
+ xml.NetworkAdapter do
72
+ xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network")
73
+ xml.IpAddress uri[:ip]
74
+ end
75
+ end
76
+ end
77
+ if options[:dns_settings]
78
+ xml.DnsSettings do
79
+ xml.PrimaryDns options[:dns_settings][:primary_dns]
80
+ if options[:dns_settings][:secondary_dns]
81
+ xml.SecondaryDns options[:dns_settings][:secondary_dns]
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ xml.SshKey(:href => options[:ssh_key_uri])
88
+ end
89
+ xml.Description options[:description]
90
+ xml.Tags do
91
+ options[:tags].each do |tag|
92
+ xml.Tag tag
93
+ end
94
+ end
95
+ xml.PoweredOn options[:powered_on]
96
+ end
97
+ end
98
+ end
99
+
100
+ class Real
101
+ def virtual_machine_copy(template_uri, options)
102
+ options = validate_create_server_options_copy(template_uri, options)
103
+ body = build_request_body_copy(options)
104
+ request(
105
+ :expects => 201,
106
+ :method => 'POST',
107
+ :headers => {},
108
+ :body => body,
109
+ :uri => template_uri,
110
+ :parse => true
111
+ )
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ module Shared
5
+ def validate_create_server_options_identical(template_uri, options)
6
+ required_opts = [:name, :row, :group, :source]
7
+ unless required_opts.all? { |opt| options.key?(opt) }
8
+ raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
9
+ end
10
+
11
+ options
12
+ end
13
+
14
+ def build_request_body_identical(options)
15
+ xml = Builder::XmlMarkup.new
16
+ xml.CopyIdenticalVirtualMachine(:name => options[:name]) do
17
+ xml.Source(:href => options[:source], :type => "application/vnd.tmrk.cloud.virtualMachine")
18
+ xml.Layout do
19
+ xml.NewRow options[:row]
20
+ xml.NewGroup options[:group]
21
+ end
22
+ xml.Description options[:description]
23
+ end
24
+ end
25
+ end
26
+
27
+ class Real
28
+ def virtual_machine_copy_identical(template_uri, options)
29
+ options = validate_create_server_options_identical(template_uri, options)
30
+ body = build_request_body_identical(options)
31
+ request(
32
+ :expects => 201,
33
+ :method => 'POST',
34
+ :headers => {},
35
+ :body => body,
36
+ :uri => template_uri,
37
+ :parse => true
38
+ )
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,244 @@
1
+ module Fog
2
+ module Compute
3
+ class Ecloud
4
+ module Shared
5
+ def validate_create_server_options(template_uri, options)
6
+ required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri]
7
+ if options[:customization] == :windows
8
+ required_opts.push(:windows_password)
9
+ else
10
+ required_opts.push(:ssh_key_uri)
11
+ end
12
+ unless required_opts.all? { |opt| options.key?(opt) }
13
+ raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
14
+ end
15
+
16
+ options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
17
+ options[:network_uri].map! do |uri|
18
+ network = get_network(uri).body
19
+ if options[:ips]
20
+ ip = options[:ips][options[:network_uri].index(uri)]
21
+ end
22
+ {:href => uri, :name => network[:name], :ip => ip}
23
+ end
24
+ options[:template_uri] = template_uri
25
+ options
26
+ end
27
+
28
+ def build_request_body(options)
29
+ xml = Builder::XmlMarkup.new
30
+ xml.CreateVirtualMachine(:name => options[:name]) do
31
+ xml.ProcessorCount options[:cpus]
32
+ xml.Memory do
33
+ xml.Unit "MB"
34
+ xml.Value options[:memory]
35
+ end
36
+ xml.Layout do
37
+ xml.NewRow options[:row]
38
+ xml.NewGroup options[:group]
39
+ end
40
+ xml.Description options[:description]
41
+ xml.Tags do
42
+ options[:tags].each do |tag|
43
+ xml.Tag tag
44
+ end
45
+ end
46
+ if options[:customization] == :windows
47
+ xml.WindowsCustomization do
48
+ xml.NetworkSettings do
49
+ xml.NetworkAdapterSettings do
50
+ options[:network_uri].each do |uri|
51
+ xml.NetworkAdapter do
52
+ xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network")
53
+ xml.IpAddress uri[:ip]
54
+ end
55
+ end
56
+ end
57
+ if options[:dns_settings]
58
+ xml.DnsSettings do
59
+ xml.PrimaryDns options[:dns_settings][:primary_dns]
60
+ if options[:dns_settings][:secondary_dns]
61
+ xml.SecondaryDns options[:dns_settings][:secondary_dns]
62
+ end
63
+ end
64
+ end
65
+ end
66
+ xml.Password options[:windows_password]
67
+ if options[:windows_license_key]
68
+ xml.LicenseKey options[:windows_license_key]
69
+ end
70
+ end
71
+ else
72
+ xml.LinuxCustomization do
73
+ xml.NetworkSettings do
74
+ xml.NetworkAdapterSettings do
75
+ options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
76
+ options[:network_uri].each do |uri|
77
+ xml.NetworkAdapter do
78
+ xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network")
79
+ xml.IpAddress uri[:ip]
80
+ end
81
+ end
82
+ end
83
+ if options[:dns_settings]
84
+ xml.DnsSettings do
85
+ xml.PrimaryDns options[:dns_settings][:primary_dns]
86
+ if options[:dns_settings][:secondary_dns]
87
+ xml.SecondaryDns options[:dns_settings][:secondary_dns]
88
+ end
89
+ end
90
+ end
91
+ end
92
+ xml.SshKey(:href => options[:ssh_key_uri])
93
+ end
94
+ end
95
+ xml.PoweredOn options[:powered_on]
96
+ xml.Template(:href => options[:template_uri], :type => options[:template_type])
97
+ end
98
+ end
99
+ end
100
+
101
+ class Real
102
+ def virtual_machine_create_from_template(template_uri, options)
103
+ options = validate_create_server_options(template_uri, options)
104
+
105
+ request(
106
+ :expects => 201,
107
+ :method => 'POST',
108
+ :body => build_request_body(options),
109
+ :uri => options[:uri],
110
+ :parse => true
111
+ )
112
+ end
113
+ end
114
+
115
+ class Mock
116
+ def virtual_machine_create_from_template(template_uri, options)
117
+ options = validate_create_server_options(template_uri, options)
118
+ server_id = Fog::Mock.random_numbers(7).to_i
119
+ row_id = Fog::Mock.random_numbers(6).to_i
120
+ group_id = Fog::Mock.random_numbers(6).to_i
121
+ template_id, compute_pool_id = template_uri.match(/\/templates\/(\d+)\/computepools\/(\d+)$/).captures
122
+ compute_pool = self.data[:compute_pools][compute_pool_id.to_i].dup
123
+ environment = self.data[:environments][compute_pool[:environment_id]]
124
+ layout = self.data[:layouts][environment[:id]]
125
+ networks = options[:network_uri]
126
+ nics = networks.each_with_index.map do |network, i|
127
+ {
128
+ :UnitNumber => i.to_s,
129
+ :Name => "Network adapter #{i}",
130
+ :MacAddress => Fog::Ecloud.mac_address,
131
+ :Network => Fog::Ecloud.keep(network, :name, :href, :type),
132
+ }
133
+ end
134
+
135
+ links = [Fog::Ecloud.keep(compute_pool, :name, :href, :type), Fog::Ecloud.keep(environment, :name, :href, :type)]
136
+ networks.each do |network|
137
+ links << Fog::Ecloud.keep(network, :name, :href, :type)
138
+ network_id = id_from_uri(network[:href])
139
+ ip = self.data[:networks][network_id][:IpAddresses][:IpAddress].find { |ip| ip[:id] = network[:ip] }
140
+ ip[:DetectedOn] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"}
141
+ ip[:Host] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"}
142
+ end
143
+
144
+ server = {
145
+ :href => "/cloudapi/ecloud/virtualmachines/#{server_id}",
146
+ :name => options[:name],
147
+ :type => "application/vnd.tmrk.cloud.virtualMachine",
148
+ :Description => options[:description],
149
+ :Status => "Deployed",
150
+ :HardwareConfiguration => {
151
+ :href => "/cloudapi/ecloud/virtualmachines/#{server_id}/hardwareconfiguration",
152
+ :type => "application/vnd.tmrk.cloud.virtualMachineHardware",
153
+ :Links => {
154
+ :Link => {
155
+ :href => "/cloudapi/ecloud/virtualmachines/#{server_id}",
156
+ :name => options[:name],
157
+ :type => "application/vnd.tmrk.cloud.virtualMachine",
158
+ :rel => "up",
159
+ }
160
+ },
161
+ :ProcessorCount => options[:cpus],
162
+ :Memory => {
163
+ :Unit => "MB",
164
+ :Value => options[:memory],
165
+ },
166
+ :Disks => {
167
+ :Disk => [{
168
+ :Index => "0",
169
+ :Name => "Hard Disk 1",
170
+ :Size => {
171
+ :Unit => "GB",
172
+ :Value => "25",
173
+ },
174
+ }],
175
+ },
176
+ :Nics => {
177
+ :Nic => nics,
178
+ },
179
+ },
180
+ :IpAddresses => {
181
+ :AssignedIpAddresses => {
182
+ :Networks => {
183
+ :Network => self.data[:networks].dup.values,
184
+ }
185
+ }
186
+ },
187
+ :Links => { :Link => links },
188
+ }
189
+
190
+ row = {
191
+ :id => row_id,
192
+ :name => options[:row],
193
+ :href => "/cloudapi/ecloud/layoutrows/#{row_id}",
194
+ :type => "application/vnd.tmrk.cloud.layoutRow",
195
+ :Links => {
196
+ :Link => [
197
+ Fog::Ecloud.keep(environment, :name, :href, :type)
198
+ ],
199
+ },
200
+ :Index => 0,
201
+ :Groups => {
202
+ :Group => [
203
+ ],
204
+ },
205
+ :environment_id => environment[:id],
206
+ }
207
+
208
+ group = {
209
+ :id => group_id,
210
+ :name => options[:group],
211
+ :href => "/cloudapi/ecloud/layoutgroups/#{group_id}",
212
+ :type => "application/vnd.tmrk.cloud.layoutGroup",
213
+ :Links => {
214
+ :Link => [
215
+ Fog::Ecloud.keep(row, :name, :href, :type),
216
+ ],
217
+ },
218
+ :Index => 0,
219
+ :VirtualMachines => {
220
+ :VirtualMachine => [
221
+ server,
222
+ ],
223
+ },
224
+ :row_id => row_id,
225
+ }
226
+ row[:Groups][:Group].push(group)
227
+ layout[:Rows][:Row].push(row)
228
+
229
+ server.merge!(:OperatingSystem => options[:operating_system].merge(:type => "application/vnd.tmrk.cloud.operatingSystem")) if options[:operating_system]
230
+
231
+ server_response = response(:body => server)
232
+
233
+ server.merge!(:compute_pool_id => compute_pool[:id])
234
+
235
+ self.data[:servers][server_id] = server
236
+ self.data[:rows][row_id] = row
237
+ self.data[:groups][group_id] = group
238
+
239
+ server_response
240
+ end
241
+ end
242
+ end
243
+ end
244
+ end