fog 1.24.0 → 1.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +184 -1
  3. data/CONTRIBUTORS.md +23 -0
  4. data/README.md +17 -9
  5. data/Rakefile +4 -0
  6. data/fog.gemspec +18 -6
  7. data/lib/fog.rb +1 -1
  8. data/lib/fog/aws/auto_scaling.rb +12 -12
  9. data/lib/fog/aws/beanstalk.rb +12 -10
  10. data/lib/fog/aws/cdn.rb +0 -1
  11. data/lib/fog/aws/cloud_formation.rb +13 -11
  12. data/lib/fog/aws/cloud_watch.rb +14 -11
  13. data/lib/fog/aws/compute.rb +19 -19
  14. data/lib/fog/aws/core.rb +21 -0
  15. data/lib/fog/aws/dns.rb +0 -1
  16. data/lib/fog/aws/elasticache.rb +13 -9
  17. data/lib/fog/aws/elb.rb +23 -14
  18. data/lib/fog/aws/emr.rb +11 -9
  19. data/lib/fog/aws/iam.rb +14 -11
  20. data/lib/fog/aws/models/compute/security_group.rb +41 -0
  21. data/lib/fog/aws/models/elb/load_balancer.rb +31 -0
  22. data/lib/fog/aws/models/glacier/archive.rb +3 -1
  23. data/lib/fog/aws/models/iam/role.rb +1 -1
  24. data/lib/fog/aws/models/iam/roles.rb +1 -1
  25. data/lib/fog/aws/models/storage/file.rb +1 -1
  26. data/lib/fog/aws/parsers/compute/describe_security_groups.rb +68 -53
  27. data/lib/fog/aws/parsers/elb/describe_load_balancer_attributes.rb +7 -0
  28. data/lib/fog/aws/parsers/elb/describe_tags.rb +26 -0
  29. data/lib/fog/aws/parsers/elb/tag_list_parser.rb +57 -0
  30. data/lib/fog/aws/parsers/storage/get_bucket_website.rb +5 -1
  31. data/lib/fog/aws/rds.rb +13 -11
  32. data/lib/fog/aws/region_methods.rb +1 -1
  33. data/lib/fog/aws/requests/dynamodb/put_item.rb +1 -1
  34. data/lib/fog/aws/requests/elb/add_tags.rb +46 -0
  35. data/lib/fog/aws/requests/elb/create_load_balancer.rb +4 -1
  36. data/lib/fog/aws/requests/elb/describe_load_balancer_attributes.rb +3 -0
  37. data/lib/fog/aws/requests/elb/describe_tags.rb +56 -0
  38. data/lib/fog/aws/requests/elb/modify_load_balancer_attributes.rb +9 -3
  39. data/lib/fog/aws/requests/elb/remove_tags.rb +46 -0
  40. data/lib/fog/aws/requests/storage/copy_object.rb +1 -1
  41. data/lib/fog/aws/requests/storage/delete_object.rb +4 -3
  42. data/lib/fog/aws/requests/storage/post_object_hidden_fields.rb +23 -5
  43. data/lib/fog/aws/requests/storage/post_object_restore.rb +1 -1
  44. data/lib/fog/aws/requests/storage/put_bucket_website.rb +46 -18
  45. data/lib/fog/aws/ses.rb +1 -2
  46. data/lib/fog/aws/signaturev4.rb +62 -15
  47. data/lib/fog/aws/simpledb.rb +0 -1
  48. data/lib/fog/aws/sns.rb +12 -9
  49. data/lib/fog/aws/sqs.rb +14 -10
  50. data/lib/fog/aws/storage.rb +102 -78
  51. data/lib/fog/aws/sts.rb +10 -9
  52. data/lib/fog/bare_metal_cloud/compute.rb +0 -1
  53. data/lib/fog/bin.rb +1 -0
  54. data/lib/fog/bin/brightbox.rb +3 -1
  55. data/lib/fog/bin/rackspace.rb +4 -0
  56. data/lib/fog/bluebox/models/compute/server.rb +1 -0
  57. data/lib/fog/cloudstack/models/compute/server.rb +12 -1
  58. data/lib/fog/cloudstack/models/compute/snapshots.rb +3 -2
  59. data/lib/fog/cloudstack/models/compute/volume.rb +5 -0
  60. data/lib/fog/cloudstack/models/compute/volumes.rb +3 -2
  61. data/lib/fog/core/parser.rb +2 -112
  62. data/lib/fog/dnsmadeeasy/dns.rb +0 -1
  63. data/lib/fog/dynect/core.rb +0 -1
  64. data/lib/fog/dynect/dns.rb +11 -3
  65. data/lib/fog/ecloud/compute.rb +0 -1
  66. data/lib/fog/ecloud/core.rb +1 -1
  67. data/lib/fog/fogdocker/compute.rb +4 -1
  68. data/lib/fog/fogdocker/core.rb +1 -7
  69. data/lib/fog/fogdocker/errors.rb +9 -0
  70. data/lib/fog/fogdocker/models/compute/images.rb +4 -0
  71. data/lib/fog/fogdocker/models/compute/server.rb +18 -1
  72. data/lib/fog/fogdocker/requests/compute/container_action.rb +53 -3
  73. data/lib/fog/fogdocker/requests/compute/container_get.rb +31 -12
  74. data/lib/fog/fogdocker/requests/compute/image_search.rb +29 -0
  75. data/lib/fog/google/dns.rb +46 -12
  76. data/lib/fog/google/examples/dns/project.rb +8 -0
  77. data/lib/fog/google/examples/dns/zones.rb +43 -0
  78. data/lib/fog/google/models/compute/images.rb +2 -1
  79. data/lib/fog/google/models/dns/change.rb +40 -0
  80. data/lib/fog/google/models/dns/changes.rb +52 -0
  81. data/lib/fog/google/models/dns/project.rb +75 -0
  82. data/lib/fog/google/models/dns/projects.rb +25 -0
  83. data/lib/fog/google/models/dns/record.rb +112 -0
  84. data/lib/fog/google/models/dns/records.rb +52 -0
  85. data/lib/fog/google/models/dns/zone.rb +74 -0
  86. data/lib/fog/google/models/dns/zones.rb +34 -0
  87. data/lib/fog/google/models/storage/file.rb +1 -1
  88. data/lib/fog/google/models/storage/files.rb +1 -5
  89. data/lib/fog/google/requests/dns/create_change.rb +64 -0
  90. data/lib/fog/google/requests/dns/create_managed_zone.rb +64 -31
  91. data/lib/fog/google/requests/dns/delete_managed_zone.rb +20 -24
  92. data/lib/fog/google/requests/dns/get_change.rb +42 -0
  93. data/lib/fog/google/requests/dns/get_managed_zone.rb +22 -16
  94. data/lib/fog/google/requests/dns/get_project.rb +42 -0
  95. data/lib/fog/google/requests/dns/list_changes.rb +41 -0
  96. data/lib/fog/google/requests/dns/list_managed_zones.rb +15 -10
  97. data/lib/fog/google/requests/dns/list_resource_record_sets.rb +50 -0
  98. data/lib/fog/google/storage.rb +0 -1
  99. data/lib/fog/hp/storage.rb +1 -1
  100. data/lib/fog/internet_archive/storage.rb +0 -1
  101. data/lib/fog/libvirt/models/compute/server.rb +17 -7
  102. data/lib/fog/opennebula/models/compute/flavor.rb +46 -8
  103. data/lib/fog/opennebula/models/compute/flavors.rb +7 -0
  104. data/lib/fog/opennebula/models/compute/interface.rb +1 -1
  105. data/lib/fog/opennebula/models/compute/network.rb +1 -0
  106. data/lib/fog/opennebula/models/compute/networks.rb +5 -1
  107. data/lib/fog/opennebula/requests/compute/list_networks.rb +34 -25
  108. data/lib/fog/opennebula/requests/compute/template_pool.rb +47 -5
  109. data/lib/fog/openstack/compute.rb +2 -2
  110. data/lib/fog/openstack/docs/storage.md +18 -0
  111. data/lib/fog/openstack/identity.rb +1 -1
  112. data/lib/fog/openstack/image.rb +1 -1
  113. data/lib/fog/openstack/metering.rb +1 -1
  114. data/lib/fog/openstack/models/compute/server.rb +1 -0
  115. data/lib/fog/openstack/models/storage/directory.rb +8 -2
  116. data/lib/fog/openstack/network.rb +1 -1
  117. data/lib/fog/openstack/orchestration.rb +1 -1
  118. data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
  119. data/lib/fog/openstack/requests/storage/public_url.rb +28 -0
  120. data/lib/fog/openstack/requests/storage/put_container.rb +1 -0
  121. data/lib/fog/openstack/storage.rb +1 -0
  122. data/lib/fog/openstack/volume.rb +1 -1
  123. data/lib/fog/ovirt/compute.rb +1 -0
  124. data/lib/fog/ovirt/models/compute/server.rb +5 -0
  125. data/lib/fog/ovirt/requests/compute/update_volume.rb +39 -0
  126. data/lib/fog/rackspace.rb +1 -0
  127. data/lib/fog/rackspace/core.rb +1 -0
  128. data/lib/fog/rackspace/docs/networking.md +315 -0
  129. data/lib/fog/rackspace/mock_data.rb +1 -2
  130. data/lib/fog/rackspace/models/dns/zones.rb +2 -1
  131. data/lib/fog/rackspace/models/load_balancers/node.rb +7 -0
  132. data/lib/fog/rackspace/models/networking/network.rb +27 -0
  133. data/lib/fog/rackspace/models/networking/networks.rb +23 -0
  134. data/lib/fog/rackspace/models/networking/virtual_interface.rb +85 -0
  135. data/lib/fog/rackspace/models/networking/virtual_interfaces.rb +45 -0
  136. data/lib/fog/rackspace/models/queues/queue.rb +1 -1
  137. data/lib/fog/rackspace/networking.rb +192 -0
  138. data/lib/fog/rackspace/requests/load_balancers/create_node.rb +3 -0
  139. data/lib/fog/rackspace/requests/load_balancers/update_node.rb +3 -0
  140. data/lib/fog/rackspace/requests/networking/create_network.rb +36 -0
  141. data/lib/fog/rackspace/requests/networking/create_virtual_interface.rb +30 -0
  142. data/lib/fog/rackspace/requests/networking/delete_network.rb +21 -0
  143. data/lib/fog/rackspace/requests/networking/delete_virtual_interface.rb +23 -0
  144. data/lib/fog/rackspace/requests/networking/get_network.rb +21 -0
  145. data/lib/fog/rackspace/requests/networking/list_networks.rb +18 -0
  146. data/lib/fog/rackspace/requests/networking/list_virtual_interfaces.rb +22 -0
  147. data/lib/fog/vcloud/compute.rb +0 -1
  148. data/lib/fog/vcloud/core.rb +1 -0
  149. data/lib/fog/vcloud_director/compute.rb +1 -1
  150. data/lib/fog/version.rb +1 -1
  151. data/lib/fog/vsphere/compute.rb +38 -1
  152. data/lib/fog/vsphere/requests/compute/list_clusters.rb +31 -1
  153. data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +1 -1
  154. data/lib/fog/zerigo/dns.rb +0 -1
  155. data/lib/tasks/changelog_task.rb +1 -0
  156. data/tests/aws/models/elb/model_tests.rb +6 -0
  157. data/tests/aws/models/elb/tagging_tests.rb +15 -0
  158. data/tests/aws/models/iam/access_keys_tests.rb +1 -1
  159. data/tests/aws/models/iam/policies_tests.rb +2 -1
  160. data/tests/aws/models/iam/users_tests.rb +7 -4
  161. data/tests/aws/models/storage/url_tests.rb +5 -9
  162. data/tests/aws/requests/compute/tag_tests.rb +2 -0
  163. data/tests/aws/requests/elb/load_balancer_tests.rb +5 -1
  164. data/tests/aws/requests/storage/bucket_tests.rb +15 -1
  165. data/tests/aws/signaturev4_tests.rb +47 -0
  166. data/tests/bluebox/requests/compute/block_tests.rb +2 -1
  167. data/tests/compute/helper.rb +0 -10
  168. data/tests/compute/models/flavors_tests.rb +1 -1
  169. data/tests/fogdocker/compute_tests.rb +1 -1
  170. data/tests/fogdocker/models/compute/server_tests.rb +13 -3
  171. data/tests/fogdocker/requests/compute/container_action_tests.rb +19 -8
  172. data/tests/fogdocker/requests/compute/image_search_tests.rb +11 -0
  173. data/tests/google/models/dns/change_tests.rb +28 -0
  174. data/tests/google/models/dns/changes_tests.rb +36 -0
  175. data/tests/google/models/dns/projects_tests.rb +12 -0
  176. data/tests/google/models/dns/record_tests.rb +42 -0
  177. data/tests/google/models/dns/records_tests.rb +36 -0
  178. data/tests/google/models/dns/zone_tests.rb +28 -0
  179. data/tests/google/models/dns/zones_tests.rb +14 -0
  180. data/tests/google/requests/dns/change_tests.rb +86 -0
  181. data/tests/google/requests/dns/managed_zone_tests.rb +1 -1
  182. data/tests/google/requests/dns/project_tests.rb +29 -0
  183. data/tests/google/requests/dns/record_tests.rb +49 -0
  184. data/tests/helper.rb +1 -1
  185. data/tests/helpers/mock_helper.rb +2 -2
  186. data/tests/opennebula/models/compute/flavor_tests.rb +29 -0
  187. data/tests/opennebula/models/compute/flavors_tests.rb +17 -0
  188. data/tests/opennebula/models/compute/network_tests.rb +2 -2
  189. data/tests/opennebula/models/compute/networks_tests.rb +2 -0
  190. data/tests/openstack/requests/storage/object_tests.rb +10 -0
  191. data/tests/ovirt/compute_tests.rb +1 -1
  192. data/tests/ovirt/requests/compute/update_volume_tests.rb +20 -0
  193. data/tests/rackspace/models/networking/network_tests.rb +10 -0
  194. data/tests/rackspace/models/networking/networks_tests.rb +10 -0
  195. data/tests/rackspace/models/networking/virtual_interface_tests.rb +33 -0
  196. data/tests/rackspace/models/networking/virtual_interfaces_tests.rb +24 -0
  197. data/tests/rackspace/models/queues/queue_tests.rb +9 -0
  198. data/tests/rackspace/networking_tests.rb +118 -0
  199. data/tests/rackspace/requests/networking/network_tests.rb +49 -0
  200. data/tests/rackspace/requests/networking/virtual_interface_tests.rb +49 -0
  201. data/tests/vsphere/requests/compute/list_clusters_tests.rb +11 -0
  202. metadata +228 -180
  203. data/lib/fog/bin/terremark.rb +0 -29
  204. data/lib/fog/bin/vmfusion.rb +0 -58
  205. data/lib/fog/bin/voxel.rb +0 -29
  206. data/lib/fog/terremark.rb +0 -11
  207. data/lib/fog/terremark/models/shared/address.rb +0 -25
  208. data/lib/fog/terremark/models/shared/addresses.rb +0 -45
  209. data/lib/fog/terremark/models/shared/image.rb +0 -19
  210. data/lib/fog/terremark/models/shared/images.rb +0 -41
  211. data/lib/fog/terremark/models/shared/internetservice.rb +0 -66
  212. data/lib/fog/terremark/models/shared/internetservices.rb +0 -39
  213. data/lib/fog/terremark/models/shared/network.rb +0 -31
  214. data/lib/fog/terremark/models/shared/networks.rb +0 -48
  215. data/lib/fog/terremark/models/shared/nodeservice.rb +0 -50
  216. data/lib/fog/terremark/models/shared/nodeservices.rb +0 -29
  217. data/lib/fog/terremark/models/shared/server.rb +0 -210
  218. data/lib/fog/terremark/models/shared/servers.rb +0 -50
  219. data/lib/fog/terremark/models/shared/task.rb +0 -46
  220. data/lib/fog/terremark/models/shared/tasks.rb +0 -54
  221. data/lib/fog/terremark/models/shared/vdc.rb +0 -40
  222. data/lib/fog/terremark/models/shared/vdcs.rb +0 -48
  223. data/lib/fog/terremark/parser.rb +0 -18
  224. data/lib/fog/terremark/parsers/shared/get_catalog.rb +0 -33
  225. data/lib/fog/terremark/parsers/shared/get_catalog_item.rb +0 -32
  226. data/lib/fog/terremark/parsers/shared/get_internet_services.rb +0 -57
  227. data/lib/fog/terremark/parsers/shared/get_keys_list.rb +0 -39
  228. data/lib/fog/terremark/parsers/shared/get_network_ips.rb +0 -24
  229. data/lib/fog/terremark/parsers/shared/get_node_services.rb +0 -32
  230. data/lib/fog/terremark/parsers/shared/get_organization.rb +0 -50
  231. data/lib/fog/terremark/parsers/shared/get_organizations.rb +0 -31
  232. data/lib/fog/terremark/parsers/shared/get_public_ips.rb +0 -26
  233. data/lib/fog/terremark/parsers/shared/get_tasks_list.rb +0 -35
  234. data/lib/fog/terremark/parsers/shared/get_vapp_template.rb +0 -31
  235. data/lib/fog/terremark/parsers/shared/get_vdc.rb +0 -87
  236. data/lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb +0 -26
  237. data/lib/fog/terremark/parsers/shared/internet_service.rb +0 -58
  238. data/lib/fog/terremark/parsers/shared/network.rb +0 -39
  239. data/lib/fog/terremark/parsers/shared/node_service.rb +0 -28
  240. data/lib/fog/terremark/parsers/shared/public_ip.rb +0 -22
  241. data/lib/fog/terremark/parsers/shared/task.rb +0 -25
  242. data/lib/fog/terremark/parsers/shared/vapp.rb +0 -61
  243. data/lib/fog/terremark/requests/shared/add_internet_service.rb +0 -54
  244. data/lib/fog/terremark/requests/shared/add_node_service.rb +0 -51
  245. data/lib/fog/terremark/requests/shared/configure_vapp.rb +0 -59
  246. data/lib/fog/terremark/requests/shared/create_internet_service.rb +0 -59
  247. data/lib/fog/terremark/requests/shared/delete_internet_service.rb +0 -21
  248. data/lib/fog/terremark/requests/shared/delete_node_service.rb +0 -21
  249. data/lib/fog/terremark/requests/shared/delete_public_ip.rb +0 -21
  250. data/lib/fog/terremark/requests/shared/delete_vapp.rb +0 -20
  251. data/lib/fog/terremark/requests/shared/deploy_vapp.rb +0 -33
  252. data/lib/fog/terremark/requests/shared/get_catalog.rb +0 -30
  253. data/lib/fog/terremark/requests/shared/get_catalog_item.rb +0 -33
  254. data/lib/fog/terremark/requests/shared/get_internet_services.rb +0 -34
  255. data/lib/fog/terremark/requests/shared/get_keys_list.rb +0 -34
  256. data/lib/fog/terremark/requests/shared/get_network.rb +0 -69
  257. data/lib/fog/terremark/requests/shared/get_network_ips.rb +0 -29
  258. data/lib/fog/terremark/requests/shared/get_node_services.rb +0 -29
  259. data/lib/fog/terremark/requests/shared/get_organization.rb +0 -82
  260. data/lib/fog/terremark/requests/shared/get_organizations.rb +0 -45
  261. data/lib/fog/terremark/requests/shared/get_public_ip.rb +0 -31
  262. data/lib/fog/terremark/requests/shared/get_public_ips.rb +0 -68
  263. data/lib/fog/terremark/requests/shared/get_task.rb +0 -37
  264. data/lib/fog/terremark/requests/shared/get_tasks_list.rb +0 -30
  265. data/lib/fog/terremark/requests/shared/get_vapp.rb +0 -40
  266. data/lib/fog/terremark/requests/shared/get_vapp_template.rb +0 -33
  267. data/lib/fog/terremark/requests/shared/get_vdc.rb +0 -121
  268. data/lib/fog/terremark/requests/shared/instantiate_vapp_template.rb +0 -79
  269. data/lib/fog/terremark/requests/shared/power_off.rb +0 -33
  270. data/lib/fog/terremark/requests/shared/power_on.rb +0 -33
  271. data/lib/fog/terremark/requests/shared/power_reset.rb +0 -33
  272. data/lib/fog/terremark/requests/shared/power_shutdown.rb +0 -22
  273. data/lib/fog/terremark/shared.rb +0 -304
  274. data/lib/fog/terremark/vcloud.rb +0 -129
  275. data/lib/fog/vmfusion.rb +0 -1
  276. data/lib/fog/vmfusion/compute.rb +0 -28
  277. data/lib/fog/vmfusion/core.rb +0 -9
  278. data/lib/fog/vmfusion/models/compute/server.rb +0 -256
  279. data/lib/fog/vmfusion/models/compute/servers.rb +0 -36
  280. data/lib/fog/voxel.rb +0 -1
  281. data/lib/fog/voxel/compute.rb +0 -122
  282. data/lib/fog/voxel/core.rb +0 -16
  283. data/lib/fog/voxel/models/compute/image.rb +0 -13
  284. data/lib/fog/voxel/models/compute/images.rb +0 -27
  285. data/lib/fog/voxel/models/compute/server.rb +0 -73
  286. data/lib/fog/voxel/models/compute/servers.rb +0 -29
  287. data/lib/fog/voxel/parsers/compute/basic.rb +0 -27
  288. data/lib/fog/voxel/parsers/compute/devices_list.rb +0 -107
  289. data/lib/fog/voxel/parsers/compute/images_list.rb +0 -55
  290. data/lib/fog/voxel/parsers/compute/voxcloud_create.rb +0 -36
  291. data/lib/fog/voxel/parsers/compute/voxcloud_delete.rb +0 -27
  292. data/lib/fog/voxel/parsers/compute/voxcloud_status.rb +0 -42
  293. data/lib/fog/voxel/requests/compute/devices_list.rb +0 -22
  294. data/lib/fog/voxel/requests/compute/devices_power.rb +0 -20
  295. data/lib/fog/voxel/requests/compute/images_list.rb +0 -29
  296. data/lib/fog/voxel/requests/compute/voxcloud_create.rb +0 -20
  297. data/lib/fog/voxel/requests/compute/voxcloud_delete.rb +0 -18
  298. data/lib/fog/voxel/requests/compute/voxcloud_status.rb +0 -22
  299. data/lib/fog/xml.rb +0 -4
  300. data/lib/fog/xml/connection.rb +0 -24
  301. data/lib/fog/xml/sax_parser_connection.rb +0 -45
  302. data/tests/core/connection_tests.rb +0 -26
  303. data/tests/voxel/requests/compute/image_tests.rb +0 -52
  304. data/tests/voxel/requests/compute/server_tests.rb +0 -123
