fog 1.10.1 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (319) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +1 -0
  3. data/Gemfile +2 -0
  4. data/README.md +4 -3
  5. data/changelog.txt +207 -0
  6. data/fog.gemspec +4 -3
  7. data/lib/fog/aws.rb +0 -2
  8. data/lib/fog/aws/dynamodb.rb +1 -1
  9. data/lib/fog/aws/elasticache.rb +0 -2
  10. data/lib/fog/aws/iam.rb +1 -0
  11. data/lib/fog/aws/models/compute/volume.rb +1 -0
  12. data/lib/fog/aws/models/iam/user.rb +1 -0
  13. data/lib/fog/aws/models/storage/directories.rb +1 -1
  14. data/lib/fog/aws/models/storage/directory.rb +20 -17
  15. data/lib/fog/aws/models/storage/file.rb +4 -5
  16. data/lib/fog/aws/parsers/iam/get_user.rb +2 -0
  17. data/lib/fog/aws/parsers/iam/list_users.rb +2 -0
  18. data/lib/fog/aws/requests/cdn/delete_streaming_distribution.rb +2 -2
  19. data/lib/fog/aws/requests/cdn/put_distribution_config.rb +3 -3
  20. data/lib/fog/aws/requests/cloud_formation/update_stack.rb +3 -3
  21. data/lib/fog/aws/requests/cloud_formation/validate_template.rb +5 -5
  22. data/lib/fog/aws/requests/iam/create_user.rb +5 -4
  23. data/lib/fog/aws/requests/iam/get_user.rb +5 -4
  24. data/lib/fog/aws/requests/iam/list_users.rb +5 -4
  25. data/lib/fog/aws/requests/rds/create_db_instance.rb +25 -25
  26. data/lib/fog/aws/requests/storage/abort_multipart_upload.rb +3 -3
  27. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +2 -2
  28. data/lib/fog/aws/requests/storage/copy_object.rb +2 -2
  29. data/lib/fog/aws/requests/storage/delete_bucket.rb +1 -1
  30. data/lib/fog/aws/requests/storage/delete_bucket_cors.rb +1 -1
  31. data/lib/fog/aws/requests/storage/delete_bucket_lifecycle.rb +1 -1
  32. data/lib/fog/aws/requests/storage/delete_bucket_policy.rb +1 -1
  33. data/lib/fog/aws/requests/storage/delete_bucket_website.rb +1 -1
  34. data/lib/fog/aws/requests/storage/delete_multiple_objects.rb +1 -1
  35. data/lib/fog/aws/requests/storage/delete_object.rb +1 -1
  36. data/lib/fog/aws/requests/storage/get_bucket.rb +1 -1
  37. data/lib/fog/aws/requests/storage/get_bucket_acl.rb +1 -1
  38. data/lib/fog/aws/requests/storage/get_bucket_cors.rb +1 -1
  39. data/lib/fog/aws/requests/storage/get_bucket_lifecycle.rb +1 -1
  40. data/lib/fog/aws/requests/storage/get_bucket_location.rb +1 -1
  41. data/lib/fog/aws/requests/storage/get_bucket_logging.rb +1 -1
  42. data/lib/fog/aws/requests/storage/get_bucket_object_versions.rb +1 -1
  43. data/lib/fog/aws/requests/storage/get_bucket_policy.rb +1 -1
  44. data/lib/fog/aws/requests/storage/get_bucket_versioning.rb +1 -1
  45. data/lib/fog/aws/requests/storage/get_bucket_website.rb +1 -1
  46. data/lib/fog/aws/requests/storage/get_object.rb +2 -2
  47. data/lib/fog/aws/requests/storage/get_object_acl.rb +2 -2
  48. data/lib/fog/aws/requests/storage/get_object_http_url.rb +1 -19
  49. data/lib/fog/aws/requests/storage/get_object_torrent.rb +2 -2
  50. data/lib/fog/aws/requests/storage/get_object_url.rb +5 -14
  51. data/lib/fog/aws/requests/storage/get_request_payment.rb +1 -1
  52. data/lib/fog/aws/requests/storage/head_object.rb +2 -2
  53. data/lib/fog/aws/requests/storage/initiate_multipart_upload.rb +2 -2
  54. data/lib/fog/aws/requests/storage/list_multipart_uploads.rb +7 -8
  55. data/lib/fog/aws/requests/storage/list_parts.rb +2 -2
  56. data/lib/fog/aws/requests/storage/put_bucket.rb +1 -1
  57. data/lib/fog/aws/requests/storage/put_bucket_acl.rb +1 -1
  58. data/lib/fog/aws/requests/storage/put_bucket_cors.rb +1 -1
  59. data/lib/fog/aws/requests/storage/put_bucket_lifecycle.rb +1 -1
  60. data/lib/fog/aws/requests/storage/put_bucket_logging.rb +1 -1
  61. data/lib/fog/aws/requests/storage/put_bucket_policy.rb +1 -1
  62. data/lib/fog/aws/requests/storage/put_bucket_versioning.rb +1 -1
  63. data/lib/fog/aws/requests/storage/put_bucket_website.rb +1 -1
  64. data/lib/fog/aws/requests/storage/put_object.rb +2 -2
  65. data/lib/fog/aws/requests/storage/put_object_acl.rb +8 -8
  66. data/lib/fog/aws/requests/storage/put_object_url.rb +5 -7
  67. data/lib/fog/aws/requests/storage/put_request_payment.rb +1 -1
  68. data/lib/fog/aws/requests/storage/upload_part.rb +2 -2
  69. data/lib/fog/aws/storage.rb +201 -97
  70. data/lib/fog/bin/google.rb +47 -1
  71. data/lib/fog/bluebox/models/compute/server.rb +3 -1
  72. data/lib/fog/brightbox/compute.rb +11 -26
  73. data/lib/fog/brightbox/compute/image_selector.rb +45 -0
  74. data/lib/fog/cloudstack/compute.rb +70 -2
  75. data/lib/fog/cloudstack/models/compute/disk_offering.rb +46 -0
  76. data/lib/fog/cloudstack/models/compute/disk_offerings.rb +27 -0
  77. data/lib/fog/cloudstack/models/compute/image.rb +1 -1
  78. data/lib/fog/cloudstack/models/compute/servers.rb +3 -2
  79. data/lib/fog/cloudstack/requests/compute/create_disk_offering.rb +51 -0
  80. data/lib/fog/cloudstack/requests/compute/delete_disk_offering.rb +31 -0
  81. data/lib/fog/cloudstack/requests/compute/delete_snapshot.rb +44 -2
  82. data/lib/fog/cloudstack/requests/compute/list_disk_offerings.rb +9 -0
  83. data/lib/fog/cloudstack/requests/compute/list_os_types.rb +9 -0
  84. data/lib/fog/cloudstack/requests/compute/list_snapshots.rb +21 -0
  85. data/lib/fog/core/errors.rb +3 -0
  86. data/lib/fog/core/json.rb +48 -7
  87. data/lib/fog/core/model.rb +11 -10
  88. data/lib/fog/core/service.rb +1 -1
  89. data/lib/fog/digitalocean/CHANGELOG.md +1 -1
  90. data/lib/fog/dreamhost/dns.rb +1 -3
  91. data/lib/fog/google.rb +1 -0
  92. data/lib/fog/google/compute.rb +131 -0
  93. data/lib/fog/google/models/compute/flavor.rb +24 -0
  94. data/lib/fog/google/models/compute/flavors.rb +28 -0
  95. data/lib/fog/google/models/compute/image.rb +19 -0
  96. data/lib/fog/google/models/compute/images.rb +28 -0
  97. data/lib/fog/google/models/compute/server.rb +80 -0
  98. data/lib/fog/google/models/compute/servers.rb +61 -0
  99. data/lib/fog/google/requests/compute/delete_disk.rb +31 -0
  100. data/lib/fog/google/requests/compute/delete_firewall.rb +30 -0
  101. data/lib/fog/google/requests/compute/delete_image.rb +30 -0
  102. data/lib/fog/google/requests/compute/delete_network.rb +30 -0
  103. data/lib/fog/google/requests/compute/delete_operation.rb +30 -0
  104. data/lib/fog/google/requests/compute/delete_server.rb +40 -0
  105. data/lib/fog/google/requests/compute/get_disk.rb +31 -0
  106. data/lib/fog/google/requests/compute/get_firewall.rb +30 -0
  107. data/lib/fog/google/requests/compute/get_image.rb +30 -0
  108. data/lib/fog/google/requests/compute/get_machine_type.rb +30 -0
  109. data/lib/fog/google/requests/compute/get_network.rb +30 -0
  110. data/lib/fog/google/requests/compute/get_server.rb +31 -0
  111. data/lib/fog/google/requests/compute/get_zone.rb +30 -0
  112. data/lib/fog/google/requests/compute/insert_disk.rb +35 -0
  113. data/lib/fog/google/requests/compute/insert_firewall.rb +37 -0
  114. data/lib/fog/google/requests/compute/insert_image.rb +38 -0
  115. data/lib/fog/google/requests/compute/insert_network.rb +34 -0
  116. data/lib/fog/google/requests/compute/insert_server.rb +49 -0
  117. data/lib/fog/google/requests/compute/list_disks.rb +30 -0
  118. data/lib/fog/google/requests/compute/list_firewalls.rb +29 -0
  119. data/lib/fog/google/requests/compute/list_global_operations.rb +28 -0
  120. data/lib/fog/google/requests/compute/list_images.rb +29 -0
  121. data/lib/fog/google/requests/compute/list_machine_types.rb +29 -0
  122. data/lib/fog/google/requests/compute/list_networks.rb +29 -0
  123. data/lib/fog/google/requests/compute/list_servers.rb +30 -0
  124. data/lib/fog/google/requests/compute/list_zone_operations.rb +28 -0
  125. data/lib/fog/google/requests/compute/list_zones.rb +29 -0
  126. data/lib/fog/google/requests/compute/set_metadata.rb +36 -0
  127. data/lib/fog/hp.rb +1 -1
  128. data/lib/fog/hp/storage.rb +1 -1
  129. data/lib/fog/internet_archive/models/storage/ia_attributes.rb +1 -1
  130. data/lib/fog/internet_archive/requests/storage/head_object.rb +1 -2
  131. data/lib/fog/internet_archive/requests/storage/list_multipart_uploads.rb +5 -6
  132. data/lib/fog/openstack.rb +29 -1
  133. data/lib/fog/openstack/CHANGELOG.md +1 -1
  134. data/lib/fog/openstack/compute.rb +3 -2
  135. data/lib/fog/openstack/identity.rb +1 -5
  136. data/lib/fog/openstack/image.rb +8 -9
  137. data/lib/fog/openstack/models/compute/server.rb +24 -0
  138. data/lib/fog/openstack/network.rb +7 -28
  139. data/lib/fog/openstack/requests/compute/allocate_address.rb +1 -1
  140. data/lib/fog/openstack/requests/compute/attach_volume.rb +11 -6
  141. data/lib/fog/openstack/requests/compute/boot_from_snapshot.rb +1 -1
  142. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  143. data/lib/fog/openstack/requests/compute/create_key_pair.rb +1 -1
  144. data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
  145. data/lib/fog/openstack/requests/compute/create_security_group_rule.rb +1 -1
  146. data/lib/fog/openstack/requests/compute/create_volume.rb +15 -14
  147. data/lib/fog/openstack/requests/compute/create_volume_snapshot.rb +1 -1
  148. data/lib/fog/openstack/requests/compute/delete_volume.rb +9 -2
  149. data/lib/fog/openstack/requests/compute/detach_volume.rb +7 -2
  150. data/lib/fog/openstack/requests/compute/get_server_volumes.rb +10 -0
  151. data/lib/fog/openstack/requests/compute/get_volume_details.rb +7 -16
  152. data/lib/fog/openstack/requests/compute/list_tenants.rb +1 -1
  153. data/lib/fog/openstack/requests/compute/list_volumes.rb +4 -26
  154. data/lib/fog/openstack/requests/compute/revert_resize_server.rb +2 -2
  155. data/lib/fog/openstack/requests/compute/update_quota.rb +1 -1
  156. data/lib/fog/openstack/requests/identity/create_ec2_credential.rb +1 -1
  157. data/lib/fog/openstack/requests/identity/create_role.rb +1 -1
  158. data/lib/fog/openstack/requests/identity/create_user.rb +1 -1
  159. data/lib/fog/openstack/requests/identity/update_user.rb +1 -1
  160. data/lib/fog/openstack/requests/image/update_image_members.rb +1 -1
  161. data/lib/fog/openstack/requests/volume/create_volume.rb +1 -1
  162. data/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +1 -1
  163. data/lib/fog/openstack/requests/volume/get_quota.rb +31 -0
  164. data/lib/fog/openstack/requests/volume/get_quota_defaults.rb +31 -0
  165. data/lib/fog/openstack/requests/volume/update_quota.rb +32 -0
  166. data/lib/fog/openstack/volume.rb +11 -7
  167. data/lib/fog/rackspace.rb +11 -5
  168. data/lib/fog/rackspace/block_storage.rb +2 -1
  169. data/lib/fog/rackspace/cdn.rb +15 -15
  170. data/lib/fog/rackspace/compute.rb +2 -2
  171. data/lib/fog/rackspace/compute_v2.rb +8 -5
  172. data/lib/fog/rackspace/databases.rb +2 -1
  173. data/lib/fog/rackspace/dns.rb +2 -1
  174. data/lib/fog/rackspace/errors.rb +27 -0
  175. data/lib/fog/rackspace/load_balancers.rb +2 -1
  176. data/lib/fog/rackspace/mock_data.rb +5 -6
  177. data/lib/fog/rackspace/models/block_storage/snapshot.rb +8 -8
  178. data/lib/fog/rackspace/models/block_storage/snapshots.rb +8 -8
  179. data/lib/fog/rackspace/models/block_storage/volume.rb +16 -16
  180. data/lib/fog/rackspace/models/block_storage/volume_types.rb +8 -8
  181. data/lib/fog/rackspace/models/block_storage/volumes.rb +8 -8
  182. data/lib/fog/rackspace/models/compute_v2/attachment.rb +8 -8
  183. data/lib/fog/rackspace/models/compute_v2/attachments.rb +8 -8
  184. data/lib/fog/rackspace/models/compute_v2/flavors.rb +8 -8
  185. data/lib/fog/rackspace/models/compute_v2/image.rb +8 -8
  186. data/lib/fog/rackspace/models/compute_v2/images.rb +8 -8
  187. data/lib/fog/rackspace/models/compute_v2/metadata.rb +12 -12
  188. data/lib/fog/rackspace/models/compute_v2/metadatum.rb +8 -8
  189. data/lib/fog/rackspace/models/compute_v2/server.rb +94 -55
  190. data/lib/fog/rackspace/models/compute_v2/servers.rb +12 -12
  191. data/lib/fog/rackspace/models/dns/records.rb +1 -1
  192. data/lib/fog/rackspace/models/dns/zones.rb +1 -1
  193. data/lib/fog/rackspace/models/storage/account.rb +8 -8
  194. data/lib/fog/rackspace/models/storage/directories.rb +8 -8
  195. data/lib/fog/rackspace/models/storage/directory.rb +32 -32
  196. data/lib/fog/rackspace/models/storage/file.rb +36 -36
  197. data/lib/fog/rackspace/models/storage/files.rb +20 -20
  198. data/lib/fog/rackspace/requests/block_storage/create_snapshot.rb +4 -4
  199. data/lib/fog/rackspace/requests/block_storage/create_volume.rb +4 -4
  200. data/lib/fog/rackspace/requests/block_storage/delete_snapshot.rb +4 -4
  201. data/lib/fog/rackspace/requests/block_storage/delete_volume.rb +4 -4
  202. data/lib/fog/rackspace/requests/block_storage/get_snapshot.rb +4 -4
  203. data/lib/fog/rackspace/requests/block_storage/get_volume.rb +4 -4
  204. data/lib/fog/rackspace/requests/block_storage/get_volume_type.rb +4 -4
  205. data/lib/fog/rackspace/requests/block_storage/list_snapshots.rb +4 -4
  206. data/lib/fog/rackspace/requests/block_storage/list_volume_types.rb +4 -4
  207. data/lib/fog/rackspace/requests/block_storage/list_volumes.rb +4 -4
  208. data/lib/fog/rackspace/requests/cdn/delete_object.rb +4 -4
  209. data/lib/fog/rackspace/requests/cdn/get_containers.rb +4 -4
  210. data/lib/fog/rackspace/requests/cdn/head_container.rb +4 -4
  211. data/lib/fog/rackspace/requests/cdn/post_container.rb +4 -4
  212. data/lib/fog/rackspace/requests/cdn/put_container.rb +4 -4
  213. data/lib/fog/rackspace/requests/compute/delete_image.rb +1 -1
  214. data/lib/fog/rackspace/requests/compute_v2/attach_volume.rb +4 -4
  215. data/lib/fog/rackspace/requests/compute_v2/change_server_password.rb +4 -4
  216. data/lib/fog/rackspace/requests/compute_v2/confirm_resize_server.rb +4 -4
  217. data/lib/fog/rackspace/requests/compute_v2/create_image.rb +4 -4
  218. data/lib/fog/rackspace/requests/compute_v2/create_server.rb +11 -5
  219. data/lib/fog/rackspace/requests/compute_v2/delete_attachment.rb +4 -4
  220. data/lib/fog/rackspace/requests/compute_v2/delete_image.rb +5 -4
  221. data/lib/fog/rackspace/requests/compute_v2/delete_metadata_item.rb +4 -4
  222. data/lib/fog/rackspace/requests/compute_v2/delete_server.rb +4 -4
  223. data/lib/fog/rackspace/requests/compute_v2/get_attachment.rb +4 -4
  224. data/lib/fog/rackspace/requests/compute_v2/get_flavor.rb +4 -4
  225. data/lib/fog/rackspace/requests/compute_v2/get_image.rb +4 -4
  226. data/lib/fog/rackspace/requests/compute_v2/get_metadata_item.rb +4 -4
  227. data/lib/fog/rackspace/requests/compute_v2/get_server.rb +4 -4
  228. data/lib/fog/rackspace/requests/compute_v2/list_addresses.rb +4 -4
  229. data/lib/fog/rackspace/requests/compute_v2/list_addresses_by_network.rb +4 -4
  230. data/lib/fog/rackspace/requests/compute_v2/list_attachments.rb +4 -4
  231. data/lib/fog/rackspace/requests/compute_v2/list_flavors.rb +4 -4
  232. data/lib/fog/rackspace/requests/compute_v2/list_images.rb +4 -4
  233. data/lib/fog/rackspace/requests/compute_v2/list_metadata.rb +4 -4
  234. data/lib/fog/rackspace/requests/compute_v2/list_servers.rb +4 -4
  235. data/lib/fog/rackspace/requests/compute_v2/reboot_server.rb +4 -4
  236. data/lib/fog/rackspace/requests/compute_v2/rebuild_server.rb +4 -4
  237. data/lib/fog/rackspace/requests/compute_v2/rescue_server.rb +43 -0
  238. data/lib/fog/rackspace/requests/compute_v2/resize_server.rb +4 -4
  239. data/lib/fog/rackspace/requests/compute_v2/revert_resize_server.rb +4 -4
  240. data/lib/fog/rackspace/requests/compute_v2/set_metadata.rb +4 -4
  241. data/lib/fog/rackspace/requests/compute_v2/set_metadata_item.rb +4 -4
  242. data/lib/fog/rackspace/requests/compute_v2/unrescue_server.rb +40 -0
  243. data/lib/fog/rackspace/requests/compute_v2/update_metadata.rb +4 -4
  244. data/lib/fog/rackspace/requests/compute_v2/update_server.rb +4 -4
  245. data/lib/fog/rackspace/requests/storage/copy_object.rb +4 -4
  246. data/lib/fog/rackspace/requests/storage/delete_container.rb +4 -4
  247. data/lib/fog/rackspace/requests/storage/delete_object.rb +4 -4
  248. data/lib/fog/rackspace/requests/storage/get_container.rb +4 -4
  249. data/lib/fog/rackspace/requests/storage/get_containers.rb +4 -4
  250. data/lib/fog/rackspace/requests/storage/get_object.rb +4 -4
  251. data/lib/fog/rackspace/requests/storage/get_object_https_url.rb +4 -4
  252. data/lib/fog/rackspace/requests/storage/head_container.rb +4 -4
  253. data/lib/fog/rackspace/requests/storage/head_containers.rb +4 -4
  254. data/lib/fog/rackspace/requests/storage/head_object.rb +4 -4
  255. data/lib/fog/rackspace/requests/storage/post_set_meta_temp_url_key.rb +4 -4
  256. data/lib/fog/rackspace/requests/storage/put_container.rb +4 -4
  257. data/lib/fog/rackspace/requests/storage/put_object.rb +4 -4
  258. data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +4 -4
  259. data/lib/fog/rackspace/service.rb +1 -1
  260. data/lib/fog/rackspace/storage.rb +12 -6
  261. data/lib/fog/riakcs.rb +3 -3
  262. data/lib/fog/riakcs/provisioning.rb +1 -3
  263. data/lib/fog/riakcs/requests/provisioning/create_user.rb +2 -2
  264. data/lib/fog/riakcs/requests/provisioning/get_user.rb +1 -1
  265. data/lib/fog/riakcs/requests/provisioning/list_users.rb +1 -1
  266. data/lib/fog/riakcs/requests/usage/get_usage.rb +1 -1
  267. data/lib/fog/riakcs/usage.rb +0 -1
  268. data/lib/fog/version.rb +1 -1
  269. data/lib/fog/vsphere/compute.rb +21 -14
  270. data/lib/fog/vsphere/models/compute/networks.rb +2 -2
  271. data/lib/fog/vsphere/models/compute/server.rb +10 -0
  272. data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -1
  273. data/lib/fog/vsphere/requests/compute/get_template.rb +16 -0
  274. data/lib/fog/vsphere/requests/compute/list_datacenters.rb +1 -1
  275. data/lib/fog/vsphere/requests/compute/list_templates.rb +49 -0
  276. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +9 -6
  277. data/lib/fog/vsphere/requests/compute/vm_clone.rb +41 -27
  278. data/lib/fog/xenserver/CHANGELOG.md +1 -1
  279. data/lib/fog/xenserver/models/compute/network.rb +2 -2
  280. data/lib/tasks/changelog_task.rb +2 -1
  281. data/tests/aws/models/storage/directory_tests.rb +41 -5
  282. data/tests/aws/models/storage/file_tests.rb +1 -2
  283. data/tests/aws/models/storage/files_tests.rb +6 -4
  284. data/tests/aws/models/storage/url_tests.rb +7 -5
  285. data/tests/aws/models/storage/version_tests.rb +2 -2
  286. data/tests/aws/models/storage/versions_tests.rb +5 -5
  287. data/tests/aws/requests/iam/user_tests.rb +10 -8
  288. data/tests/aws/requests/storage/multipart_upload_tests.rb +1 -1
  289. data/tests/aws/requests/storage/object_tests.rb +15 -13
  290. data/tests/brightbox/compute/image_selector_tests.rb +103 -0
  291. data/tests/cloudstack/compute/models/disk_offering_tests.rb +5 -0
  292. data/tests/cloudstack/compute/models/snapshot_tests.rb +5 -20
  293. data/tests/cloudstack/requests/disk_offering_tests.rb +3 -3
  294. data/tests/cloudstack/requests/os_type_tests.rb +2 -3
  295. data/tests/compute/helper.rb +9 -0
  296. data/tests/core/json_tests.rb +62 -0
  297. data/tests/dynect/requests/dns/dns_tests.rb +0 -3
  298. data/tests/google/models/compute/server_tests.rb +24 -0
  299. data/tests/google/requests/compute/disk_tests.rb +88 -0
  300. data/tests/google/requests/compute/firewall_tests.rb +85 -0
  301. data/tests/google/requests/compute/image_tests.rb +80 -0
  302. data/tests/google/requests/compute/network_tests.rb +74 -0
  303. data/tests/google/requests/compute/operation_tests.rb +19 -0
  304. data/tests/google/requests/compute/server_tests.rb +84 -0
  305. data/tests/google/requests/compute/zone_tests.rb +46 -0
  306. data/tests/helpers/mock_helper.rb +4 -0
  307. data/tests/openstack/models/compute/server_tests.rb +91 -1
  308. data/tests/openstack/requests/compute/volume_tests.rb +11 -9
  309. data/tests/openstack/requests/volume/quota_tests.rb +51 -0
  310. data/tests/openstack/version_tests.rb +55 -0
  311. data/tests/rackspace/helper.rb +10 -0
  312. data/tests/rackspace/models/compute_v2/server_tests.rb +26 -1
  313. data/tests/rackspace/requests/compute/image_tests.rb +1 -1
  314. data/tests/rackspace/requests/compute_v2/image_tests.rb +2 -2
  315. data/tests/rackspace/requests/compute_v2/server_tests.rb +13 -0
  316. data/tests/rackspace/requests/dns/dns_tests.rb +1 -1
  317. data/tests/rackspace/requests/dns/records_tests.rb +3 -3
  318. data/tests/vsphere/requests/compute/vm_clone_tests.rb +10 -0
  319. metadata +109 -747
