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,824 @@
1
+ require 'fog/ecloud/core'
2
+ require 'fog/ecloud/collection'
3
+ require 'fog/ecloud/model'
4
+ require 'builder'
5
+
6
+ module Fog
7
+ module Compute
8
+ class Ecloud < Fog::Service
9
+ API_URL = "https://services.enterprisecloud.terremark.com"
10
+
11
+ attr_reader :authentication_method, :version
12
+
13
+ #### Credentials
14
+ #requires
15
+ recognizes :ecloud_username, :ecloud_password, :ecloud_version,
16
+ :ecloud_access_key, :ecloud_private_key,
17
+ :ecloud_authentication_method, :base_path
18
+
19
+ #### Models
20
+ model_path 'fog/ecloud/models/compute'
21
+ model :organization
22
+ collection :organizations
23
+ model :location
24
+ collection :locations
25
+ model :catalog_item
26
+ collection :catalog
27
+ model :catalog_configuration
28
+ collection :catalog_configurations
29
+ model :environment
30
+ collection :environments
31
+ model :task
32
+ collection :tasks
33
+ model :compute_pool
34
+ collection :compute_pools
35
+ model :server
36
+ collection :servers
37
+ model :virtual_machine_assigned_ip
38
+ collection :virtual_machine_assigned_ips
39
+ model :hardware_configuration
40
+ collection :hardware_configurations
41
+ model :server_configuration_option
42
+ collection :server_configuration_options
43
+ model :guest_process
44
+ collection :guest_processes
45
+ model :layout
46
+ collection :layouts
47
+ model :row
48
+ collection :rows
49
+ model :group
50
+ collection :groups
51
+ model :internet_service
52
+ collection :internet_services
53
+ model :node
54
+ collection :nodes
55
+ model :monitor
56
+ collection :monitors
57
+ model :cpu_usage_detail
58
+ collection :cpu_usage_detail_summary
59
+ model :memory_usage_detail
60
+ collection :memory_usage_detail_summary
61
+ model :storage_usage_detail
62
+ collection :storage_usage_detail_summary
63
+ model :operating_system_family
64
+ collection :operating_system_families
65
+ model :operating_system
66
+ collection :operating_systems
67
+ model :template
68
+ collection :templates
69
+ model :firewall_acl
70
+ collection :firewall_acls
71
+ model :network
72
+ collection :networks
73
+ model :ip_address
74
+ collection :ip_addresses
75
+ model :physical_device
76
+ collection :physical_devices
77
+ model :public_ip
78
+ collection :public_ips
79
+ model :trusted_network_group
80
+ collection :trusted_network_groups
81
+ model :backup_internet_service
82
+ collection :backup_internet_services
83
+ model :rnat
84
+ collection :rnats
85
+ model :association
86
+ collection :associations
87
+ model :tag
88
+ collection :tags
89
+ model :admin_organization
90
+ collection :admin_organizations
91
+ model :ssh_key
92
+ collection :ssh_keys
93
+ model :password_complexity_rule
94
+ collection :password_complexity_rules
95
+ model :authentication_level
96
+ collection :authentication_levels
97
+ model :login_banner
98
+ collection :login_banners
99
+ model :user
100
+ collection :users
101
+ model :role
102
+ collection :roles
103
+ model :ssh_key
104
+ collection :ssh_keys
105
+ model :support_ticket
106
+ collection :support_tickets
107
+ model :detached_disk
108
+ collection :detached_disks
109
+
110
+ #### Requests
111
+ request_path 'fog/ecloud/requests/compute'
112
+ request :backup_internet_service_create
113
+ request :backup_internet_service_delete
114
+ request :backup_internet_service_edit
115
+ request :compute_pool_edit
116
+ request :firewall_acls_create
117
+ request :firewall_acls_delete
118
+ request :get_admin_organization
119
+ request :get_api_key
120
+ request :get_api_keys
121
+ request :get_association
122
+ request :get_associations
123
+ request :get_authentication_level
124
+ request :get_authentication_levels
125
+ request :get_backup_internet_service
126
+ request :get_backup_internet_services
127
+ request :get_catalog
128
+ request :get_catalog_configuration
129
+ request :get_catalog_configurations
130
+ request :get_catalog_item
131
+ request :get_compute_pool
132
+ request :get_compute_pools
133
+ request :get_cpu_usage_detail
134
+ request :get_cpu_usage_detail_summary
135
+ request :get_environment
136
+ request :get_firewall_acl
137
+ request :get_firewall_acls
138
+ request :get_group
139
+ request :get_groups
140
+ request :get_guest_process
141
+ request :get_guest_processes
142
+ request :get_hardware_configuration
143
+ request :get_internet_service
144
+ request :get_internet_services
145
+ request :get_ip_address
146
+ request :get_layout
147
+ request :get_layouts
148
+ request :get_location
149
+ request :get_locations
150
+ request :get_login_banner
151
+ request :get_login_banners
152
+ request :get_memory_usage_detail
153
+ request :get_memory_usage_detail_summary
154
+ request :get_monitor
155
+ request :get_monitors
156
+ request :get_network
157
+ request :get_network_summary
158
+ request :get_networks
159
+ request :get_node
160
+ request :get_nodes
161
+ request :get_operating_system
162
+ request :get_operating_system_families
163
+ request :get_organization
164
+ request :get_organizations
165
+ request :get_password_complexity_rule
166
+ request :get_password_complexity_rules
167
+ request :get_physical_device
168
+ request :get_physical_devices
169
+ request :get_public_ip
170
+ request :get_public_ips
171
+ request :get_rnat
172
+ request :get_rnats
173
+ request :get_role
174
+ request :get_roles
175
+ request :get_row
176
+ request :get_rows
177
+ request :get_server
178
+ request :get_server_configuration_option
179
+ request :get_server_configuration_options
180
+ request :get_servers
181
+ request :get_ssh_key
182
+ request :get_ssh_keys
183
+ request :get_storage_usage_detail
184
+ request :get_storage_usage_detail_summary
185
+ request :get_support_ticket
186
+ request :get_support_tickets
187
+ request :get_tag
188
+ request :get_tags
189
+ request :get_task
190
+ request :get_tasks
191
+ request :get_template
192
+ request :get_templates
193
+ request :get_trusted_network_group
194
+ request :get_trusted_network_groups
195
+ request :get_user
196
+ request :get_users
197
+ request :get_virtual_machine_assigned_ips
198
+ request :get_detached_disks
199
+ request :get_detached_disk
200
+ request :groups_create
201
+ request :groups_delete
202
+ request :groups_edit
203
+ request :groups_movedown
204
+ request :groups_moveup
205
+ request :internet_service_create
206
+ request :internet_service_delete
207
+ request :internet_service_edit
208
+ request :monitors_create_default
209
+ request :monitors_create_ecv
210
+ request :monitors_create_http
211
+ request :monitors_create_loopback
212
+ request :monitors_create_ping
213
+ request :monitors_disable
214
+ request :monitors_edit_ecv
215
+ request :monitors_edit_http
216
+ request :monitors_edit_ping
217
+ request :monitors_enable
218
+ request :node_service_create
219
+ request :node_service_delete
220
+ request :node_service_edit
221
+ request :power_off
222
+ request :power_on
223
+ request :power_reset
224
+ request :power_shutdown
225
+ request :public_ip_activate
226
+ request :rnat_associations_create_device
227
+ request :rnat_associations_delete
228
+ request :rnat_associations_edit_network
229
+ request :rows_create
230
+ request :rows_delete
231
+ request :rows_edit
232
+ request :rows_movedown
233
+ request :rows_moveup
234
+ request :trusted_network_groups_create
235
+ request :trusted_network_groups_delete
236
+ request :trusted_network_groups_edit
237
+ request :virtual_machine_edit_assigned_ips
238
+ request :virtual_machine_copy
239
+ request :virtual_machine_copy_identical
240
+ request :virtual_machine_create_from_template
241
+ request :virtual_machine_delete
242
+ request :virtual_machine_edit
243
+ request :virtual_machine_edit_hardware_configuration
244
+ request :virtual_machine_import
245
+ request :virtual_machine_upload_file
246
+ request :virtual_machine_detach_disk
247
+ request :virtual_machine_attach_disk
248
+
249
+ module Shared
250
+ attr_accessor :base_path
251
+ attr_reader :versions_uri
252
+
253
+ def validate_data(required_opts = [], options = {})
254
+ unless required_opts.all? { |opt| options.key?(opt) }
255
+ raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
256
+ end
257
+ end
258
+
259
+ def id_from_uri(uri)
260
+ uri.match(/(\d+)$/)[1].to_i
261
+ end
262
+
263
+ def default_organization_uri
264
+ "#{@base_path}/organizations"
265
+ end
266
+ end
267
+
268
+ class Real
269
+ include Shared
270
+
271
+ class << self
272
+ def basic_request(name, expects=[200], method=:get, headers={}, body='')
273
+ define_method(name) do |uri|
274
+ request({
275
+ :expects => expects,
276
+ :method => method,
277
+ :headers => headers,
278
+ :body => body,
279
+ :parse => true,
280
+ :uri => uri
281
+ })
282
+ end
283
+ end
284
+ end
285
+
286
+ def initialize(options = {})
287
+ @base_path = options[:base_path] || '/cloudapi/ecloud'
288
+ @connections = {}
289
+ @connection_options = options[:connection_options] || {}
290
+ @host = options[:ecloud_host] || API_URL
291
+ @persistent = options[:persistent] || false
292
+ @version = options[:ecloud_version] || "2013-06-01"
293
+ @authentication_method = options[:ecloud_authentication_method] || :cloud_api_auth
294
+ @access_key = options[:ecloud_access_key]
295
+ @private_key = options[:ecloud_private_key]
296
+ if @private_key.nil? || @authentication_method == :basic_auth
297
+ @authentication_method = :basic_auth
298
+ @username = options[:ecloud_username]
299
+ @password = options[:ecloud_password]
300
+ if @username.nil? || @password.nil?
301
+ raise ArgumentError, "No credentials (cloud auth, or basic auth) passed!"
302
+ end
303
+ else
304
+ @hmac = Fog::HMAC.new("sha256", @private_key)
305
+ end
306
+ end
307
+
308
+ def request(params)
309
+ # Convert the uri to a URI if it's a string.
310
+ if params[:uri].is_a?(String)
311
+ params[:uri] = URI.parse(@host + params[:uri])
312
+ end
313
+ host_url = "#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? ":#{params[:uri].port}" : ''}"
314
+
315
+ # Hash connections on the host_url ... There's nothing to say we won't get URI's that go to
316
+ # different hosts.
317
+ @connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)
318
+
319
+ # Set headers to an empty hash if none are set.
320
+ headers = set_extra_headers_for(params) || set_extra_headers_for({})
321
+
322
+ # Make the request
323
+ options = {
324
+ :expects => (params[:expects] || 200),
325
+ :method => params[:method] || 'GET',
326
+ :path => params[:uri].path + "#{"?#{params[:uri].query}" if params[:uri].query}",
327
+ :headers => headers
328
+ }
329
+ unless params[:body].nil? || params[:body].empty?
330
+ options.merge!({:body => params[:body]})
331
+ end
332
+ response = @connections[host_url].request(options)
333
+ # Parse the response body into a hash
334
+ unless response.body.empty?
335
+ if params[:parse]
336
+ document = Fog::ToHashDocument.new
337
+ parser = Nokogiri::XML::SAX::PushParser.new(document)
338
+ parser << response.body
339
+ parser.finish
340
+
341
+ response.body = document.body
342
+ end
343
+ end
344
+
345
+ response
346
+ end
347
+
348
+ private
349
+
350
+ # if Authorization and x-tmrk-authorization are used, the x-tmrk-authorization takes precendence.
351
+ def set_extra_headers_for(params)
352
+ params[:headers] = {
353
+ 'x-tmrk-version' => @version,
354
+ 'Date' => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT"),
355
+ }.merge(params[:headers] || {})
356
+ if params[:method]=="POST" || params[:method]=="PUT"
357
+ params[:headers].merge!({"Content-Type" => 'application/xml'}) unless params[:headers]['Content-Type']
358
+ params[:headers].merge!({"Accept" => 'application/xml'})
359
+ end
360
+ unless params[:body].nil? || params[:body].empty?
361
+ params[:headers].merge!({"x-tmrk-contenthash" => "Sha256 #{Base64.encode64(Digest::SHA2.digest(params[:body].to_s)).chomp}"})
362
+ end
363
+ if @authentication_method == :basic_auth
364
+ params[:headers].merge!({'Authorization' => "Basic #{Base64.encode64(@username+":"+@password).delete("\r\n")}"})
365
+ elsif @authentication_method == :cloud_api_auth
366
+ signature = cloud_api_signature(params)
367
+ params[:headers].merge!({
368
+ "x-tmrk-authorization" => %{CloudApi AccessKey="#{@access_key}" SignatureType="HmacSha256" Signature="#{signature}"},
369
+ "Authorization" => %{CloudApi AccessKey="#{@access_key}" SignatureType="HmacSha256" Signature="#{signature}"}
370
+ })
371
+ end
372
+ params[:headers]
373
+ end
374
+
375
+ def cloud_api_signature(params)
376
+ verb = params[:method].upcase
377
+ headers = params[:headers]
378
+ path = params[:uri].path
379
+ canonicalized_headers = canonicalize_headers(headers)
380
+ canonicalized_resource = canonicalize_resource(path)
381
+ string = [
382
+ verb,
383
+ headers['Content-Length'].to_s,
384
+ headers['Content-Type'].to_s,
385
+ headers['Date'].to_s,
386
+ canonicalized_headers,
387
+ canonicalized_resource + "\n"
388
+ ].join("\n")
389
+ Base64.encode64(@hmac.sign(string)).chomp
390
+ end
391
+
392
+ # section 5.6.3.2 in the ~1000 page pdf spec
393
+ def canonicalize_headers(headers)
394
+ tmp = headers.reduce({}) {|ret, h| ret[h.first.downcase] = h.last if h.first.match(/^x-tmrk/i) ; ret }
395
+ tmp.reject! {|k,v| k == "x-tmrk-authorization" }
396
+ tmp = tmp.sort.map{|e| "#{e.first}:#{e.last}" }.join("\n")
397
+ tmp
398
+ end
399
+
400
+ # section 5.6.3.3 in the ~1000 page pdf spec
401
+ def canonicalize_resource(path)
402
+ uri, query_string = path.split("?")
403
+ return uri if query_string.nil?
404
+ query_string_pairs = query_string.split("&").sort.map{|e| e.split("=") }
405
+ tm_query_string = query_string_pairs.map{|x| "#{x.first.downcase}:#{x.last}" }.join("\n")
406
+ "#{uri.downcase}\n#{tm_query_string}\n"
407
+ end
408
+ end
409
+
410
+ class Mock
411
+ include Shared
412
+
413
+ def self.data
414
+ @data ||= Hash.new do |hash, key|
415
+ hash[key] = begin
416
+ compute_pool_id = Fog.credentials[:ecloud_compute_pool_id] || Fog::Mock.random_numbers(3).to_i
417
+ environment_id = Fog.credentials[:ecloud_environment_id] || Fog::Mock.random_numbers(3).to_i
418
+ public_ip_id = Fog.credentials[:ecloud_public_ip_id] || Fog::Mock.random_numbers(6).to_i
419
+ internet_service_id = Fog::Mock.random_numbers(6).to_i
420
+ node_service_id = Fog::Mock.random_numbers(6).to_i
421
+ environment_name = Fog.credentials[:ecloud_environment_name] || Fog::Mock.random_letters(12)
422
+ location_id = Fog::Mock.random_numbers(4).to_i
423
+ network_id = Fog.credentials[:ecloud_network_id] || Fog::Mock.random_numbers(6).to_i
424
+ network_ip = Fog::Ecloud.ip_address
425
+ public_ip = Fog.credentials[:ecloud_public_ip_name] || Fog::Ecloud.ip_address
426
+ ip_address_id = Fog::Ecloud.ip_address
427
+ ip_address2_id = Fog::Ecloud.ip_address
428
+ operating_system_id = Fog::Mock.random_numbers(7).to_i
429
+ operating_system_family_id = Fog::Mock.random_numbers(7).to_i
430
+ organization_id = Fog::Mock.random_numbers(7).to_i
431
+ organization_name = Fog::Mock.random_letters(7)
432
+ template_id = Fog.credentials[:ecloud_template_id] || Fog::Mock.random_numbers(7).to_i
433
+ ssh_key_id = Fog.credentials[:ecloud_ssh_key_id] || Fog::Mock.random_numbers(4).to_i
434
+ ssh_key_name = Fog.credentials[:ecloud_ssh_key_name] || "root"
435
+
436
+ environment = {
437
+ :id => environment_id,
438
+ :href => "/cloudapi/ecloud/environments/#{environment_id}",
439
+ :name => environment_name,
440
+ :type => "application/vnd.tmrk.cloud.environment"
441
+ }
442
+
443
+ organization = {
444
+ :href => "/cloudapi/ecloud/organizations/#{organization_id}",
445
+ :type => "application/vnd.tmrk.cloud.organization",
446
+ :name => organization_name,
447
+ :Links => {
448
+ :Link => [
449
+ Fog::Ecloud.keep(environment, :href, :name, :type),
450
+ {
451
+ :href => "/cloudapi/ecloud/admin/organizations/#{organization_id}",
452
+ :name => organization_name,
453
+ :type => "application/vnd.tmrk.cloud.admin.organization",
454
+ :rel => "alternate",
455
+ },
456
+ {
457
+ :href => "/cloudapi/ecloud/devicetags/organizations/#{organization_id}",
458
+ :type => "application/vnd.tmrk.cloud.deviceTag; type=collection",
459
+ :rel => "down",
460
+ },
461
+ {
462
+ :href => "/cloudapi/ecloud/alerts/organizations/#{organization_id}",
463
+ :type => "application/vnd.tmrk.cloud.alertLog",
464
+ :rel => "down",
465
+ },
466
+ ],
467
+ },
468
+ :Locations => {
469
+ :Location => [
470
+ {
471
+ :href => "/cloudapi/ecloud/locations/#{location_id}",
472
+ :name => organization_name,
473
+ :Catalog => {
474
+ :href => "/cloudapi/ecloud/admin/catalog/organizations/#{organization_id}/locations/#{location_id}",
475
+ :type => "application/vnd.tmrk.cloud.admin.catalogEntry; type=collection"
476
+ },
477
+ :Environments => { :Environment => [environment] }
478
+ }
479
+ ]
480
+ }
481
+ }
482
+ environment.merge!(
483
+ :Links => {
484
+ :Link => [ Fog::Ecloud.keep(organization, :href, :name, :type), ]
485
+ }
486
+ )
487
+
488
+ admin_organization = {
489
+ :id => organization_id,
490
+ :href => "/cloudapi/ecloud/admin/organizations/#{organization_id}",
491
+ :type => "application/vnd.tmrk.cloud.admin.organization",
492
+ :name => organization_name,
493
+ :Links => {
494
+ :Link => [
495
+ Fog::Ecloud.keep(organization, :href, :type, :name)
496
+ ],
497
+ },
498
+ :organization_id => organization_id,
499
+ }
500
+
501
+ compute_pool = {
502
+ :id => compute_pool_id,
503
+ :href => "/cloudapi/ecloud/computepools/#{compute_pool_id}",
504
+ :name => Fog::Mock.random_letters(12),
505
+ :type => "application/vnd.tmrk.cloud.computePool",
506
+ :environment_id => environment_id,
507
+ :Links => {
508
+ :Link => [
509
+ Fog::Ecloud.keep(organization, :href, :name, :type),
510
+ Fog::Ecloud.keep(environment, :href, :name, :type),
511
+ ]
512
+ }
513
+ }
514
+
515
+ public_ip = {
516
+ :id => public_ip_id,
517
+ :href => "/cloudapi/ecloud/publicips/#{public_ip_id}",
518
+ :name => public_ip,
519
+ :type => "application/vnd.tmrk.cloud.publicIp",
520
+ :IpType => "none",
521
+ :environment_id => environment_id,
522
+ :Links => {
523
+ :Link => [
524
+ Fog::Ecloud.keep(environment, :href, :name, :type),
525
+ ],
526
+ },
527
+ :InternetServices => {
528
+ :InternetService => [
529
+ ],
530
+ },
531
+ }
532
+
533
+ internet_service = {
534
+ :id => internet_service_id,
535
+ :href => "/cloudapi/ecloud/internetservices/#{internet_service_id}",
536
+ :name => Fog::Mock.random_letters(6),
537
+ :type => "application/vnd.tmrk.cloud.internetService",
538
+ :public_ip_id => public_ip_id,
539
+ :Links => {
540
+ :Link => [
541
+ Fog::Ecloud.keep(public_ip, :href, :name, :type),
542
+ ],
543
+ },
544
+ :NodeServices => {
545
+ :NodeService => [
546
+ ]
547
+ },
548
+ }
549
+
550
+ node_service = {
551
+ :id => node_service_id,
552
+ :href => "/cloudapi/ecloud/nodeservices/#{node_service_id}",
553
+ :name => Fog::Mock.random_letters(6),
554
+ :type => "application/vnd.tmrk.cloud.nodeService",
555
+ :internet_service_id => internet_service_id,
556
+ :Links => {
557
+ :Link => [
558
+ Fog::Ecloud.keep(internet_service, :href, :name, :type)
559
+ ],
560
+ },
561
+ }
562
+
563
+ internet_service[:NodeServices][:NodeService].push(node_service)
564
+ public_ip[:InternetServices][:InternetService].push(internet_service)
565
+
566
+ network = {
567
+ :id => network_id,
568
+ :href => "/cloudapi/ecloud/networks/#{network_id}",
569
+ :name => "#{network_ip}/#{Fog::Mock.random_numbers(2)}",
570
+ :type => "application/vnd.tmrk.cloud.network",
571
+ :Address => network_ip,
572
+ :NetworkType => "Dmz",
573
+ :BroadcastAddress => network_ip,
574
+ :GatewayAddress => network_ip,
575
+ :environment_id => environment_id,
576
+ :Links => {
577
+ :Link => [
578
+ Fog::Ecloud.keep(environment, :href, :name, :type),
579
+ ]
580
+ },
581
+ :IpAddresses => {
582
+ :IpAddress => [],
583
+ },
584
+ }
585
+
586
+ ip_address = {
587
+ :id => ip_address_id,
588
+ :href => "/cloudapi/ecloud/ipaddresses/networks/#{network_id}/#{ip_address_id}",
589
+ :name => ip_address_id,
590
+ :type => "application/vnd.tmrk.cloud.ipAddress",
591
+ :network_id => network_id,
592
+ :Links => {
593
+ :Link => [ Fog::Ecloud.keep(network, :href, :name, :type), ],
594
+ },
595
+ :Reserved => "false",
596
+ :Host => nil,
597
+ :DetectedOn => nil,
598
+ }
599
+
600
+ ip_address2 = ip_address.dup.merge(:id => ip_address2_id, :href => "/cloudapi/ecloud/ipaddresses/networks/#{network_id}/#{ip_address2_id}", :name => ip_address2_id)
601
+
602
+ network[:IpAddresses][:IpAddress].push(ip_address).push(ip_address2)
603
+
604
+ short_name = "solaris10_64guest"
605
+ operating_system = {
606
+ :short_name => short_name,
607
+ :compute_pool_id => compute_pool_id,
608
+ :href => "/cloudapi/ecloud/operatingsystems/#{short_name}/computepools/#{compute_pool_id}",
609
+ :name => "Sun Solaris 10 (64-bit)",
610
+ :type => "application/vnd.tmrk.cloud.operatingSystem",
611
+ :FamilyName => "Solaris",
612
+ :Links => {
613
+ :Link => Fog::Ecloud.keep(compute_pool, :href, :name, :type),
614
+ },
615
+ :ConfigurationOptions => {
616
+ :Processor => {
617
+ :Minimum => "1",
618
+ :Maximum => "8",
619
+ :StepFactor => "1"
620
+ },
621
+ :Memory => {
622
+ :MinimumSize => {
623
+ :Unit => "MB",
624
+ :Value => "800"
625
+ },
626
+ :MaximumSize => {
627
+ :Unit => "MB",
628
+ :Value => "16384"
629
+ },
630
+ :StepFactor => {
631
+ :Unit => "MB",
632
+ :Value => "4"
633
+ }
634
+ },
635
+ :Disk => {
636
+ :Minimum => "1",
637
+ :Maximum => "15",
638
+ :SystemDisk => {
639
+ :ResourceCapacityRange => {
640
+ :MinimumSize => {
641
+ :Unit => "GB",
642
+ :Value => "1"
643
+ },
644
+ :MaximumSize => {
645
+ :Unit => "GB",
646
+ :Value => "512"
647
+ },
648
+ :StepFactor => {
649
+ :Unit => "GB",
650
+ :Value => "1"}
651
+ },
652
+ :MonthlyCost => "0"
653
+ },
654
+ :DataDisk => {
655
+ :ResourceCapacityRange => {
656
+ :MinimumSize => {
657
+ :Unit => "GB",
658
+ :Value => "1"
659
+ },
660
+ :MaximumSize => {
661
+ :Unit => "GB",
662
+ :Value => "512"
663
+ },
664
+ :StepFactor => {
665
+ :Unit => "GB",
666
+ :Value => "1"
667
+ }
668
+ },
669
+ :MonthlyCost => "0"
670
+ }
671
+ },
672
+ :NetworkAdapter=> {
673
+ :Minimum => "1",
674
+ :Maximum => "4",
675
+ :StepFactor => "1"
676
+ }
677
+ }
678
+ }
679
+
680
+ template = {
681
+ :id => template_id,
682
+ :href => "/cloudapi/ecloud/templates/#{template_id}/computepools/#{compute_pool_id}",
683
+ :type => "application/vnd.tmrk.cloud.template",
684
+ :name => "Sun Solaris 10 (x64)",
685
+ :compute_pool_id => compute_pool_id,
686
+ :OperatingSystem => Fog::Ecloud.keep(operating_system, :href, :name, :type),
687
+ :Memory => {
688
+ :MinimumSize => {
689
+ :Unit => "MB",
690
+ :Value => "800"
691
+ },
692
+ :MaximumSize => {
693
+ :Unit => "MB",
694
+ :Value => "16384"
695
+ },
696
+ :StepFactor => {
697
+ :Unit => "MB",
698
+ :Value => "4"
699
+ }
700
+ },
701
+ :Storage => {
702
+ :Size => {
703
+ :Unit => "GB",
704
+ :Value => "7"
705
+ }
706
+ },
707
+ :NetworkAdapters => "1",
708
+ :Links => {
709
+ :Link => [
710
+ Fog::Ecloud.keep(compute_pool, :href, :name, :type),
711
+ ]
712
+ }
713
+ }
714
+
715
+ operating_system_family = {
716
+ :id => operating_system_family_id,
717
+ :compute_pool_id => compute_pool_id,
718
+ :OperatingSystemFamily => {
719
+ :Name => "Linux",
720
+ :OperatingSystems => {
721
+ :OperatingSystem => [Fog::Ecloud.keep(operating_system, :href, :name, :type)],
722
+ }
723
+ },
724
+ :Links => {
725
+ :Link => [
726
+ Fog::Ecloud.keep(compute_pool, :href, :name, :type),
727
+ ]
728
+ }
729
+ }
730
+
731
+ ssh_key = {
732
+ :id => ssh_key_id,
733
+ :href => "/cloudapi/ecloud/admin/sshKeys/#{ssh_key_id}",
734
+ :name => ssh_key_name,
735
+ :admin_organization_id => organization_id,
736
+ :Links => {
737
+ :Link => [
738
+ Fog::Ecloud.keep(admin_organization, :href, :name, :type),
739
+ Fog::Ecloud.keep(organization, :href, :name, :type),
740
+ ]
741
+ },
742
+ :Default => "true",
743
+ :FingerPrint => Fog::Ecloud.mac_address
744
+ }
745
+
746
+ layout = {
747
+ :id => environment_id,
748
+ :href => "/cloudapi/ecloud/layout/environments/#{environment_id}",
749
+ :type => "application/vnd.tmrk.cloud.deviceLayout",
750
+ :Links => {
751
+ :Link => [
752
+ Fog::Ecloud.keep(environment, :name, :href, :type),
753
+ ],
754
+ },
755
+ :Rows => {
756
+ :Row => [
757
+ ],
758
+ },
759
+ :environment_id => environment_id
760
+ }
761
+
762
+ {
763
+ :compute_pools => {compute_pool_id => compute_pool},
764
+ :environments => {environment_id => environment},
765
+ :public_ips => {public_ip_id => public_ip},
766
+ :internet_services => {internet_service_id => internet_service},
767
+ :node_services => {node_service_id => node_service},
768
+ :networks => {network_id => network},
769
+ :organizations => {organization_id => organization},
770
+ :admin_organizations => {organization_id => admin_organization},
771
+ :operating_systems => {operating_system_id => operating_system},
772
+ :operating_system_families => {operating_system_family_id => operating_system_family},
773
+ :servers => {},
774
+ :tasks => {},
775
+ :templates => {template_id => template},
776
+ :ssh_keys => {ssh_key_id => ssh_key},
777
+ :detached_disks => {},
778
+ :template_href => (Fog.credentials[:ecloud_template_href] || "/cloudapi/ecloud/templates/#{template_id}/computepools/#{compute_pool_id}"),
779
+ :rows => {},
780
+ :groups => {},
781
+ :layouts => {environment_id => layout},
782
+ }
783
+ end
784
+ end
785
+ end
786
+
787
+ def self.reset
788
+ @data = nil
789
+ end
790
+
791
+ def initialize(options={})
792
+ @base_path = '/cloudapi/ecloud'
793
+ @ecloud_api_key = options[:ecloud]
794
+ end
795
+
796
+ def data
797
+ self.class.data[@ecloud_api_key]
798
+ end
799
+
800
+ def reset_data
801
+ self.class.data.delete(@ecloud_api_key)
802
+ end
803
+
804
+ def response(params={})
805
+ body = params[:body]
806
+ headers = {
807
+ "Content-Type" => "application/xml"
808
+ }.merge(params[:headers] || {})
809
+ status = params[:status] || 200
810
+
811
+ response = Excon::Response.new(:body => body, :headers => headers, :status => status)
812
+ if params.key?(:expects) && ![*params[:expects]].include?(response.status)
813
+ raise(Excon::Errors.status_error(params, response))
814
+ else response
815
+ end
816
+ end
817
+
818
+ def deep_copy(o)
819
+ Marshal.load(Marshal.dump(o))
820
+ end
821
+ end
822
+ end
823
+ end
824
+ end