@@ -0,0 +1,45 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/rackspace/models/networking/virtual_interface'
3
+ require 'fog/rackspace/models/compute_v2/server'
4
+
5
+ module Fog
6
+ module Rackspace
7
+ class Networking
8
+ class VirtualInterfaces < Fog::Collection
9
+ model Fog::Rackspace::Networking::VirtualInterface
10
+
11
+ # Returns list of virtual interfaces for a server
12
+ # @return [Fog::Rackspace::Networking::Servers] Retrieves a list virtual interfaces for server.
13
+ # @raise [Fog::Rackspace::Networking::NotFound] - HTTP 404
14
+ # @raise [Fog::Rackspace::Networking::BadRequest] - HTTP 400
15
+ # @raise [Fog::Rackspace::Networking::InternalServerError] - HTTP 500
16
+ # @raise [Fog::Rackspace::Networking::ServiceError]
17
+ # @note Fog's current implementation only returns 1000 servers
18
+ # @note The filter parameter on the method is just to maintain compatability with other providers that support filtering.
19
+ # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Servers-d1e2078.html
20
+ # @see Fog::Rackspace::Networking::Server#virtual_interfaces
21
+ def all(options={})
22
+ server = server(options[:server])
23
+ data = service.list_virtual_interfaces(server.id).body['virtual_interfaces']
24
+ objects = load(data)
25
+ objects.each{ |obj| obj.attributes[:server] = server }
26
+ objects
27
+ end
28
+
29
+ private
30
+
31
+ def server(obj)
32
+ server = case obj.class.to_s
33
+ when "Fog::Compute::RackspaceV2::Server" then obj
34
+ when "String" then Fog::Compute::RackspaceV2::Server.new(:id => obj, :service => service)
35
+ else raise "Please pass in :server (either id or Fog::Compute::RackspaceV2::Server)"
36
+ end
37
+
38
+ raise "Server (#{server}) not found" unless server.present?
39
+
40
+ server
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -91,7 +91,7 @@ module Fog
91
91
 