@@ -3,6 +3,7 @@ require 'fog/openstack'
3
3
  module Fog
4
4
  module Network
5
5
  class OpenStack < Fog::Service
6
+ SUPPORTED_VERSIONS = /v2(\.0)*/
6
7
 
7
8
  requires :openstack_auth_url
8
9
  recognizes :openstack_auth_token, :openstack_management_url, :persistent,
@@ -112,8 +113,6 @@ module Fog
112
113
  attr_reader :current_tenant
113
114
 
114
115
  def initialize(options={})
115
- require 'multi_json'
116
-
117
116
  @openstack_auth_token = options[:openstack_auth_token]
118
117
 
119
118
  unless @openstack_auth_token
@@ -168,8 +167,6 @@ module Fog
168
167
  }.merge!(params[:headers] || {}),
169
168
  :host => @host,
170
169
  :path => "#{@path}/#{params[:path]}"#,
171
- # Causes errors for some requests like tenants?limit=1
172
- # :query => ('ignore_awful_caching' << Time.now.to_i.to_s)
173
170
  }))
174
171
  rescue Excon::Errors::Unauthorized => error
175
172
  if error.response.body != 'Bad username or password' # token expiration
@@ -188,7 +185,7 @@ module Fog
188
185
  end
189
186
  end
190
187
  unless response.body.empty?
