fog 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. data/.document +1 -1
  2. data/.irbrc +5 -10
  3. data/{README.rdoc → README.md} +66 -61
  4. data/Rakefile +4 -6
  5. data/changelog.txt +491 -0
  6. data/docs/about/users.markdown +1 -0
  7. data/fog.gemspec +4 -4
  8. data/lib/fog.rb +1 -1
  9. data/lib/fog/aws.rb +4 -0
  10. data/lib/fog/aws/auto_scaling.rb +3 -0
  11. data/lib/fog/aws/cloud_watch.rb +28 -0
  12. data/lib/fog/aws/compute.rb +7 -1
  13. data/lib/fog/aws/elasticache.rb +64 -6
  14. data/lib/fog/aws/models/auto_scaling/configuration.rb +3 -1
  15. data/lib/fog/aws/models/auto_scaling/group.rb +10 -9
  16. data/lib/fog/aws/models/auto_scaling/policies.rb +33 -0
  17. data/lib/fog/aws/models/auto_scaling/policy.rb +46 -0
  18. data/lib/fog/aws/models/cloud_watch/alarm.rb +50 -2
  19. data/lib/fog/aws/models/cloud_watch/alarms.rb +18 -1
  20. data/lib/fog/aws/models/compute/address.rb +2 -2
  21. data/lib/fog/aws/models/dns/records.rb +5 -0
  22. data/lib/fog/aws/models/elasticache/cluster.rb +1 -1
  23. data/lib/fog/aws/models/iam/users.rb +26 -4
  24. data/lib/fog/aws/parsers/auto_scaling/describe_policies.rb +7 -5
  25. data/lib/fog/aws/parsers/elb/describe_load_balancers.rb +1 -1
  26. data/lib/fog/aws/rds.rb +1 -1
  27. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  28. data/lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb +1 -2
  29. data/lib/fog/aws/requests/auto_scaling/delete_auto_scaling_group.rb +10 -2
  30. data/lib/fog/aws/requests/auto_scaling/delete_launch_configuration.rb +1 -1
  31. data/lib/fog/aws/requests/auto_scaling/delete_policy.rb +10 -1
  32. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_instances.rb +0 -1
  33. data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +13 -1
  34. data/lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb +20 -1
  35. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +1 -1
  36. data/lib/fog/aws/requests/cloud_watch/delete_alarms.rb +19 -1
  37. data/lib/fog/aws/requests/cloud_watch/describe_alarms.rb +20 -2
  38. data/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb +9 -0
  39. data/lib/fog/aws/requests/compute/allocate_address.rb +4 -5
  40. data/lib/fog/aws/requests/compute/create_dhcp_options.rb +6 -5
  41. data/lib/fog/aws/requests/compute/create_internet_gateway.rb +7 -6
  42. data/lib/fog/aws/requests/compute/create_subnet.rb +11 -10
  43. data/lib/fog/aws/requests/compute/create_vpc.rb +8 -7
  44. data/lib/fog/aws/requests/compute/delete_dhcp_options.rb +1 -0
  45. data/lib/fog/aws/requests/compute/delete_internet_gateway.rb +1 -0
  46. data/lib/fog/aws/requests/compute/delete_subnet.rb +1 -0
  47. data/lib/fog/aws/requests/compute/delete_vpc.rb +2 -1
  48. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +1 -0
  49. data/lib/fog/aws/requests/compute/describe_dhcp_options.rb +1 -8
  50. data/lib/fog/aws/requests/compute/describe_instances.rb +3 -1
  51. data/lib/fog/aws/requests/compute/describe_internet_gateways.rb +1 -8
  52. data/lib/fog/aws/requests/compute/describe_subnets.rb +1 -9
  53. data/lib/fog/aws/requests/compute/describe_vpcs.rb +1 -8
  54. data/lib/fog/aws/requests/compute/release_address.rb +12 -4
  55. data/lib/fog/aws/requests/compute/start_instances.rb +1 -0
  56. data/lib/fog/aws/requests/compute/stop_instances.rb +1 -0
  57. data/lib/fog/aws/requests/elasticache/create_cache_cluster.rb +26 -2
  58. data/lib/fog/aws/requests/elasticache/delete_cache_cluster.rb +10 -1
  59. data/lib/fog/aws/requests/elasticache/describe_cache_clusters.rb +16 -1
  60. data/lib/fog/aws/requests/elasticache/modify_cache_cluster.rb +35 -3
  61. data/lib/fog/aws/requests/elasticache/reboot_cache_cluster.rb +10 -2
  62. data/lib/fog/aws/requests/elb/create_load_balancer.rb +1 -1
  63. data/lib/fog/aws/requests/rds/describe_db_instances.rb +3 -3
  64. data/lib/fog/aws/sqs.rb +1 -1
  65. data/lib/fog/aws/storage.rb +1 -1
  66. data/lib/fog/bin/rackspace.rb +4 -0
  67. data/lib/fog/cloudstack/compute.rb +25 -18
  68. data/lib/fog/cloudstack/models/compute/image.rb +34 -34
  69. data/lib/fog/cloudstack/models/compute/job.rb +14 -1
  70. data/lib/fog/cloudstack/models/compute/jobs.rb +1 -1
  71. data/lib/fog/cloudstack/models/compute/security_group.rb +50 -0
  72. data/lib/fog/cloudstack/models/compute/security_group_rule.rb +62 -0
  73. data/lib/fog/cloudstack/models/compute/security_group_rules.rb +37 -0
  74. data/lib/fog/cloudstack/models/compute/security_groups.rb +27 -0
  75. data/lib/fog/cloudstack/models/compute/server.rb +63 -39
  76. data/lib/fog/cloudstack/models/compute/volume.rb +3 -7
  77. data/lib/fog/cloudstack/models/compute/zone.rb +1 -2
  78. data/lib/fog/cloudstack/requests/compute/assign_virtual_machine.rb +18 -0
  79. data/lib/fog/cloudstack/requests/compute/authorize_security_group_egress.rb +68 -0
  80. data/lib/fog/cloudstack/requests/compute/authorize_security_group_ingress.rb +55 -4
  81. data/lib/fog/cloudstack/requests/compute/create_security_group.rb +12 -4
  82. data/lib/fog/cloudstack/requests/compute/create_zone.rb +20 -0
  83. data/lib/fog/cloudstack/requests/compute/delete_security_group.rb +17 -0
  84. data/lib/fog/cloudstack/requests/compute/destroy_virtual_machine.rb +23 -1
  85. data/lib/fog/cloudstack/requests/compute/list_firewall_rules.rb +15 -0
  86. data/lib/fog/cloudstack/requests/compute/list_security_groups.rb +22 -4
  87. data/lib/fog/cloudstack/requests/compute/query_async_job_result.rb +15 -3
  88. data/lib/fog/cloudstack/requests/compute/revoke_security_group_egress.rb +42 -0
  89. data/lib/fog/cloudstack/requests/compute/revoke_security_group_ingress.rb +29 -3
  90. data/lib/fog/core.rb +1 -0
  91. data/lib/fog/core/attributes.rb +1 -1
  92. data/lib/fog/core/current_machine.rb +2 -2
  93. data/lib/fog/core/scp.rb +8 -0
  94. data/lib/fog/core/ssh.rb +8 -0
  95. data/lib/fog/dynect/dns.rb +14 -5
  96. data/lib/fog/ibm/requests/compute/create_instance.rb +1 -1
  97. data/lib/fog/libvirt/requests/compute/create_volume.rb +1 -1
  98. data/lib/fog/libvirt/requests/compute/list_volumes.rb +1 -1
  99. data/lib/fog/local/models/storage/file.rb +12 -1
  100. data/lib/fog/local/storage.rb +25 -1
  101. data/lib/fog/ninefold/compute.rb +1 -0
  102. data/lib/fog/openstack.rb +3 -1
  103. data/lib/fog/openstack/compute.rb +13 -2
  104. data/lib/fog/openstack/models/compute/servers.rb +10 -2
  105. data/lib/fog/openstack/requests/compute/create_flavor.rb +2 -2
  106. data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
  107. data/lib/fog/openstack/requests/compute/create_server.rb +1 -1
  108. data/lib/fog/openstack/requests/compute/create_volume.rb +1 -1
  109. data/lib/fog/openstack/requests/compute/get_flavor_details.rb +7 -7
  110. data/lib/fog/openstack/requests/compute/get_quota.rb +1 -12
  111. data/lib/fog/openstack/requests/compute/get_quota_defaults.rb +1 -12
  112. data/lib/fog/openstack/requests/compute/get_volume_details.rb +1 -1
  113. data/lib/fog/openstack/requests/compute/list_flavors.rb +7 -7
  114. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +7 -7
  115. data/lib/fog/openstack/requests/compute/list_security_groups.rb +7 -7
  116. data/lib/fog/openstack/requests/compute/list_servers_detail.rb +4 -3
  117. data/lib/fog/openstack/requests/compute/list_volumes.rb +6 -8
  118. data/lib/fog/openstack/requests/compute/update_quota.rb +2 -15
  119. data/lib/fog/openstack/requests/identity/delete_role.rb +1 -1
  120. data/lib/fog/openstack/requests/identity/list_roles.rb +1 -1
  121. data/lib/fog/openstack/requests/image/create_image.rb +3 -1
  122. data/lib/fog/openstack/requests/image/list_public_images.rb +19 -1
  123. data/lib/fog/openstack/requests/image/list_public_images_detailed.rb +20 -2
  124. data/lib/fog/openstack/requests/image/update_image.rb +1 -1
  125. data/lib/fog/rackspace.rb +2 -0
  126. data/lib/fog/rackspace/databases.rb +121 -0
  127. data/lib/fog/rackspace/identity.rb +83 -0
  128. data/lib/fog/rackspace/load_balancers.rb +3 -0
  129. data/lib/fog/rackspace/models/databases/database.rb +32 -0
  130. data/lib/fog/rackspace/models/databases/databases.rb +31 -0
  131. data/lib/fog/rackspace/models/databases/flavor.rb +15 -0
  132. data/lib/fog/rackspace/models/databases/flavors.rb +25 -0
  133. data/lib/fog/rackspace/models/databases/instance.rb +104 -0
  134. data/lib/fog/rackspace/models/databases/instances.rb +25 -0
  135. data/lib/fog/rackspace/models/databases/user.rb +32 -0
  136. data/lib/fog/rackspace/models/databases/users.rb +31 -0
  137. data/lib/fog/rackspace/models/identity/credential.rb +13 -0
  138. data/lib/fog/rackspace/models/identity/credentials.rb +32 -0
  139. data/lib/fog/rackspace/models/identity/role.rb +14 -0
  140. data/lib/fog/rackspace/models/identity/roles.rb +32 -0
  141. data/lib/fog/rackspace/models/identity/tenant.rb +15 -0
  142. data/lib/fog/rackspace/models/identity/tenants.rb +28 -0
  143. data/lib/fog/rackspace/models/identity/user.rb +53 -0
  144. data/lib/fog/rackspace/models/identity/users.rb +36 -0
  145. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +17 -0
  146. data/lib/fog/rackspace/requests/databases/check_root_user.rb +15 -0
  147. data/lib/fog/rackspace/requests/databases/create_database.rb +24 -0
  148. data/lib/fog/rackspace/requests/databases/create_instance.rb +26 -0
  149. data/lib/fog/rackspace/requests/databases/create_user.rb +24 -0
  150. data/lib/fog/rackspace/requests/databases/delete_database.rb +15 -0
  151. data/lib/fog/rackspace/requests/databases/delete_instance.rb +15 -0
  152. data/lib/fog/rackspace/requests/databases/delete_user.rb +15 -0
  153. data/lib/fog/rackspace/requests/databases/enable_root_user.rb +15 -0
  154. data/lib/fog/rackspace/requests/databases/get_flavor.rb +15 -0
  155. data/lib/fog/rackspace/requests/databases/get_instance.rb +15 -0
  156. data/lib/fog/rackspace/requests/databases/list_databases.rb +15 -0
  157. data/lib/fog/rackspace/requests/databases/list_flavors.rb +15 -0
  158. data/lib/fog/rackspace/requests/databases/list_instances.rb +15 -0
  159. data/lib/fog/rackspace/requests/databases/list_users.rb +15 -0
  160. data/lib/fog/rackspace/requests/databases/resize_instance.rb +22 -0
  161. data/lib/fog/rackspace/requests/databases/resize_instance_volume.rb +24 -0
  162. data/lib/fog/rackspace/requests/databases/restart_instance.rb +20 -0
  163. data/lib/fog/rackspace/requests/identity/create_token.rb +25 -0
  164. data/lib/fog/rackspace/requests/identity/create_user.rb +25 -0
  165. data/lib/fog/rackspace/requests/identity/delete_user.rb +15 -0
  166. data/lib/fog/rackspace/requests/identity/get_credentials.rb +15 -0
  167. data/lib/fog/rackspace/requests/identity/get_user_by_id.rb +15 -0
  168. data/lib/fog/rackspace/requests/identity/get_user_by_name.rb +15 -0
  169. data/lib/fog/rackspace/requests/identity/list_credentials.rb +22 -0
  170. data/lib/fog/rackspace/requests/identity/list_tenants.rb +22 -0
  171. data/lib/fog/rackspace/requests/identity/list_user_roles.rb +22 -0
  172. data/lib/fog/rackspace/requests/identity/list_users.rb +22 -0
  173. data/lib/fog/rackspace/requests/identity/update_user.rb +24 -0
  174. data/lib/fog/rackspace/requests/load_balancers/get_ssl_termination.rb +15 -0
  175. data/lib/fog/rackspace/requests/load_balancers/remove_ssl_termination.rb +15 -0
  176. data/lib/fog/rackspace/requests/load_balancers/set_ssl_termination.rb +31 -0
  177. data/lib/fog/rackspace/storage.rb +1 -1
  178. data/lib/fog/vsphere/models/compute/server.rb +1 -0
  179. data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -2
  180. data/tests/aws/models/compute/address_tests.rb +2 -1
  181. data/tests/aws/models/compute/volume_tests.rb +1 -1
  182. data/tests/aws/models/dns/records_tests.rb +19 -1
  183. data/tests/aws/models/storage/directory_tests.rb +1 -1
  184. data/tests/aws/models/storage/url_tests.rb +7 -1
  185. data/tests/aws/requests/auto_scaling/auto_scaling_tests.rb +4 -2
  186. data/tests/aws/requests/compute/address_tests.rb +19 -1
  187. data/tests/aws/requests/elasticache/cache_cluster_tests.rb +4 -4
  188. data/tests/aws/requests/elb/helper.rb +13 -2
  189. data/tests/aws/requests/iam/access_key_tests.rb +1 -3
  190. data/tests/cloudstack/compute/models/security_group_rule_tests.rb +29 -0
  191. data/tests/cloudstack/compute/models/security_group_tests.rb +16 -0
  192. data/tests/cloudstack/compute/models/security_groups_tests.rb +19 -0
  193. data/tests/cloudstack/compute/models/server_tests.rb +18 -0
  194. data/tests/cloudstack/compute/models/volume_tests.rb +34 -0
  195. data/tests/cloudstack/compute/models/volumes_tests.rb +17 -0
  196. data/tests/compute/helper.rb +10 -3
  197. data/tests/core/current_machine_tests.rb +32 -0
  198. data/tests/helper.rb +1 -1
  199. data/tests/helpers/mock_helper.rb +3 -0
  200. data/tests/hp/requests/compute/address_tests.rb +2 -1
  201. data/tests/joyent/requests/compute/datasets_tests.rb +12 -3
  202. data/tests/local/models/file_tests.rb +43 -0
  203. data/tests/local/storage_tests.rb +40 -0
  204. data/tests/openstack/requests/compute/flavor_tests.rb +1 -1
  205. data/tests/openstack/requests/compute/server_tests.rb +3 -3
  206. data/tests/openstack/requests/compute/volume_tests.rb +1 -1
  207. data/tests/openstack/requests/identity/role_tests.rb +1 -1
  208. data/tests/rackspace/databases_tests.rb +26 -0
  209. data/tests/rackspace/models/databases/database_tests.rb +17 -0
  210. data/tests/rackspace/models/databases/databases_tests.rb +17 -0
  211. data/tests/rackspace/models/databases/flavors_tests.rb +20 -0
  212. data/tests/rackspace/models/databases/instance_tests.rb +43 -0
  213. data/tests/rackspace/models/databases/instances_tests.rb +14 -0
  214. data/tests/rackspace/models/databases/user_tests.rb +21 -0
  215. data/tests/rackspace/models/databases/users_tests.rb +21 -0
  216. data/tests/rackspace/models/identity/credentials_tests.rb +16 -0
  217. data/tests/rackspace/models/identity/roles_tests.rb +16 -0
  218. data/tests/rackspace/models/identity/tenants_tests.rb +21 -0
  219. data/tests/rackspace/models/identity/user_tests.rb +17 -0
  220. data/tests/rackspace/models/identity/users_tests.rb +17 -0
  221. data/tests/rackspace/models/load_balancers/load_balancer_tests.rb +20 -0
  222. data/tests/rackspace/requests/databases/database_tests.rb +36 -0
  223. data/tests/rackspace/requests/databases/flavor_tests.rb +16 -0
  224. data/tests/rackspace/requests/databases/helper.rb +84 -0
  225. data/tests/rackspace/requests/databases/instance_tests.rb +77 -0
  226. data/tests/rackspace/requests/databases/user_tests.rb +37 -0
  227. data/tests/rackspace/requests/identity/tenants_tests.rb +21 -0
  228. data/tests/rackspace/requests/identity/token_tests.rb +63 -0
  229. data/tests/rackspace/requests/identity/user_tests.rb +107 -0
  230. data/tests/rackspace/requests/load_balancers/helper.rb +70 -1
  231. data/tests/rackspace/requests/load_balancers/ssl_termination_tests.rb +38 -0
  232. data/tests/storage/models/file_tests.rb +1 -1
  233. metadata +129 -13
  234. data/spec/core/current_machine_spec.rb +0 -32
  235. data/spec/lib/fog/aws/parsers/sqs/receive_message_spec.rb +0 -58
  236. data/spec/spec_helper.rb +0 -8
