fog 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. data/.gitignore +1 -0
  2. data/README.md +1 -0
  3. data/Rakefile +2 -1
  4. data/changelog.txt +184 -0
  5. data/docs/cdn/index.markdown +69 -3
  6. data/fog.gemspec +2 -2
  7. data/lib/fog.rb +2 -1
  8. data/lib/fog/atmos/models/storage/file.rb +16 -14
  9. data/lib/fog/aws/auto_scaling.rb +55 -13
  10. data/lib/fog/aws/cdn.rb +69 -9
  11. data/lib/fog/aws/cloud_watch.rb +15 -1
  12. data/lib/fog/aws/compute.rb +2 -0
  13. data/lib/fog/aws/models/auto_scaling/group.rb +10 -4
  14. data/lib/fog/aws/models/cdn/distribution.rb +93 -0
  15. data/lib/fog/aws/models/cdn/distribution_helper.rb +64 -0
  16. data/lib/fog/aws/models/cdn/distributions.rb +32 -0
  17. data/lib/fog/aws/models/cdn/distributions_helper.rb +47 -0
  18. data/lib/fog/aws/models/cdn/invalidation.rb +64 -0
  19. data/lib/fog/aws/models/cdn/invalidations.rb +54 -0
  20. data/lib/fog/aws/models/cdn/streaming_distribution.rb +77 -0
  21. data/lib/fog/aws/models/cdn/streaming_distributions.rb +32 -0
  22. data/lib/fog/aws/models/compute/server.rb +0 -23
  23. data/lib/fog/aws/models/compute/spot_request.rb +2 -24
  24. data/lib/fog/aws/models/rds/server.rb +18 -0
  25. data/lib/fog/aws/models/rds/subnet_group.rb +20 -0
  26. data/lib/fog/aws/models/rds/subnet_groups.rb +27 -0
  27. data/lib/fog/aws/models/storage/file.rb +1 -1
  28. data/lib/fog/aws/parsers/auto_scaling/describe_adjustment_types.rb +15 -2
  29. data/lib/fog/aws/parsers/auto_scaling/describe_auto_scaling_groups.rb +39 -13
  30. data/lib/fog/aws/parsers/auto_scaling/describe_auto_scaling_notification_types.rb +43 -0
  31. data/lib/fog/aws/parsers/auto_scaling/describe_metric_collection_types.rb +3 -3
  32. data/lib/fog/aws/parsers/auto_scaling/describe_notification_configurations.rb +42 -0
  33. data/lib/fog/aws/parsers/auto_scaling/describe_scaling_process_types.rb +15 -2
  34. data/lib/fog/aws/parsers/auto_scaling/describe_tags.rb +46 -0
  35. data/lib/fog/aws/parsers/auto_scaling/describe_termination_policy_types.rb +44 -0
  36. data/lib/fog/aws/parsers/cdn/get_invalidation.rb +32 -0
  37. data/lib/fog/aws/parsers/cloud_formation/describe_stacks.rb +1 -1
  38. data/lib/fog/aws/parsers/cloud_watch/list_metrics.rb +1 -1
  39. data/lib/fog/aws/parsers/compute/describe_availability_zones.rb +13 -2
  40. data/lib/fog/aws/parsers/compute/describe_reserved_instances.rb +1 -1
  41. data/lib/fog/aws/parsers/elasticache/base.rb +0 -2
  42. data/lib/fog/aws/parsers/elasticache/engine_defaults_parser.rb +1 -1
  43. data/lib/fog/aws/parsers/elasticache/event_list.rb +2 -0
  44. data/lib/fog/aws/parsers/rds/base.rb +32 -0
  45. data/lib/fog/aws/parsers/rds/create_db_subnet_group.rb +38 -0
  46. data/lib/fog/aws/parsers/rds/describe_db_subnet_groups.rb +38 -0
  47. data/lib/fog/aws/parsers/rds/event_list.rb +40 -0
  48. data/lib/fog/aws/parsers/rds/subnet_group_parser.rb +38 -0
  49. data/lib/fog/aws/parsers/rds/tag_list_parser.rb +35 -0
  50. data/lib/fog/aws/rds.rb +24 -7
  51. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +36 -16
  52. data/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb +19 -12
  53. data/lib/fog/aws/requests/auto_scaling/create_or_update_tags.rb +63 -0
  54. data/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb +10 -3
  55. data/lib/fog/aws/requests/auto_scaling/delete_notification_configuration.rb +21 -5
  56. data/lib/fog/aws/requests/auto_scaling/delete_policy.rb +2 -2
  57. data/lib/fog/aws/requests/auto_scaling/delete_tags.rb +63 -0
  58. data/lib/fog/aws/requests/auto_scaling/describe_adjustment_types.rb +4 -3
  59. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_groups.rb +17 -13
  60. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb +1 -1
  61. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_notification_types.rb +55 -0
  62. data/lib/fog/aws/requests/auto_scaling/describe_metric_collection_types.rb +6 -5
  63. data/lib/fog/aws/requests/auto_scaling/describe_notification_configurations.rb +79 -0
  64. data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +1 -1
  65. data/lib/fog/aws/requests/auto_scaling/describe_scaling_process_types.rb +4 -3
  66. data/lib/fog/aws/requests/auto_scaling/describe_tags.rb +74 -0
  67. data/lib/fog/aws/requests/auto_scaling/describe_termination_policy_types.rb +53 -0
  68. data/lib/fog/aws/requests/auto_scaling/disable_metrics_collection.rb +1 -1
  69. data/lib/fog/aws/requests/auto_scaling/enable_metrics_collection.rb +2 -2
  70. data/lib/fog/aws/requests/auto_scaling/put_notification_configuration.rb +30 -11
  71. data/lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb +4 -4
  72. data/lib/fog/aws/requests/auto_scaling/put_scheduled_update_group_action.rb +8 -5
  73. data/lib/fog/aws/requests/auto_scaling/set_desired_capacity.rb +2 -2
  74. data/lib/fog/aws/requests/auto_scaling/set_instance_health.rb +2 -2
  75. data/lib/fog/aws/requests/auto_scaling/suspend_processes.rb +1 -1
  76. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +30 -18
  77. data/lib/fog/aws/requests/cdn/delete_distribution.rb +31 -0
  78. data/lib/fog/aws/requests/cdn/delete_streaming_distribution.rb +30 -0
  79. data/lib/fog/aws/requests/cdn/get_distribution.rb +28 -0
  80. data/lib/fog/aws/requests/cdn/get_distribution_list.rb +29 -0
  81. data/lib/fog/aws/requests/cdn/get_invalidation.rb +60 -0
  82. data/lib/fog/aws/requests/cdn/get_invalidation_list.rb +41 -0
  83. data/lib/fog/aws/requests/cdn/get_streaming_distribution.rb +26 -0
  84. data/lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb +30 -0
  85. data/lib/fog/aws/requests/cdn/post_distribution.rb +44 -0
  86. data/lib/fog/aws/requests/cdn/post_invalidation.rb +33 -0
  87. data/lib/fog/aws/requests/cdn/post_streaming_distribution.rb +44 -0
  88. data/lib/fog/aws/requests/cdn/put_distribution_config.rb +28 -0
  89. data/lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb +28 -0
  90. data/lib/fog/aws/requests/compute/create_image.rb +32 -5
  91. data/lib/fog/aws/requests/compute/create_subnet.rb +3 -3
  92. data/lib/fog/aws/requests/compute/create_volume.rb +2 -2
  93. data/lib/fog/aws/requests/compute/register_image.rb +1 -1
  94. data/lib/fog/aws/requests/elasticache/describe_events.rb +7 -4
  95. data/lib/fog/aws/requests/glacier/create_archive.rb +1 -1
  96. data/lib/fog/aws/requests/glacier/initiate_multipart_upload.rb +1 -1
  97. data/lib/fog/aws/requests/rds/add_tags_to_resource.rb +46 -0
  98. data/lib/fog/aws/requests/rds/create_db_instance.rb +2 -0
  99. data/lib/fog/aws/requests/rds/create_db_subnet_group.rb +58 -0
  100. data/lib/fog/aws/requests/rds/describe_db_subnet_groups.rb +63 -0
  101. data/lib/fog/aws/requests/rds/describe_events.rb +52 -0
  102. data/lib/fog/aws/requests/rds/list_tags_for_resource.rb +44 -0
  103. data/lib/fog/aws/requests/rds/remove_tags_from_resource.rb +44 -0
  104. data/lib/fog/aws/sqs.rb +1 -1
  105. data/lib/fog/aws/storage.rb +1 -1
  106. data/lib/fog/bin/openstack.rb +5 -0
  107. data/lib/fog/bluebox/models/compute/server.rb +0 -19
  108. data/lib/fog/bluebox/requests/compute/create_block.rb +8 -8
  109. data/lib/fog/brightbox/compute.rb +56 -7
  110. data/lib/fog/brightbox/models/compute/accounts.rb +29 -0
  111. data/lib/fog/brightbox/models/compute/api_client.rb +37 -0
  112. data/lib/fog/brightbox/models/compute/api_clients.rb +24 -0
  113. data/lib/fog/brightbox/models/compute/application.rb +27 -0
  114. data/lib/fog/brightbox/models/compute/applications.rb +28 -0
  115. data/lib/fog/brightbox/models/compute/server.rb +3 -1
  116. data/lib/fog/brightbox/models/compute/users.rb +1 -3
  117. data/lib/fog/brightbox/requests/compute/create_application.rb +13 -0
  118. data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +2 -2
  119. data/lib/fog/brightbox/requests/compute/destroy_application.rb +14 -0
  120. data/lib/fog/brightbox/requests/compute/get_account.rb +28 -4
  121. data/lib/fog/brightbox/requests/compute/get_application.rb +14 -0
  122. data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +19 -0
  123. data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +19 -0
  124. data/lib/fog/brightbox/requests/compute/get_user.rb +28 -5
  125. data/lib/fog/brightbox/requests/compute/list_accounts.rb +13 -0
  126. data/lib/fog/brightbox/requests/compute/list_applications.rb +13 -0
  127. data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +14 -0
  128. data/lib/fog/brightbox/requests/compute/update_account.rb +51 -3
  129. data/lib/fog/brightbox/requests/compute/update_application.rb +15 -0
  130. data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +4 -2
  131. data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +37 -0
  132. data/lib/fog/clodo/models/compute/server.rb +7 -44
  133. data/lib/fog/compute/models/server.rb +23 -2
  134. data/lib/fog/core/time.rb +2 -0
  135. data/lib/fog/core/wait_for.rb +0 -2
  136. data/lib/fog/ecloud/models/compute/servers.rb +3 -1
  137. data/lib/fog/ecloud/requests/compute/get_servers.rb +1 -1
  138. data/lib/fog/ecloud/requests/compute/get_tasks.rb +1 -1
  139. data/lib/fog/go_grid/models/compute/server.rb +0 -4
  140. data/lib/fog/google/storage.rb +1 -1
  141. data/lib/fog/hp/models/compute/server.rb +1 -23
  142. data/lib/fog/hp/storage.rb +0 -1
  143. data/lib/fog/joyent/models/compute/server.rb +4 -0
  144. data/lib/fog/joyent/models/compute/servers.rb +4 -3
  145. data/lib/fog/libvirt/models/compute/server.rb +1 -27
  146. data/lib/fog/linode/models/compute/server.rb +0 -1
  147. data/lib/fog/local/models/storage/directory.rb +1 -1
  148. data/lib/fog/network.rb +26 -0
  149. data/lib/fog/ninefold/compute.rb +8 -0
  150. data/lib/fog/ninefold/requests/compute/assign_to_load_balancer_rule.rb +13 -0
  151. data/lib/fog/ninefold/requests/compute/create_load_balancer_rule.rb +11 -0
  152. data/lib/fog/ninefold/requests/compute/delete_load_balancer_rule.rb +11 -0
  153. data/lib/fog/ninefold/requests/compute/list_load_balancer_rule_instances.rb +15 -0
  154. data/lib/fog/ninefold/requests/compute/list_load_balancer_rules.rb +14 -0
  155. data/lib/fog/ninefold/requests/compute/remove_from_load_balancer_rule.rb +12 -0
  156. data/lib/fog/ninefold/requests/compute/update_load_balancer_rule.rb +15 -0
  157. data/lib/fog/ninefold/storage.rb +14 -112
  158. data/lib/fog/openstack.rb +4 -1
  159. data/lib/fog/openstack/compute.rb +20 -1
  160. data/lib/fog/openstack/identity.rb +67 -18
  161. data/lib/fog/openstack/image.rb +12 -4
  162. data/lib/fog/openstack/models/compute/security_group.rb +1 -1
  163. data/lib/fog/openstack/models/compute/server.rb +5 -23
  164. data/lib/fog/openstack/models/identity/tenants.rb +5 -3
  165. data/lib/fog/openstack/models/identity/users.rb +4 -1
  166. data/lib/fog/openstack/models/image/image.rb +6 -1
  167. data/lib/fog/openstack/models/network/network.rb +46 -0
  168. data/lib/fog/openstack/models/network/networks.rb +34 -0
  169. data/lib/fog/openstack/models/network/port.rb +52 -0
  170. data/lib/fog/openstack/models/network/ports.rb +34 -0
  171. data/lib/fog/openstack/models/network/subnet.rb +55 -0
  172. data/lib/fog/openstack/models/network/subnets.rb +34 -0
  173. data/lib/fog/openstack/network.rb +234 -0
  174. data/lib/fog/openstack/requests/compute/attach_volume.rb +10 -0
  175. data/lib/fog/openstack/requests/compute/create_security_group.rb +15 -11
  176. data/lib/fog/openstack/requests/compute/create_security_group_rule.rb +17 -15
  177. data/lib/fog/openstack/requests/compute/create_server.rb +7 -1
  178. data/lib/fog/openstack/requests/compute/create_volume.rb +10 -10
  179. data/lib/fog/openstack/requests/compute/create_volume_snapshot.rb +16 -1
  180. data/lib/fog/openstack/requests/compute/detach_volume.rb +5 -0
  181. data/lib/fog/openstack/requests/compute/get_snapshot_details.rb +4 -4
  182. data/lib/fog/openstack/requests/compute/get_volume_details.rb +9 -9
  183. data/lib/fog/openstack/requests/compute/list_security_groups.rb +3 -3
  184. data/lib/fog/openstack/requests/compute/list_volumes.rb +14 -14
  185. data/lib/fog/openstack/requests/identity/create_tenant.rb +3 -3
  186. data/lib/fog/openstack/requests/identity/create_user.rb +1 -1
  187. data/lib/fog/openstack/requests/identity/delete_role.rb +1 -1
  188. data/lib/fog/openstack/requests/identity/get_tenant.rb +1 -1
  189. data/lib/fog/openstack/requests/identity/list_roles.rb +7 -0
  190. data/lib/fog/openstack/requests/image/create_image.rb +36 -38
  191. data/lib/fog/openstack/requests/image/delete_image.rb +0 -2
  192. data/lib/fog/openstack/requests/image/list_public_images.rb +7 -25
  193. data/lib/fog/openstack/requests/image/list_public_images_detailed.rb +2 -41
  194. data/lib/fog/openstack/requests/image/update_image.rb +26 -21
  195. data/lib/fog/openstack/requests/image/update_image_members.rb +37 -0
  196. data/lib/fog/openstack/requests/network/create_network.rb +44 -0
  197. data/lib/fog/openstack/requests/network/create_port.rb +52 -0
  198. data/lib/fog/openstack/requests/network/create_subnet.rb +56 -0
  199. data/lib/fog/openstack/requests/network/delete_network.rb +30 -0
  200. data/lib/fog/openstack/requests/network/delete_port.rb +30 -0
  201. data/lib/fog/openstack/requests/network/delete_subnet.rb +30 -0
  202. data/lib/fog/openstack/requests/network/get_network.rb +42 -0
  203. data/lib/fog/openstack/requests/network/get_port.rb +48 -0
  204. data/lib/fog/openstack/requests/network/get_subnet.rb +49 -0
  205. data/lib/fog/openstack/requests/network/list_networks.rb +27 -0
  206. data/lib/fog/openstack/requests/network/list_ports.rb +27 -0
  207. data/lib/fog/openstack/requests/network/list_subnets.rb +27 -0
  208. data/lib/fog/openstack/requests/network/set_tenant.rb +21 -0
  209. data/lib/fog/openstack/requests/network/update_network.rb +41 -0
  210. data/lib/fog/openstack/requests/network/update_port.rb +44 -0
  211. data/lib/fog/openstack/requests/network/update_subnet.rb +44 -0
  212. data/lib/fog/openstack/requests/volume/create_volume.rb +10 -10
  213. data/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +16 -1
  214. data/lib/fog/openstack/requests/volume/get_snapshot_details.rb +6 -6
  215. data/lib/fog/openstack/requests/volume/get_volume_details.rb +10 -10
  216. data/lib/fog/openstack/requests/volume/list_volumes.rb +14 -14
  217. data/lib/fog/openstack/volume.rb +10 -0
  218. data/lib/fog/rackspace/models/compute/server.rb +1 -24
  219. data/lib/fog/rackspace/models/compute_v2/server.rb +4 -2
  220. data/lib/fog/rackspace/requests/compute_v2/create_server.rb +1 -1
  221. data/lib/fog/rackspace/requests/compute_v2/list_servers.rb +1 -1
  222. data/lib/fog/storm_on_demand/models/compute/server.rb +1 -5
  223. data/lib/fog/virtual_box/models/compute/server.rb +2 -44
  224. data/lib/fog/vmfusion/models/compute/server.rb +3 -36
  225. data/lib/fog/vsphere/models/compute/server.rb +1 -1
  226. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +2 -31
  227. data/lib/fog/vsphere/requests/compute/vm_clone.rb +35 -7
  228. data/tests/aws/models/cdn/distribution_tests.rb +15 -0
  229. data/tests/aws/models/cdn/distributions_tests.rb +15 -0
  230. data/tests/aws/models/cdn/invalidation_tests.rb +32 -0
  231. data/tests/aws/models/cdn/invalidations_tests.rb +15 -0
  232. data/tests/aws/models/cdn/streaming_distribution_tests.rb +15 -0
  233. data/tests/aws/models/cdn/streaming_distributions_tests.rb +15 -0
  234. data/tests/aws/models/rds/tagging_tests.rb +20 -0
  235. data/tests/aws/requests/auto_scaling/auto_scaling_tests.rb +1 -11
  236. data/tests/aws/requests/auto_scaling/describe_types_tests.rb +102 -0
  237. data/tests/aws/requests/auto_scaling/helper.rb +47 -3
  238. data/tests/aws/requests/auto_scaling/notification_configuration_tests.rb +123 -0
  239. data/tests/aws/requests/auto_scaling/tag_tests.rb +62 -0
  240. data/tests/aws/requests/cdn/cdn_tests.rb +252 -0
  241. data/tests/aws/requests/compute/image_tests.rb +32 -1
  242. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  243. data/tests/aws/requests/rds/describe_events.rb +16 -0
  244. data/tests/aws/requests/rds/helper.rb +26 -0
  245. data/tests/aws/requests/rds/subnet_groups_test.rb +48 -0
  246. data/tests/aws/requests/rds/tagging_tests.rb +78 -0
  247. data/tests/brightbox/requests/compute/account_tests.rb +24 -4
  248. data/tests/brightbox/requests/compute/application_test.rb +63 -0
  249. data/tests/brightbox/requests/compute/helper.rb +49 -1
  250. data/tests/helper.rb +4 -1
  251. data/tests/local/models/directory_tests.rb +16 -0
  252. data/tests/ninefold/requests/compute/helper.rb +53 -0
  253. data/tests/ninefold/requests/compute/load_balancer_tests.rb +66 -0
  254. data/tests/openstack/models/image/image_tests.rb +1 -0
  255. data/tests/openstack/models/network/network_tests.rb +24 -0
  256. data/tests/openstack/models/network/networks_tests.rb +21 -0
  257. data/tests/openstack/models/network/port_tests.rb +28 -0
  258. data/tests/openstack/models/network/ports_tests.rb +25 -0
  259. data/tests/openstack/models/network/subnet_tests.rb +30 -0
  260. data/tests/openstack/models/network/subnets_tests.rb +27 -0
  261. data/tests/openstack/requests/compute/image_tests.rb +3 -4
  262. data/tests/openstack/requests/compute/quota_tests.rb +2 -0
  263. data/tests/openstack/requests/compute/security_group_tests.rb +10 -10
  264. data/tests/openstack/requests/compute/server_tests.rb +3 -1
  265. data/tests/openstack/requests/compute/volume_tests.rb +11 -12
  266. data/tests/openstack/requests/identity/tenant_tests.rb +2 -1
  267. data/tests/openstack/requests/image/image_tests.rb +66 -45
  268. data/tests/openstack/requests/network/network_tests.rb +56 -0
  269. data/tests/openstack/requests/network/port_tests.rb +63 -0
  270. data/tests/openstack/requests/network/subnet_tests.rb +66 -0
  271. data/tests/rackspace/models/identity/user_tests.rb +1 -1
  272. data/tests/rackspace/models/identity/users_tests.rb +1 -1
  273. metadata +137 -13
  274. data/lib/fog/ninefold/models/storage/directories.rb +0 -48
  275. data/lib/fog/ninefold/models/storage/directory.rb +0 -53
  276. data/lib/fog/ninefold/models/storage/file.rb +0 -108
  277. data/lib/fog/ninefold/models/storage/files.rb +0 -73
  278. data/lib/fog/ninefold/requests/storage/delete_namespace.rb +0 -19
  279. data/lib/fog/ninefold/requests/storage/get_namespace.rb +0 -20
  280. data/lib/fog/ninefold/requests/storage/head_namespace.rb +0 -20
  281. data/lib/fog/ninefold/requests/storage/post_namespace.rb +0 -20
  282. data/lib/fog/ninefold/requests/storage/put_namespace.rb +0 -20