191
- response.body = MultiJson.decode(response.body)
188
+ response.body = Fog::JSON.decode(response.body)
192
189
  end
193
190
  response
194
191
  end
@@ -225,35 +222,17 @@ module Fog
225
222
  @host = uri.host
226
223
  @path = uri.path
227
224
  @path.sub!(/\/$/, '')
228
- unless @path.match(/^\/v(\d)+(\.)?(\d)*$/)
229
- @path = "/" + retrieve_current_version(uri)
225
+ unless @path.match(SUPPORTED_VERSIONS)
226
+ @path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
227
+ uri,
228
+ @auth_token,
229
+ @connection_options)
230
230
  end
231
231
  @port = uri.port
232
232
  @scheme = uri.scheme
233
233
  true
234
234
  end
235
235
 
236
- def retrieve_current_version(uri)
237
- response = Fog::Connection.new(
238
- "#{uri.scheme}://#{uri.host}:#{uri.port}", false, @connection_options).request({
239
- :expects => [200, 204],
240
- :headers => {'Content-Type' => 'application/json',
241
- 'Accept' => 'application/json',
242
- 'X-Auth-Token' => @auth_token},
243
- :host => uri.host,
244
- :method => 'GET'
245
- })
246
-
247
- body = Fog::JSON.decode(response.body)
248
- version = nil
249
- unless body['versions'].empty?
250
- current_version = body['versions'].detect { |x| x["status"] == "CURRENT" }
251
- version = current_version["id"]
252
- end
253
- raise Errors::NotFound.new('No API versions found') if version.nil?
254
- version
255
- end
256
-
257
236
  end