@@ -3,9 +3,6 @@ module Fog
3
3
  class Cloudstack
4
4
  class Real
5
5
 
6
- # Creates an account.
7
- #
8
- # {CloudStack API Reference}[http://download.cloud.com/releases/2.2.0/api_2.2.4/global_admin/authorizeSecurityGroupIngress.html]
9
6
  def revoke_security_group_ingress(options={})
10
7
  options.merge!(
11
8
  'command' => 'revokeSecurityGroupIngress'
@@ -14,6 +11,35 @@ module Fog
14
11
  request(options)
15
12
  end
16
13
 
14
+ end # Real
15
+
16
+ class Mock
17
+ def revoke_security_group_ingress(options={})
18
+ unless security_group_rule_id = options['id']
19
+ raise Fog::Compute::Cloudstack::BadRequest.new('Unable to execute API command missing parameter id')
20
+ end
21
+
22
+ security_group = self.data[:security_groups].values.find do |group|
23
+ (rule = (group['ingressrule'] || []).find{|r| r['ruleid'] == security_group_rule_id}) && group['ingressrule'].delete(rule)
24
+ end
25
+
26
+ job_id = Fog::Cloudstack.uuid
27
+ job = {
28
+ "cmd" => "com.cloud.api.commands.revokeSecurityGroupIngress",
29
+ "created" => Time.now.iso8601,
30
+ "jobid" => job_id,
31
+ "jobstatus" => 1,
32
+ "jobprocstatus" => 0,
33
+ "jobresultcode" => 0,
34
+ "jobresulttype" => "object",
35
+ "jobresult" => { "securitygroup" => security_group }
36
+ }
37
+
38
+ self.data[:jobs][job_id]= job
39
+
40
+ {"revokesecuritygroupingress" => { "jobid" => job_id }}
41
+ end
42
+
17
43
  end
18
44
  end
19
45
  end
data/lib/fog/core.rb CHANGED
@@ -19,6 +19,7 @@ require 'fog/core/attributes'
19
19
  require 'fog/core/collection'
20
20
  require 'fog/core/connection'
21
21
  require 'fog/core/credentials'
22
+ require 'fog/core/current_machine'
22
23
  require 'fog/core/deprecation'
23
24
  require 'fog/core/errors'
24
25
  require 'fog/core/hmac'
@@ -186,7 +186,7 @@ module Fog
186
186
  end
187
187
 
188
188
  def dup_attributes!
189
- @attributes = @attributes.dup
189
+ @attributes = @attributes.dup if @attributes
190
190
  end
191
191
 
192
192
  private
@@ -1,4 +1,4 @@
1
-
1
+ require 'thread'
2
2
  module Fog
3
3
  class CurrentMachine
4
4
  @@lock = Mutex.new
@@ -24,7 +24,7 @@ module Fog
24
24
  # puts "Service timeout"
25
25
  # end
26
26
  #
27
- # @raise [Net::HTTPExceptions] if the net/http request fails.
27
+ # @raise [Excon::Errors::Error] if the net/http request fails.
28
28
  def self.ip_address
29
29
  @@lock.synchronize do
30
30
  @@ip_address ||= Excon.get(AMAZON_AWS_CHECK_IP).body.chomp
data/lib/fog/core/scp.rb CHANGED
@@ -52,6 +52,14 @@ module Fog
52
52
  raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH')
53
53
  end
54
54
 
55
+ if options[:key_data] || options[:keys]
56
+ options[:keys_only] = true
57
+ #Explicitly set these so net-ssh doesn't add the default keys
58
+ #as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
59
+ options[:keys] = [] unless options[:keys]
60
+ options[:key_data] = [] unless options[:key_data]
61
+ end
62
+
55
63
  @address = address
56
64
  @username = username
57
65
  @options = { :paranoid => false }.merge(options)
data/lib/fog/core/ssh.rb CHANGED
@@ -46,6 +46,14 @@ module Fog
46
46
  raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH')
47
47
  end
48
48
 
49
+ if options[:key_data] || options[:keys]
50
+ options[:keys_only] = true
51
+ #Explicitly set these so net-ssh doesn't add the default keys
52
+ #as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
53
+ options[:keys] = [] unless options[:keys]
54
+ options[:key_data] = [] unless options[:key_data]
55
+ end
56
+
49
57
  @address = address
50
58
  @username = username
51
59
  @options = { :paranoid => false }.merge(options)
@@ -65,7 +65,7 @@ module Fog
65
65
  @dynect_password = options[:dynect_password]
66
66
 
67
67
  @connection_options = options[:connection_options] || {}
68
- @host = "api2.dynect.net"
68
+ @host = 'api2.dynect.net'
69
69
  @port = options[:port] || 443
70
70
  @path = options[:path] || '/REST'
71
71
  @persistent = options[:persistent] || false
@@ -86,16 +86,25 @@ module Fog
86
86
  params[:headers] ||= {}
87
87
  params[:headers]['Content-Type'] = 'application/json'
88
88
  params[:headers]['API-Version'] = @version
89
- params[:headers]['Auth-Token'] = auth_token unless params[:path] == "Session"
89
+ params[:headers]['Auth-Token'] = auth_token unless params[:path] == 'Session'
90
90
  params[:path] = "#{@path}/#{params[:path]}" unless params[:path] =~ %r{^#{Regexp.escape(@path)}/}
91
+
91
92
  response = @connection.request(params.merge!({:host => @host}))
92
93
 
93
- if response.status == 307
94
- response = poll_job(response)
95
- elsif !response.body.empty?
94
+ if response.body.empty?
95
+ response.body = {}
96
+ else
96
97
  response.body = Fog::JSON.decode(response.body)
97
98
  end
98
99
 
100
+ if response.body['status'] == 'failure'
101
+ raise Error, response.body['msgs'].first['INFO']
102
+ end
103
+
104
+ if response.status == 307 && params[:path] !~ %r{^/REST/Job/}
105
+ response = poll_job(response)
106
+ end
107
+
99
108
  response
100
109
  rescue Excon::Errors::HTTPStatusError => error
101
110
  if @auth_token && error.message =~ /login: (Bad or expired credentials|inactivity logout)/
@@ -46,7 +46,7 @@ module Fog
46
46
  'volumeID' => options[:volume_id],
47
47
  'vlanID' => options[:vlan_id],
48
48
  'SecondaryIP' => options[:secondary_ip],
49
- 'isMiniEphemermal' => options[:is_mini_ephemeral],
49
+ 'isMiniEphemeral' => options[:is_mini_ephemeral],
50
50
  'Configuration Data' => options[:configuration_data],
51
51
  'antiCollocationInstance' => options[:anti_collocation_instance],
52
52
  }
@@ -8,7 +8,7 @@ module Fog
8
8
  end
9
9
 
10
10
  class Mock
11
- def create_volume(xml)
11
+ def create_volume(pool_name, xml)
12
12
 
13
13
  end
14
14
  end
@@ -20,7 +20,7 @@ module Fog
20
20
 
21
21
  def volume_to_attributes(vol)
22
22
 
23
- format_type = xml_element(vol.xml_desc, "/volume/target/format", "type")
23
+ format_type = xml_element(vol.xml_desc, "/volume/target/format", "type") rescue nil # not all volumes have types, e.g. LVM
24
24
  return nil if format_type == "dir"
25
25
 
26
26
  {
@@ -12,6 +12,8 @@ module Fog
12
12
  # attribute :content_type, :aliases => 'Content-Type'
13
13
  attribute :last_modified, :aliases => 'Last-Modified'
14
14
 
15
+ require 'uri'
16
+
15
17
  def body
16
18
  attributes[:body] ||= if last_modified
17
19
  collection.get(identity).body
@@ -73,7 +75,16 @@ module Fog
73
75
  end
74
76
 
75
77
  def public_url
76
- nil
78
+ requires :directory, :key
79
+
80
+ if connection.endpoint
81
+ escaped_directory = URI.escape(directory.key)
82
+ escaped_key = URI.escape(key)
83
+
84
+ ::File.join(connection.endpoint, escaped_directory, escaped_key)
85
+ else
86
+ nil
87
+ end
77
88
  end
78
89
 
79
90
  def save(options = {})
@@ -6,6 +6,7 @@ module Fog
6
6
  class Local < Fog::Service
7
7
 
8
8
  requires :local_root
9
+ recognizes :endpoint, :scheme, :host, :port, :path
9
10
 
10
11
  model_path 'fog/local/models/storage'
11
12
  collection :directories
@@ -13,8 +14,12 @@ module Fog
13
14
  model :file
14
15
  collection :files
15
16
 
17
+ require 'uri'
18
+
16
19
  class Mock
17
20
 
21
+ attr_reader :endpoint
22
+
18
23
  def self.data
19
24
  @data ||= Hash.new do |hash, key|
20
25
  hash[key] = {}
@@ -30,6 +35,8 @@ module Fog
30
35
 
31
36
  require 'mime/types'
32
37
  @local_root = ::File.expand_path(options[:local_root])
38
+
39
+ @endpoint = options[:endpoint] || build_endpoint_from_options(options)
33
40
  end
34
41
 
35
42
  def data
@@ -48,13 +55,23 @@ module Fog
48
55
  self.class.data.delete(@local_root)
49
56
  end
50
57
 
58
+ private
59
+ def build_endpoint_from_options(options)
60
+ return unless options[:host]
61
+
62
+ URI::Generic.build(options).to_s
63
+ end
51
64
  end
52
65
 
53
66
  class Real
54
67
 
68
+ attr_reader :endpoint
69
+
55
70
  def initialize(options={})
56
71
  require 'mime/types'
57
72
  @local_root = ::File.expand_path(options[:local_root])
73
+
74
+ @endpoint = options[:endpoint] || build_endpoint_from_options(options)
58
75
  end
59
76
 
60
77
  def local_root
@@ -69,9 +86,16 @@ module Fog
69
86
  require 'fileutils'
70
87
  source_path = path_to(::File.join(source_directory_name, source_object_name))
71
88
  target_path = path_to(::File.join(target_directory_name, target_object_name))
72
- ::FileUtils.mkdir_p(::File.dirname(source_path))
89
+ ::FileUtils.mkdir_p(::File.dirname(target_path))
73
90
  ::FileUtils.copy_file(source_path, target_path)
74
91
  end
92
+
93
+ private
94
+ def build_endpoint_from_options(options)
95
+ return unless options[:host]
96
+
97
+ URI::Generic.build(options).to_s
98
+ end
75
99
  end
76
100
 
77
101
  end
@@ -8,6 +8,7 @@ module Fog
8
8
  API_URL = "http://api.ninefold.com/compute/v1.0/"
9
9
 
10
10
  requires :ninefold_compute_key, :ninefold_compute_secret
11
+ recognizes :ninefold_api_url # allow us to specify non-prod environments
11
12
 
12
13
  model_path 'fog/ninefold/models/compute'
13
14
  model :server
data/lib/fog/openstack.rb CHANGED
@@ -50,6 +50,7 @@ module Fog
50
50
  connection = Fog::Connection.new(uri.to_s, false, connection_options)
51
51
  @openstack_api_key = options[:openstack_api_key]
52
52
  @openstack_username = options[:openstack_username]
53
+
53
54
  response = connection.request({
54
55
  :expects => [200, 204],
55
56
  :headers => {
@@ -63,7 +64,8 @@ module Fog
63
64
 
64
65
  return {
65
66
  :token => response.headers['X-Auth-Token'],
66
- :server_management_url => response.headers['X-Server-Management-Url']
67
+ :server_management_url => response.headers['X-Server-Management-Url'],
68
+ :identity_public_endpoint => response.headers['X-Keystone']
67
69
  }
68
70
  end
69
71
 
@@ -176,13 +176,24 @@ module Fog
176
176
  'minRam' => 0,
177
177
  'minDisk' => 0,
178
178
  'metadata' => {},
179
- 'links' => []
179
+ 'links' => [{"href"=>"http://nova1:8774/v1.1/admin/images/1", "rel"=>"self"}, {"href"=>"http://nova1:8774/admin/images/2", "rel"=>"bookmark"}]
180
180
  }
181
181
  },
182
182
  :servers => {},
183
183
  :key_pairs => {},
184
184
  :security_groups => {},
185
- :addresses => {}
185
+ :addresses => {},
186
+ :quota => {
187
+ 'metadata_items' => 128,
188
+ 'injected_file_content_bytes' => 10240,
189
+ 'injected_files' => 5,
190
+ 'gigabytes' => 1000,
191
+ 'ram' => 51200,
192
+ 'floating_ips' => 10,
193
+ 'instances' => 10,
194
+ 'volumes' => 10,
195
+ 'cores' => 20,
196
+ }
186
197
  }
187
198
  end
188
199
  end
@@ -7,10 +7,18 @@ module Fog
7
7
 
8
8
  class Servers < Fog::Collection
9
9
 
10
+ attribute :filters
11
+
10
12
  model Fog::Compute::OpenStack::Server
11
13
 
12
- def all
13
- data = connection.list_servers_detail.body['servers']
14
+ def initialize(attributes)
15
+ self.filters ||= {}
16
+ super
17
+ end
18
+
19
+ def all(filters = filters)
20
+ self.filters = filters
21
+ data = connection.list_servers_detail(filters).body['servers']
14
22
  load(data)
15
23
  end
16
24
 
@@ -55,7 +55,7 @@ module Fog
55
55
  response.body = {
56
56
  "flavor" => {
57
57
  "vcpus" => attributes[:vcpus],
58
- "disk" => attributes[:disc],
58
+ "disk" => attributes[:disk],
59
59
  "name" => attributes[:name],
60
60
  "links" => [
61
61
  {
@@ -70,7 +70,7 @@ module Fog
70
70
  "rxtx_factor" => attributes[:rxtx_factor] || 1,
71
71
  "OS-FLV-EXT-DATA:ephemeral" => attributes[:ephemeral] || 0,
72
72
  "ram" => attributes[:ram],
73
- "id" => 11,
73
+ "id" => "11",
74
74
  "swap" => attributes[:swap] || ""
75
75
  }
76
76
  }
@@ -31,7 +31,7 @@ module Fog
31
31
  "Content-Length" => "139",
32
32
  "Date" => Date.new}
33
33
  response.body = {
34
- "security_groups" => [{
34
+ "security_group" => [{
35
35
  "rules" => [],
36
36
  "tenant_id" => "d5183375ab0343f3a0b4b05f547aefc2",
37
37
  "id" => 999,
@@ -14,7 +14,7 @@ module Fog
14
14
 
15
15
  vanilla_options = ['metadata', 'accessIPv4', 'accessIPv6',
16
16
  'availability_zone', 'user_data', 'key_name',
17
- 'security_groups']
17
+ 'security_groups', 'adminPass']
18
18
  vanilla_options.select{|o| options[o]}.each do |key|
19
19
  data['server'][key] = options[key]
20
20
  end
@@ -42,7 +42,7 @@ module Fog
42
42
  'volumeType' => nil,
43
43
  'availabilityZone' => 'nova',
44
44
  'createdAt' => Time.now,
45
- 'attchments' => []
45
+ 'attachments' => []
46
46
  }
47
47
  }
48
48
  response
@@ -18,13 +18,13 @@ module Fog
18
18
  def get_flavor_details(flavor_ref)
19
19
  response = Excon::Response.new
20
20
  flavor = {
21
- '1' => { 'id' => '1', 'name' => '256 server', 'ram' => 256, 'disk' => 10, 'links' => [] },
22
- '2' => { 'id' => '2', 'name' => '512 server', 'ram' => 512, 'disk' => 20, 'links' => [] },
23
- '3' => { 'id' => '3', 'name' => '1GB server', 'ram' => 1024, 'disk' => 40, 'links' => [] },
24
- '4' => { 'id' => '4', 'name' => '2GB server', 'ram' => 2048, 'disk' => 80, 'links' => [] },
25
- '5' => { 'id' => '5', 'name' => '4GB server', 'ram' => 4096, 'disk' => 160, 'links' => [] },
26
- '6' => { 'id' => '6', 'name' => '8GB server', 'ram' => 8192, 'disk' => 320, 'links' => [] },
27
- '7' => { 'id' => '7', 'name' => '15.5GB server', 'ram' => 15872, 'disk' => 620, 'links' => [] }
21
+ '1' => { 'id' => '1', 'name' => '256 server', 'ram' => 256, 'disk' => 10, 'swap' => '1', 'vcpus' => 1, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => [] },
22
+ '2' => { 'id' => '2', 'name' => '512 server', 'ram' => 512, 'disk' => 20, 'swap' => '1', 'vcpus' => 2, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => [] },
23
+ '3' => { 'id' => '3', 'name' => '1GB server', 'ram' => 1024, 'disk' => 40, 'swap' => '2', 'vcpus' => 2, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => [] },
24
+ '4' => { 'id' => '4', 'name' => '2GB server', 'ram' => 2048, 'disk' => 80, 'swap' => '4', 'vcpus' => 4, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => [] },
25
+ '5' => { 'id' => '5', 'name' => '4GB server', 'ram' => 4096, 'disk' => 160, 'swap' => '8', 'vcpus' => 8, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => [] },
26
+ '6' => { 'id' => '6', 'name' => '8GB server', 'ram' => 8192, 'disk' => 320, 'swap' => '16', 'vcpus' => 16, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => [] },
27
+ '7' => { 'id' => '7', 'name' => '15.5GB server', 'ram' => 15872, 'disk' => 620, 'swap' => '32', 'vcpus' => 32, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => [] }
28
28
  }[flavor_ref]
29
29
  if flavor
30
30
  response.status = 200
@@ -19,18 +19,7 @@ module Fog
19
19
  response = Excon::Response.new
20
20
  response.status = 200
21
21
  response.body = {
22
- 'quota_set' => {
23
- 'metadata_items' => 128,
24
- 'injected_file_content_bytes' => 10240,
25
- 'injected_files' => 5,
26
- 'gigabytes' => 1000,
27
- 'ram' => 51200,
28
- 'floating_ips' => 10,
29
- 'instances' => 10,
30
- 'volumes' => 10,
31
- 'cores' => 20,
32
- 'id' => tenant_id
33
- }
22
+ 'quota_set' => (self.data[:quota_updated] or self.data[:quota]).merge({'id' => tenant_id})
34
23
  }
35
24
  response
36
25
  end