@@ -43,6 +43,7 @@ module Fog
43
43
 
44
44
  service(:compute , 'openstack/compute' , 'Compute' )
45
45
  service(:identity, 'openstack/identity', 'Identity')
46
+ service(:network, 'openstack/network', 'Network')
46
47
 
47
48
  # legacy v1.0 style auth
48
49
  def self.authenticate_v1(options, connection_options = {})
@@ -94,7 +95,7 @@ module Fog
94
95
  req_body = {
95
96
  'auth' => {
96
97
  'passwordCredentials' => {
97
- 'username' => @openstack_username,
98
+ 'username' => @openstack_username.to_s,
98
99
  'password' => @openstack_api_key.to_s
99
100
  }
100
101
  }
@@ -148,11 +149,13 @@ module Fog
148
149
  mgmt_url = svc['endpoints'].detect{|x| x[@endpoint_type]}[@endpoint_type]
149
150
  identity_url = identity_svc['endpoints'].detect{|x| x['publicURL']}['publicURL'] if identity_svc
150
151
  token = body['access']['token']['id']
152
+ expires = body['access']['token']['expires']
151
153
 
152
154
  {
153
155
  :user => user,
154
156
  :tenant => tenant,
155
157
  :token => token,
158
+ :expires => expires,
156
159
  :server_management_url => mgmt_url,
157
160
  :identity_public_endpoint => identity_url,
158
161
  :current_user_id => body['access']['user']['id']
@@ -152,9 +152,13 @@ module Fog
152
152
  # Hosts
153
153
  request :list_hosts
154
154
  request :get_host_details
155
-
155
+
156
156
 
157
157
  class Mock
158
+ attr_reader :auth_token
159
+ attr_reader :auth_token_expiration
160
+ attr_reader :current_user
161
+ attr_reader :current_tenant
158
162
 
159
163
  def self.data
160
164
  @data ||= Hash.new do |hash, key|
@@ -205,6 +209,19 @@ module Fog
205
209
  def initialize(options={})
206
210
  @openstack_username = options[:openstack_username]
207
211
  @openstack_tenant = options[:openstack_tenant]
212
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
213
+
214
+ @auth_token = Fog::Mock.random_base64(64)
215
+ @auth_token_expiration = (Time.now.utc + 86400).iso8601
216
+
217
+ management_url = URI.parse(options[:openstack_auth_url])
218
+ management_url.port = 8774
219
+ management_url.path = '/v1.1/1'
220
+ @openstack_management_url = management_url.to_s
221
+
222
+ identity_public_endpoint = URI.parse(options[:openstack_auth_url])
223
+ identity_public_endpoint.port = 5000
224
+ @openstack_identity_public_endpoint = identity_public_endpoint.to_s
208
225
  end
209
226
 
210
227
  def data
@@ -226,6 +243,7 @@ module Fog
226
243
 
227
244
  class Real
228
245
  attr_reader :auth_token
246
+ attr_reader :auth_token_expiration
229
247
  attr_reader :current_user
230
248
  attr_reader :current_tenant
231
249
 
@@ -338,6 +356,7 @@ module Fog
338
356
 
339
357
  @openstack_must_reauthenticate = false
340
358
  @auth_token = credentials[:token]
359
+ @auth_token_expiration = credentials[:expires]
341
360
  @openstack_management_url = credentials[:server_management_url]
342
361
  @openstack_identity_public_endpoint = credentials[:identity_public_endpoint]
343
362
  uri = URI.parse(@openstack_management_url)
@@ -53,32 +53,79 @@ module Fog
53
53
 
54
54
 
55
55
  class Mock
56
+ attr_reader :auth_token
57
+ attr_reader :auth_token_expiration
58
+ attr_reader :current_user
59
+ attr_reader :current_tenant
60
+
56
61
  def self.data
62
+ @users ||= {}
63
+ @roles ||= {}
64
+ @tenants ||= {}
65
+
57
66
  @data ||= Hash.new do |hash, key|
58
67
  hash[key] = {
59
- :users => {},
60
- :roles => {},
61
- :tenants => {}
68
+ :users => @users,
69
+ :roles => @roles,
70
+ :tenants => @tenants
62
71
  }
63
72
  end
64
73
  end
65
74
 
66
- def self.reset
67
- @data = nil
75
+ def self.reset!
76
+ @data = nil
77
+ @users = nil
78
+ @roles = nil
79
+ @tenants = nil
68
80
  end
69
81
 
70
82
  def initialize(options={})
71
- @openstack_username = options[:openstack_username]
72
-
73
- unless self.data[:users].values.detect {|user| user['name'] == @openstack_username}
74
- id = Fog::Mock.random_numbers(6).to_s
75
- self.data[:users][id] = {
76
- 'id' => id,
77
- 'name' => options[:openstack_username],
78
- 'email' => "#{options[:openstack_username]}@mock.com",
83
+ require 'multi_json'
84
+ @openstack_username = options[:openstack_username] || 'admin'
85
+ @openstack_tenant = options[:openstack_tenant] || 'admin'
86
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
87
+ @openstack_management_url = @openstack_auth_uri.to_s
88
+
89
+ @auth_token = Fog::Mock.random_base64(64)
90
+ @auth_token_expiration = (Time.now.utc + 86400).iso8601
91
+
92
+ @admin_tenant = self.data[:tenants].values.find do |u|
93
+ u['name'] == 'admin'
94
+ end
95
+
96
+ if @openstack_tenant
97
+ @current_tenant = self.data[:tenants].values.find do |u|
98
+ u['name'] == @openstack_tenant
99
+ end
100
+
101
+ unless @current_tenant
102
+ @current_tenant_id = Fog::Mock.random_hex(32)
103
+ @current_tenant = self.data[:tenants][@current_tenant_id] = {
104
+ 'id' => @current_tenant_id,
105
+ 'name' => @openstack_tenant
106
+ }
107
+ else
108
+ @current_tenant_id = @current_tenant['id']
109
+ end
110
+ else
111
+ @current_tenant = @admin_tenant
112
+ end
113
+
114
+ @current_user = self.data[:users].values.find do |u|
115
+ u['name'] == @openstack_username
116
+ end
117
+
118
+ unless @current_user
119
+ @current_user_id = Fog::Mock.random_hex(32)
120
+ @current_user = self.data[:users][@current_user_id] = {
121
+ 'id' => @current_user_id,
122
+ 'name' => @openstack_username,
123
+ 'email' => "#{@openstack_username}@mock.com",
79
124
  'tenantId' => Fog::Mock.random_numbers(6).to_s,
80
125
  'enabled' => true
81
126
  }
127
+ else
128
+ @current_user_id = @current_user['id']
82
129
  end
83
130
  end
84
131
 
@@ -91,11 +138,13 @@ module Fog
91
138
  end
92
139
 
93
140
  def credentials
94
- { :provider => 'openstack',
95
- :openstack_auth_url => @openstack_auth_uri.to_s,
96
- :openstack_auth_token => @auth_token,
97
- :openstack_management_url => @openstack_management_url,
98
- :openstack_current_user_id => @openstack_current_user_id}
141
+ { :provider => 'openstack',
142
+ :openstack_auth_url => @openstack_auth_uri.to_s,
143
+ :openstack_auth_token => @auth_token,
144
+ :openstack_management_url => @openstack_management_url,
145
+ :openstack_current_user_id => @openstack_current_user_id,
146
+ :current_user => @current_user,
147
+ :current_tenant => @current_tenant}
99
148
  end
100
149
  end
101
150
 
@@ -3,7 +3,6 @@ require 'fog/openstack'
3
3
  module Fog
4
4
  module Image
5
5
  class OpenStack < Fog::Service
6
-
7
6
  requires :openstack_auth_url
8
7
  recognizes :openstack_auth_token, :openstack_management_url, :persistent,
9
8
  :openstack_service_name, :openstack_tenant,
@@ -15,7 +14,6 @@ module Fog
15
14
  model :image
16
15
  collection :images
17
16
 
18
-
19
17
  request_path 'fog/openstack/requests/image'
20
18
 
21
19
  request :list_public_images
@@ -24,6 +22,7 @@ module Fog
24
22
  request :create_image
25
23
  request :update_image
26
24
  request :get_image_members
25
+ request :update_image_members
27
26
  request :get_shared_images
28
27
  request :add_member_to_image
29
28
  request :remove_member_from_image
@@ -35,8 +34,7 @@ module Fog
35
34
  def self.data
36
35
  @data ||= Hash.new do |hash, key|
37
36
  hash[key] = {
38
- :users => {},
39
- :tenants => {}
37
+ :images => {}
40
38
  }
41
39
  end
42
40
  end
@@ -48,6 +46,16 @@ module Fog
48
46
  def initialize(options={})
49
47
  require 'multi_json'
50
48
  @openstack_username = options[:openstack_username]
49
+ @openstack_tenant = options[:openstack_tenant]
50
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
51
+
52
+ @auth_token = Fog::Mock.random_base64(64)
53
+ @auth_token_expiration = (Time.now.utc + 86400).iso8601
54
+
55
+ management_url = URI.parse(options[:openstack_auth_url])
56
+ management_url.port = 9292
57
+ management_url.path = '/v1'
58
+ @openstack_management_url = management_url.to_s
51
59
 
52
60
  @data ||= { :users => {} }
53
61
  unless @data[:users].find {|u| u['name'] == options[:openstack_username]}
@@ -17,7 +17,7 @@ module Fog
17
17
  def save
18
18
  requires :name, :description
19
19
  data = connection.create_security_group(name, description)
20
- merge_attributes(data.body['security_group'])
20
+ merge_attributes(data.body['security_groups'])
21
21
  true
22
22
  end
23
23
 
@@ -24,6 +24,8 @@ module Fog
24
24
  attribute :availability_zone
25
25
  attribute :user_data_encoded
26
26
  attribute :state, :aliases => 'status'
27
+ attribute :created, :type => :time
28
+ attribute :updated, :type => :time
27
29
 
28
30
  attribute :tenant_id
29
31
  attribute :user_id
@@ -38,7 +40,7 @@ module Fog
38
40
  attribute :os_ext_sts_vm_state, :aliases => 'OS-EXT-STS:vm_state'
39
41
 
40
42
  attr_reader :password
41
- attr_writer :private_key, :private_key_path, :public_key, :public_key_path, :username, :image_ref, :flavor_ref
43
+ attr_writer :image_ref, :flavor_ref, :os_scheduler_hints
42
44
 
43
45
 
44
46
  def initialize(attributes={})
@@ -48,6 +50,7 @@ module Fog
48
50
  self.security_groups = attributes.delete(:security_groups)
49
51
  self.min_count = attributes.delete(:min_count)
50
52
  self.max_count = attributes.delete(:max_count)
53
+ self.os_scheduler_hints = attributes.delete(:os_scheduler_hints)
51
54
 
52
55
  super
53
56
  end
@@ -92,15 +95,6 @@ module Fog
92
95
  end
93
96
  end
94
97
 
95
- def private_key_path
96
- @private_key_path ||= Fog.credentials[:private_key_path]
97
- @private_key_path &&= File.expand_path(@private_key_path)
98
- end
99
-
100
- def private_key
101
- @private_key ||= private_key_path && File.read(private_key_path)
102
- end
103
-
104
98
  def public_ip_address
105
99
  if addresses['public']
106
100
  #assume last is either original or assigned from floating IPs
@@ -111,15 +105,6 @@ module Fog
111
105
  end
112
106
  end
113
107
 
114
- def public_key_path
115
- @public_key_path ||= Fog.credentials[:public_key_path]
116
- @public_key_path &&= File.expand_path(@public_key_path)
117
- end
118
-
119
- def public_key
120
- @public_key ||= public_key_path && File.read(public_key_path)
121
- end
122
-
123
108
  def image_ref
124
109
  @image_ref
125
110
  end
@@ -239,6 +224,7 @@ module Fog
239
224
  'security_groups' => @security_groups,
240
225
  'min_count' => @min_count,
241
226
  'max_count' => @max_count,
227
+ 'os:scheduler_hints' => @os_scheduler_hints
242
228
  }
243
229
  options = options.reject {|key, value| value.nil?}
244
230
  data = connection.create_server(name, image_ref, flavor_ref, options)
@@ -260,10 +246,6 @@ module Fog
260
246
  retry
261
247
  end
262
248
 
263
- def username
264
- @username ||= 'root'
265
- end
266
-
267
249
  private
268
250
 
269
251
  def adminPass=(new_admin_pass)
@@ -12,9 +12,11 @@ module Fog
12
12
  end
13
13
 
14
14
  def find_by_id(id)
15
- self.find {|tenant| tenant.id == id} ||
16
- Fog::Identity::OpenStack::Tenant.new(
17
- connection.get_tenant(id).body['tenant'])
15
+ cached_tenant = self.find {|tenant| tenant.id == id}
16
+ return cached_tenant if cached_tenant
17
+ tenant_hash = connection.get_tenant(id).body['tenant']
18
+ Fog::Identity::OpenStack::Tenant.new(
19
+ tenant_hash.merge(:connection => connection))
18
20
  end
19
21
 
20
22
  def destroy(id)
@@ -17,7 +17,10 @@ module Fog
17
17
  def find_by_id(id)
18
18
  self.find {|user| user.id == id} ||
19
19
  Fog::Identity::OpenStack::User.new(
20
- connection.get_user_by_id(id).body['user'])
20
+ connection.get_user_by_id(id).body['user'].merge(
21
+ 'connection' => connection
22
+ )
23
+ )
21
24
  end
22
25
 
23
26
  def destroy(id)
@@ -44,7 +44,7 @@ module Fog
44
44
  def create
45
45
  requires :name
46
46
  merge_attributes(connection.create_image(self.attributes).body['image'])
47
- self
47
+ self
48
48
  end
49
49
 
50
50
  def update
@@ -69,6 +69,11 @@ module Fog
69
69
  connection.remove_member_from_image(self.id, member_id)
70
70
  end
71
71
 
72
+ def update_members(members)
73
+ requires :id
74
+ connection.update_image_members(self.id, members)
75
+ end
76
+
72
77
  def members
73
78
  requires :id
74
79
  connection.get_image_members(self.id).body['members']
@@ -0,0 +1,46 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Network
5
+ class OpenStack
6
+ class Network < Fog::Model
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :subnets
11
+ attribute :shared
12
+ attribute :status
13
+ attribute :admin_state_up
14
+ attribute :tenant_id
15
+
16
+ def initialize(attributes)
17
+ @connection = attributes[:connection]
18
+ super
19
+ end
20
+
21
+ def save
22
+ identity ? update : create
23
+ end
24
+
25
+ def create
26
+ merge_attributes(connection.create_network(self.attributes).body['network'])
27
+ self
28
+ end
29
+
30
+ def update
31
+ requires :id
32
+ merge_attributes(connection.update_network(self.id,
33
+ self.attributes).body['network'])
34
+ self
35
+ end
36
+
37
+ def destroy
38
+ requires :id
39
+ connection.delete_network(self.id)
40
+ true
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,34 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/openstack/models/network/network'
3
+
4
+ module Fog
5
+ module Network
6
+ class OpenStack
7
+ class Networks < Fog::Collection
8
+
9
+ attribute :filters
10
+
11
+ model Fog::Network::OpenStack::Network
12
+
13
+ def initialize(attributes)
14
+ self.filters ||= {}
15
+ super
16
+ end
17
+
18
+ def all(filters = filters)
19
+ self.filters = filters
20
+ load(connection.list_networks(filters).body['networks'])
21
+ end
22
+
23
+ def get(network_id)
24
+ if network = connection.get_network(network_id).body['network']
25
+ new(network)
26
+ end
27
+ rescue Fog::Network::OpenStack::NotFound
28
+ nil
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end