258
237
  end
259
238
  end
@@ -6,7 +6,7 @@ module Fog
6
6
  def allocate_address(pool = nil)
7
7
 
8
8
  request(
9
- :body => MultiJson.encode({'pool' => pool}),
9
+ :body => Fog::JSON.encode({'pool' => pool}),
10
10
  :expects => [200, 202],
11
11
  :method => 'POST',
12
12
  :path => 'os-floating-ips.json'
@@ -11,7 +11,7 @@ module Fog
11
11
  }
12
12
  }
13
13
  request(
14
- :body => MultiJson.encode(data),
14
+ :body => Fog::JSON.encode(data),
15
15
  :expects => [200, 202],
16
16
  :method => 'POST',
17
17
  :path => "servers/%s/os-volume_attachments" % [server_id]
@@ -21,16 +21,21 @@ module Fog
21
21
  end
22
22
 
23
23
  class Mock
24
+
24
25
  def attach_volume(volume_id, server_id, device)
25
26
  response = Excon::Response.new
26
27
  response.status = 200
27
- response.body ={ "volumeAttachment" => {
28
- "id" => volume_id,
29
- "volumeId" => volume_id
30
- }
31
- }
28
+ data = {
29
+ 'id' => volume_id,
30
+ 'volumeId' => volume_id,
31
+ 'serverId' => server_id,
32
+ 'device' => device
33
+ }
34
+ self.data[:volumes][volume_id]['attachments'] << data
35
+ response.body = { 'volumeAttachment' => data }
32
36
  response
33
37
  end
38
+
34
39
  end
35
40
 
36
41
  end
@@ -29,7 +29,7 @@ module Fog
29
29
  end
30
30
 
31
31
  request(
32
- :body => MultiJson.encode(data),
32
+ :body => Fog::JSON.encode(data),
33
33
  :expects => [200, 202],
34
34
  :method => 'POST',
35
35
  :path => '/os-volumes_boot.json'
@@ -35,7 +35,7 @@ module Fog
35
35
  }
36
36
 
37
37
  request(
38
- :body => MultiJson.encode(data),
38
+ :body => Fog::JSON.encode(data),
39
39
  :expects => 200,
40
40
  :method => 'POST',
41
41
  :path => 'flavors'
@@ -14,7 +14,7 @@ module Fog
14
14
  data['keypair']['public_key'] = public_key unless public_key.nil?
15
15
 
16
16
  request(
17
- :body => MultiJson.encode(data),
17
+ :body => Fog::JSON.encode(data),
18
18
  :expects => 200,
19
19
  :method => 'POST',
20
20
  :path => 'os-keypairs.json'
@@ -12,7 +12,7 @@ module Fog
12
12
  }
13
13
 
14
14
  request(
15
- :body => MultiJson.encode(data),
15
+ :body => Fog::JSON.encode(data),
16
16
  :expects => 200,
17
17
  :method => 'POST',
18
18
  :path => 'os-security-groups.json'
@@ -18,7 +18,7 @@ module Fog
18
18
  request(
19
19
  :expects => 200,
20
20
  :method => 'POST',
21
- :body => MultiJson.encode(data),
21
+ :body => Fog::JSON.encode(data),
22
22
  :path => 'os-security-group-rules.json'
23
23
  )
24
24
  end
@@ -17,7 +17,7 @@ module Fog
17
17
  data['volume'][key] = options[key]
18
18
  end
19
19
  request(
20
- :body => MultiJson.encode(data),
20
+ :body => Fog::JSON.encode(data),
21
21
  :expects => [200, 202],
22
22
  :method => 'POST',
23
23
  :path => "os-volumes"
@@ -31,22 +31,23 @@ module Fog
31
31
  def create_volume(name, description, size, options={})
32
32
  response = Excon::Response.new
33
33
  response.status = 202
34
- response.body = {
35
- 'volume' => {
36
- 'id' => Fog::Mock.random_numbers(2),
37
- 'display_name' => name,
38
- 'display_description' => description,
39
- 'size' => size,
40
- 'status' => 'creating',
41
- 'snapshot_id' => '4',
42
- 'volume_type' => nil,
43
- 'availability_zone' => 'nova',
44
- 'created_at' => Time.now,
45
- 'attachments' => []
46
- }
34
+ data = {
35
+ 'id' => Fog::Mock.random_numbers(2),
36
+ 'name' => name,
37
+ 'description' => description,
38
+ 'size' => size,
39
+ 'status' => 'creating',
40
+ 'snapshot_id' => '4',
41
+ 'volume_type' => nil,
42
+ 'availability_zone' => 'nova',
43
+ 'created_at' => Time.now,
44
+ 'attachments' => []
47
45
  }
46
+ self.data[:volumes][data['id']] = data
47
+ response.body = { 'volume' => data }
48
48
  response
49
49
  end
50
+
50
51
  end
51
52
 
52
53
  end
@@ -14,7 +14,7 @@ module Fog
14
14
  }
15
15
 
16
16
  request(
17
- :body => MultiJson.encode(data),
17
+ :body => Fog::JSON.encode(data),
18
18
  :expects => [200, 202],
19
19
  :method => 'POST',
20
20
  :path => "os-snapshots"
@@ -14,11 +14,18 @@ module Fog
14
14
  end
15
15
 
16
16
  class Mock
17
+
17
18
  def delete_volume(volume_id)
18
19
  response = Excon::Response.new
19
- response.status = 204
20
- response
20
+ if list_volumes.body['volumes'].map { |v| v['id'] }.include? volume_id
21
+ self.data[:volumes].delete(volume_id)
22
+ response.status = 204
23
+ response
24
+ else
25
+ raise Fog::Compute::OpenStack::NotFound
26
+ end
21
27
  end
28
+
22
29
  end
23
30
 
24
31
  end
@@ -14,10 +14,15 @@ module Fog
14
14
  end
15
15
 
16
16
  class Mock
17
+
17
18
  def detach_volume(server_id, attachment_id)
18
19
  response = Excon::Response.new
19
- response.status = 202
20
- response
20
+ if self.data[:volumes][attachment_id]['attachments'].reject! { |attachment| attachment['serverId'] == server_id }
21
+ response.status = 202
22
+ response
23
+ else
24
+ raise Fog::Compute::OpenStack::NotFound
25
+ end
21
26
  end
22
27
  end
23
28
 
@@ -16,6 +16,16 @@ module Fog
16
16
 
17
17
  class Mock
18
18
 
19
+ def get_server_volumes(server_id)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ data = self.data[:volumes].values.find_all do |vol|
23
+ vol['attachments'].find { |attachment| attachment["serverId"] == server_id }
24
+ end
25
+ response.body = { 'volumeAttachments' => data.collect! { |vol| vol['attachments'] }.flatten(1) }
26
+ response
27
+ end
28
+
19
29
  end
20
30
 
21
31
  end
@@ -18,22 +18,13 @@ module Fog
18
18
 
19
19
  def get_volume_details(volume_id)
20
20
  response = Excon::Response.new
21
- response.status = 200
22
- response.body = {
23
- 'volume' => {
24
- 'id' => '1',
25
- 'display_name' => Fog::Mock.random_letters(rand(8) + 5),
26
- 'display_description' => Fog::Mock.random_letters(rand(12) + 10),
27
- 'size' => 3,
28
- 'volume_type' => nil,
29
- 'snapshot_id' => '4',
30
- 'status' => 'online',
31
- 'availability_zone' => 'nova',
32
- 'created_at' => Time.now,
33
- 'attachments' => []
34
- }
35
- }
36
- response
21
+ if data = self.data[:volumes][volume_id]
22
+ response.status = 200
23
+ response.body = { 'volume' => data }
24
+ response
25
+ else
26
+ raise Fog::Compute::OpenStack::NotFound
27
+ end
37
28
  end
38
29
  end
39
30
 
@@ -11,7 +11,7 @@ module Fog
11
11
  :method => 'GET',
12
12
  :path => '/v2.0/tenants'
13
13
  })
14
- response.body = MultiJson.decode(response.body)
14
+ response.body = Fog::JSON.decode(response.body)
15
15
  response
16
16
  end
17
17
  end
@@ -17,32 +17,10 @@ module Fog
17
17
  class Mock
18
18
 
19
19
  def list_volumes(detailed=true)
20
- response = Excon::Response.new
21
- response.status = 200
22
- self.data[:volumes] ||= [
23
- { "status" => "available",
24
- "display_description" => "",
25
- "availability_zone" => "nova",
26
- "display_name" => "test 1",
27
- "attachments" => [{}],
28
- "volume_type" => nil,
29
- "snapshot_id" => nil,
30
- "size" => 1,
31
- "id" => Fog::Mock.random_hex(32),
32
- "created_at" => Time.now },
33
- { "status" => "available",
34
- "display_description" => "",
35
- "availability_zone" => "nova",
36
- "display_name" => "test 2",
37
- "attachments" => [{}],
38
- "volume_type" => nil,
39
- "snapshot_id" => nil,
40
- "size" => 1,
41
- "id" => Fog::Mock.random_hex(32),
42
- "created_at" => Time.now }
43
- ]
44
- response.body = { 'volumes' => self.data[:volumes] }
45
- response
20
+ Excon::Response.new(
21
+ :body => { 'volumes' => self.data[:volumes].values },
22
+ :status => 200
23
+ )
46
24
  end
47
25
  end
48
26
 
@@ -3,7 +3,7 @@ module Fog
3
3
  class OpenStack
4
4
  class Real
5
5
 
6
- def revert_resized_server(server_id)
6
+ def revert_resize_server(server_id)
7
7
  body = { 'revertResize' => nil }
8
8
  server_action(server_id, body)
9
9
  end
@@ -12,7 +12,7 @@ module Fog
12
12
 
13
13
  class Mock
14
14
 
15
- def revert_resized_server(server_id)
15
+ def revert_resize_server(server_id)
16
16
  response = Excon::Response.new
17
17
  response.status = 202
18
18
 
@@ -6,7 +6,7 @@ module Fog
6
6
  def update_quota(tenant_id, options = {})
7
7
  options['tenant_id'] = tenant_id
8
8
  request(
9
- :body => MultiJson.encode({ 'quota_set' => options }),
9
+ :body => Fog::JSON.encode({ 'quota_set' => options }),
10
10
  :expects => 200,
11
11
  :method => 'PUT',
12
12
  :path => "/os-quota-sets/#{tenant_id}"
@@ -26,7 +26,7 @@ module Fog
26
26
  data = { 'tenant_id' => tenant_id }
27
27
 
28
28
  request(
29
- :body => MultiJson.encode(data),
29
+ :body => Fog::JSON.encode(data),
30
30
  :expects => [200, 202],
31
31
  :method => 'POST',
32
32
  :path => "users/#{user_id}/credentials/OS-EC2"
@@ -10,7 +10,7 @@ module Fog
10
10
  }
11
11
 
12
12
  request(
13
- :body => MultiJson.encode(data),
13
+ :body => Fog::JSON.encode(data),
14
14
  :expects => [200, 202],
15
15
  :method => 'POST',
16
16
  :path => '/OS-KSADM/roles'
@@ -15,7 +15,7 @@ module Fog
15
15
  }
16
16
 
17
17
  request(
18
- :body => MultiJson.encode(data),
18
+ :body => Fog::JSON.encode(data),
19
19
  :expects => [200, 202],
20
20
  :method => 'POST',
21
21
  :path => '/users'
@@ -6,7 +6,7 @@ module Fog
6
6
  def update_user(user_id, options = {})
7
7
  url = options.delete('url') || "/users/#{user_id}"
8
8
  request(
9
- :body => MultiJson.encode({ 'user' => options }),
9
+ :body => Fog::JSON.encode({ 'user' => options }),
10
10
  :expects => 200,
11
11
  :method => 'PUT',
12
12
  :path => url
@@ -11,7 +11,7 @@ module Fog
11
11
  data = { 'memberships' => members }
12
12
 
13
13
  request(
14
- :body => MultiJson.encode(data),
14
+ :body => Fog::JSON.encode(data),
15
15
  :expects => [200, 202],
16
16
  :method => 'PUT',
17
17
  :path => "images/#{image_id}/members"
@@ -17,7 +17,7 @@ module Fog
17
17
  data['volume'][key] = options[key]
18
18
  end
19
19
  request(
20
- :body => MultiJson.encode(data),
20
+ :body => Fog::JSON.encode(data),
21
21
  :expects => [200, 202],
22
22
  :method => 'POST',
23
23
  :path => "volumes"