92
92
  if claim
93
93
  message = claim.messages.first
94
- yield message
94
+ yield message if block_given?
95
95
  message.destroy
96
96
  true
97
97
  else
@@ -0,0 +1,192 @@
1
+ require 'fog/rackspace/core'
2
+
3
+ module Fog
4
+ module Rackspace
5
+ class Networking < Fog::Service
6
+ include Fog::Rackspace::Errors
7
+
8
+ class ServiceError < Fog::Rackspace::Errors::ServiceError; end
9
+ class InternalServerError < Fog::Rackspace::Errors::InternalServerError; end
10
+ class BadRequest < Fog::Rackspace::Errors::BadRequest; end
11
+
12
+ class InvalidStateException < ::RuntimeError
13
+ attr_reader :desired_state
14
+ attr_reader :current_state
15
+
16
+ def initialize(desired_state, current_state)
17
+ @desired_state = desired_state
18
+ @current_state = current_state
19
+ end
20
+ end
21
+
22
+ class InvalidServerStateException < InvalidStateException
23
+ def to_s
24
+ "Server should have transitioned to '#{desired_state}' not '#{current_state}'"
25
+ end
26
+ end
27
+
28
+ class InvalidImageStateException < InvalidStateException
29
+ def to_s
30
+ "Image should have transitioned to '#{desired_state}' not '#{current_state}'"
31
+ end
32
+ end
33
+
34
+ DFW_ENDPOINT = 'https://dfw.servers.api.rackspacecloud.com/v2'
35
+ ORD_ENDPOINT = 'https://ord.servers.api.rackspacecloud.com/v2'
36
+ LON_ENDPOINT = 'https://lon.servers.api.rackspacecloud.com/v2'
37
+
38
+ requires :rackspace_username, :rackspace_api_key
39
+ recognizes :rackspace_endpoint
40
+ recognizes :rackspace_auth_url
41
+ recognizes :rackspace_auth_token
42
+ recognizes :rackspace_region
43
+ recognizes :rackspace_compute_url
44
+
45
+ model_path 'fog/rackspace/models/networking'
46
+
47
+ model :network
48
+ collection :networks
49
+
50
+ model :virtual_interface
51
+ collection :virtual_interfaces
52
+
53
+ request_path 'fog/rackspace/requests/networking'
54
+ request :list_networks
55
+ request :get_network
56
+ request :create_network
57
+ request :delete_network
58
+
59
+ request :list_virtual_interfaces
60
+ request :create_virtual_interface
61
+ request :delete_virtual_interface
62
+
63
+ class Mock < Fog::Rackspace::Service
64
+ include Fog::Rackspace::MockData
65
+
66
+ def initialize(options)
67
+ @rackspace_api_key = options[:rackspace_api_key]
68
+ end
69
+
70
+ def request(params)
71
+ Fog::Mock.not_implemented
72
+ end
73
+
74
+ def response(params={})
75
+ body = params[:body] || {}
76
+ status = params[:status] || 200
77
+ headers = params[:headers] || {}
78
+
79
+ response = Excon::Response.new(:body => body, :headers => headers, :status => status)
80
+ if params.key?(:expects) && ![*params[:expects]].include?(response.status)
81
+ raise(Excon::Errors.status_error(params, response))
82
+ else response
83
+ end
84
+ end
85
+ end
86
+
87
+ class Real < Fog::Rackspace::Service
88
+ def initialize(options = {})
89
+ @rackspace_api_key = options[:rackspace_api_key]
90
+ @rackspace_username = options[:rackspace_username]
91
+ @rackspace_auth_url = options[:rackspace_auth_url]
92
+ setup_custom_endpoint(options)
93
+ @rackspace_must_reauthenticate = false
94
+ @connection_options = options[:connection_options] || {}
95
+
96
+ authenticate
97
+
98
+ deprecation_warnings(options)
99
+
100
+ @persistent = options[:persistent] || false
101
+ @connection = Fog::Core::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
102
+ end
103
+
104
+ def request(params, parse_json = true)
105
+ super
106
+ rescue Excon::Errors::NotFound => error
107
+ raise NotFound.slurp(error, self)
108
+ rescue Excon::Errors::BadRequest => error
109
+ raise BadRequest.slurp(error, self)
110
+ rescue Excon::Errors::InternalServerError => error
111
+ raise InternalServerError.slurp(error, self)
112
+ rescue Excon::Errors::HTTPStatusError => error
113
+ raise ServiceError.slurp(error, self)
114
+ end
115
+
116
+ def authenticate(options={})
117
+ super({
118
+ :rackspace_api_key => @rackspace_api_key,
119
+ :rackspace_username => @rackspace_username,
120
+ :rackspace_auth_url => @rackspace_auth_url,
121
+ :connection_options => @connection_options
122
+ })
123
+ end
124
+
125
+ def service_name
126
+ :cloudServersOpenStack
127
+ end
128
+
129
+ def request_id_header
130
+ "x-compute-request-id"
131
+ end
132
+
133
+ def region
134
+ @rackspace_region
135
+ end
136
+
137
+ def endpoint_uri(service_endpoint_url=nil)
138
+ @uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_compute_url)
139
+ end
140
+
141
+ private
142
+
143
+ def setup_custom_endpoint(options)
144
+ @rackspace_endpoint = Fog::Rackspace.normalize_url(options[:rackspace_compute_url] || options[:rackspace_endpoint])
145
+
146
+ if v2_authentication?
147
+ case @rackspace_endpoint
148
+ when DFW_ENDPOINT
149
+ @rackspace_endpoint = nil
150
+ @rackspace_region = :dfw
151
+ when ORD_ENDPOINT
152
+ @rackspace_endpoint = nil
153
+ @rackspace_region = :ord
154
+ when LON_ENDPOINT
155
+ @rackspace_endpoint = nil
156
+ @rackspace_region = :lon
157
+ else
158
+ # we are actually using a custom endpoint
159
+ @rackspace_region = options[:rackspace_region]
160
+ end
161
+ else
162
+ #if we are using auth1 and the endpoint is not set, default to DFW_ENDPOINT for historical reasons
163
+ @rackspace_endpoint ||= DFW_ENDPOINT
164
+ end
165
+ end
166
+
167
+ def deprecation_warnings(options)
168
+ Fog::Logger.deprecation("The :rackspace_endpoint option is deprecated. Please use :rackspace_compute_url for custom endpoints") if options[:rackspace_endpoint]
169
+
170
+ if [DFW_ENDPOINT, ORD_ENDPOINT, LON_ENDPOINT].include?(@rackspace_endpoint) && v2_authentication?
171
+ regions = @identity_service.service_catalog.display_service_regions(service_name)
172
+ Fog::Logger.deprecation("Please specify region using :rackspace_region rather than :rackspace_endpoint. Valid regions for :rackspace_region are #{regions}.")
173
+ end
174
+ end
175
+
176
+ def append_tenant_v1(credentials)
177
+ account_id = credentials['X-Server-Management-Url'].match(/.*\/([\d]+)$/)[1]
178
+
179
+ endpoint = @rackspace_endpoint || credentials['X-Server-Management-Url'] || DFW_ENDPOINT
180
+ @uri = URI.parse(endpoint)
181
+ @uri.path = "#{@uri.path}/#{account_id}"
182
+ end
183
+
184
+ def authenticate_v1(options)
185
+ credentials = Fog::Rackspace.authenticate(options, @connection_options)
186
+ append_tenant_v1 credentials
187
+ @auth_token = credentials['X-Auth-Token']
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
@@ -14,6 +14,9 @@ module Fog
14
14
  if options.key?(:weight)
15
15
  data['nodes'][0]['weight'] = options[:weight]
16
16
  end
17
+ if options.key? :type
18
+ data['node']['type'] = options[:type]
19
+ end
17
20
  request(
18
21
  :body => Fog::JSON.encode(data),
19
22
  :expects => [200, 202],
@@ -12,6 +12,9 @@ module Fog
12
12
  if options.key? :condition
13
13
  data['node']['condition'] = options[:condition]
14
14
  end
15
+ if options.key? :type
16
+ data['node']['type'] = options[:type]
17
+ end
15
18
  #TODO - Do anything if no valid options are passed in?
16
19
  request(
17
20
  :body => Fog::JSON.encode(data),
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Networking
4
+ class Real
5
+ def create_network(label, cidr)
6
+ data = {
7
+ 'network' => {
8
+ 'label' => label,
9
+ 'cidr' => cidr
10
+ }
11
+ }
12
+
13
+ request(
14
+ :method => 'POST',
15
+ :body => Fog::JSON.encode(data),
16
+ :path => "os-networksv2",
17
+ :expects => 200
18
+ )
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def create_network(label, cidr)
24
+ network_id = Fog::Rackspace::MockData.uuid
25
+
26
+ self.data[:networks][network_id] = {
27
+ 'id' => network_id,
28
+ 'label' => label,
29
+ 'cidr' => cidr
30
+ }
31
+ response(:body => { 'network' => self.data[:networks][network_id] })
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Networking
4
+ class Real
5
+ # Creates virtual interface for a server
6
+ # @param [String] server_id The server id to create the virtual interface on
7
+ # @param [String] network_id The network id to attach the virtual interface to
8
+ # @raise [Fog::Rackspace::Networking::NotFound] - HTTP 404
9
+ # @raise [Fog::Rackspace::Networking::BadRequest] - HTTP 400
10
+ # @raise [Fog::Rackspace::Networking::InternalServerError] - HTTP 500
11
+ # @raise [Fog::Rackspace::Networking::ServiceError]
12
+ # @see http://docs.rackspace.com/servers/api/v2/cn-devguide/content/api_create_virtual_interface.html
13
+ def create_virtual_interface(server_id, network_id)
14
+ data = {
15
+ :virtual_interface => {
16
+ :network_id => network_id
17
+ }
18
+ }
19
+
20
+ request(
21
+ :expects => [200],
22
+ :method => 'POST',
23
+ :path => "servers/#{server_id}/os-virtual-interfacesv2",
24
+ :body => Fog::JSON.encode(data)
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Networking
4
+ class Real
5
+ def delete_network(id)
6
+ request(:method => 'DELETE', :path => "os-networksv2/#{id}", :expects => 202)
7
+ end
8
+ end
9
+
10
+ class Mock
11
+ def delete_network(id)
12
+ unless self.data[:networks].key?(id)
13
+ raise Fog::Rackspace::Networking::NotFound
14
+ end
15
+
16
+ response(:body => '', :status => 202)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Networking
4
+ class Real
5
+ # Deletes virtual interface from server
6
+ # @param [String] server_id The server id that contains the virtual interface
7
+ # @param [String] interface_id The id of the virtual interface
8
+ # @raise [Fog::Rackspace::Networking::NotFound] - HTTP 404
9
+ # @raise [Fog::Rackspace::Networking::BadRequest] - HTTP 400
10
+ # @raise [Fog::Rackspace::Networking::InternalServerError] - HTTP 500
11
+ # @raise [Fog::Rackspace::Networking::ServiceError]
12
+ # @see http://docs.rackspace.com/servers/api/v2/cn-devguide/content/delete_virt_interface_api.html
13
+ def delete_virtual_interface(server_id, interface_id)
14
+ request(
15
+ :expects => [200],
16
+ :method => 'DELETE',
17
+ :path => "servers/#{server_id}/os-virtual-interfacesv2/#{interface_id}"
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Networking
4
+ class Real
5
+ def get_network(id)
6
+ request(:method => 'GET', :path => "os-networksv2/#{id}", :expects => 200)
7
+ end
8
+ end
9
+
10
+ class Mock
11
+ def get_network(id)
12
+ unless self.data[:networks].key?(id)
13
+ raise Fog::Rackspace::Networking::NotFound
14
+ end
15
+
16
+ response(:body => { 'network' => self.data[:networks][id] })
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Networking
4
+ class Real
5
+ def list_networks
6
+ request(:method => 'GET', :path => 'os-networksv2', :expects => 200)
7
+ end
8
+ end
9
+
10
+ class Mock
11
+ def list_networks
12
+ networks = self.data[:networks].values
13
+ response(:body => { 'networks' => networks })
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Networking
4
+ class Real
5
+ # Lists virtual interfaces for a server
6
+ # @param [String] server_id
7
+ # @raise [Fog::Rackspace::Networking::NotFound] - HTTP 404
8
+ # @raise [Fog::Rackspace::Networking::BadRequest] - HTTP 400
9
+ # @raise [Fog::Rackspace::Networking::InternalServerError] - HTTP 500
10
+ # @raise [Fog::Rackspace::Networking::ServiceError]
11
+ # @see http://docs.rackspace.com/servers/api/v2/cn-devguide/content/list_virt_interfaces.html
12
+ def list_virtual_interfaces(server_id)
13
+ request(
14
+ :expects => [200],
15
+ :method => 'GET',
16
+ :path => "servers/#{server_id}/os-virtual-interfacesv2"
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end