fog 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +5 -0
  3. data/Rakefile +14 -4
  4. data/bin/fog +22 -0
  5. data/changelog.txt +262 -0
  6. data/fog.gemspec +8 -4
  7. data/lib/fog/aws.rb +11 -0
  8. data/lib/fog/aws/auto_scaling.rb +15 -18
  9. data/lib/fog/aws/beanstalk.rb +8 -10
  10. data/lib/fog/aws/cloud_formation.rb +9 -12
  11. data/lib/fog/aws/compute.rb +8 -10
  12. data/lib/fog/aws/credential_fetcher.rb +6 -6
  13. data/lib/fog/aws/elasticache.rb +13 -17
  14. data/lib/fog/aws/elb.rb +29 -31
  15. data/lib/fog/aws/iam.rb +10 -13
  16. data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
  17. data/lib/fog/aws/models/compute/spot_request.rb +1 -11
  18. data/lib/fog/aws/models/rds/log_file.rb +26 -0
  19. data/lib/fog/aws/models/rds/log_files.rb +50 -0
  20. data/lib/fog/aws/models/rds/server.rb +3 -1
  21. data/lib/fog/aws/models/rds/snapshot.rb +1 -0
  22. data/lib/fog/aws/models/rds/snapshots.rb +20 -13
  23. data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
  24. data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
  25. data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
  26. data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
  27. data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
  28. data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
  29. data/lib/fog/aws/rds.rb +27 -14
  30. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  31. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
  32. data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
  33. data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
  34. data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
  35. data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
  36. data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
  37. data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
  38. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
  39. data/lib/fog/aws/requests/storage/get_object.rb +1 -1
  40. data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
  41. data/lib/fog/aws/ses.rb +26 -9
  42. data/lib/fog/aws/storage.rb +2 -1
  43. data/lib/fog/aws/sts.rb +31 -21
  44. data/lib/fog/bin.rb +0 -1
  45. data/lib/fog/bin/openstack.rb +5 -0
  46. data/lib/fog/brightbox/compute.rb +20 -212
  47. data/lib/fog/brightbox/compute/shared.rb +232 -0
  48. data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
  49. data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
  50. data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
  51. data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
  52. data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
  53. data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
  54. data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
  55. data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
  56. data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
  57. data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
  58. data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
  59. data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
  60. data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
  61. data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
  62. data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
  63. data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
  64. data/lib/fog/core.rb +7 -2
  65. data/lib/fog/core/connection.rb +62 -29
  66. data/lib/fog/core/deprecated/connection.rb +24 -0
  67. data/lib/fog/core/parser.rb +1 -1
  68. data/lib/fog/digitalocean/examples/getting_started.md +1 -1
  69. data/lib/fog/digitalocean/models/compute/server.rb +2 -2
  70. data/lib/fog/google/compute.rb +31 -7
  71. data/lib/fog/google/models/compute/disk.rb +80 -0
  72. data/lib/fog/google/models/compute/disks.rb +28 -0
  73. data/lib/fog/google/models/compute/image.rb +36 -0
  74. data/lib/fog/google/models/compute/server.rb +46 -33
  75. data/lib/fog/google/models/compute/servers.rb +15 -8
  76. data/lib/fog/google/requests/compute/delete_server.rb +5 -2
  77. data/lib/fog/google/requests/compute/get_disk.rb +3 -0
  78. data/lib/fog/google/requests/compute/get_server.rb +7 -1
  79. data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
  80. data/lib/fog/google/requests/compute/insert_server.rb +51 -22
  81. data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
  82. data/lib/fog/google/requests/storage/get_object.rb +1 -1
  83. data/lib/fog/hp/requests/storage/get_object.rb +1 -1
  84. data/lib/fog/hp/storage.rb +26 -9
  85. data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
  86. data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
  87. data/lib/fog/{core/json.rb → json.rb} +13 -2
  88. data/lib/fog/metering.rb +25 -0
  89. data/lib/fog/openstack.rb +1 -0
  90. data/lib/fog/openstack/metering.rb +215 -0
  91. data/lib/fog/openstack/models/compute/flavors.rb +2 -2
  92. data/lib/fog/openstack/models/compute/metadata.rb +1 -1
  93. data/lib/fog/openstack/models/compute/server.rb +5 -2
  94. data/lib/fog/openstack/models/image/images.rb +1 -1
  95. data/lib/fog/openstack/models/metering/meter.rb +0 -0
  96. data/lib/fog/openstack/models/metering/meters.rb +0 -0
  97. data/lib/fog/openstack/models/metering/resource.rb +24 -0
  98. data/lib/fog/openstack/models/metering/resources.rb +25 -0
  99. data/lib/fog/openstack/models/volume/volume.rb +3 -1
  100. data/lib/fog/openstack/models/volume/volumes.rb +2 -1
  101. data/lib/fog/openstack/network.rb +1 -1
  102. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  103. data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
  104. data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
  105. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
  106. data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
  107. data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
  108. data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
  109. data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
  110. data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
  111. data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
  112. data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
  113. data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
  114. data/lib/fog/rackspace.rb +16 -1
  115. data/lib/fog/rackspace/block_storage.rb +13 -28
  116. data/lib/fog/rackspace/cdn.rb +10 -24
  117. data/lib/fog/rackspace/compute.rb +17 -45
  118. data/lib/fog/rackspace/compute_v2.rb +13 -33
  119. data/lib/fog/rackspace/databases.rb +13 -29
  120. data/lib/fog/rackspace/dns.rb +27 -23
  121. data/lib/fog/rackspace/identity.rb +10 -26
  122. data/lib/fog/rackspace/load_balancers.rb +13 -29
  123. data/lib/fog/rackspace/mock_data.rb +3 -3
  124. data/lib/fog/rackspace/models/compute/server.rb +1 -1
  125. data/lib/fog/rackspace/models/dns/zones.rb +34 -21
  126. data/lib/fog/rackspace/models/identity/users.rb +2 -2
  127. data/lib/fog/rackspace/models/storage/file.rb +1 -0
  128. data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
  129. data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
  130. data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
  131. data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
  132. data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
  133. data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
  134. data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
  135. data/lib/fog/rackspace/service.rb +43 -1
  136. data/lib/fog/rackspace/storage.rb +25 -43
  137. data/lib/fog/riakcs/provisioning.rb +2 -1
  138. data/lib/fog/riakcs/usage.rb +2 -1
  139. data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
  140. data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
  141. data/lib/fog/version.rb +1 -1
  142. data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
  143. data/lib/fog/xenserver/compute.rb +2 -0
  144. data/lib/fog/xenserver/models/compute/server.rb +9 -7
  145. data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
  146. data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
  147. data/lib/fog/xml.rb +21 -0
  148. data/lib/fog/xml/sax_parser_connection.rb +43 -0
  149. data/lib/tasks/changelog_task.rb +1 -0
  150. data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
  151. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  152. data/tests/aws/requests/rds/helper.rb +14 -0
  153. data/tests/aws/requests/rds/log_file_tests.rb +19 -0
  154. data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
  155. data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
  156. data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
  157. data/tests/brightbox/requests/compute/helper.rb +46 -2
  158. data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
  159. data/tests/core/connection_tests.rb +26 -0
  160. data/tests/helper.rb +13 -0
  161. data/tests/openstack/requests/metering/meter_tests.rb +52 -0
  162. data/tests/openstack/requests/metering/resource_tests.rb +19 -0
  163. data/tests/openvz/helper.rb +14 -8
  164. data/tests/rackspace/block_storage_tests.rb +9 -0
  165. data/tests/rackspace/compute_tests.rb +9 -0
  166. data/tests/rackspace/compute_v2_tests.rb +9 -0
  167. data/tests/rackspace/databases_tests.rb +9 -0
  168. data/tests/rackspace/dns_tests.rb +20 -0
  169. data/tests/rackspace/helper.rb +12 -1
  170. data/tests/rackspace/identity_tests.rb +25 -0
  171. data/tests/rackspace/load_balancer_tests.rb +10 -0
  172. data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
  173. data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
  174. data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
  175. data/tests/rackspace/models/dns/zones_tests.rb +19 -5
  176. data/tests/rackspace/models/storage/file_tests.rb +22 -6
  177. data/tests/rackspace/rackspace_tests.rb +35 -0
  178. data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
  179. data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
  180. data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
  181. data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
  182. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
  183. data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
  184. data/tests/rackspace/requests/databases/database_tests.rb +23 -20
  185. data/tests/rackspace/requests/databases/user_tests.rb +6 -6
  186. data/tests/rackspace/requests/identity/user_tests.rb +4 -1
  187. data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
  188. data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
  189. data/tests/rackspace/requests/storage/object_tests.rb +73 -18
  190. data/tests/rackspace/service_tests.rb +83 -0
  191. data/tests/rackspace/storage_tests.rb +9 -0
  192. data/tests/xenserver/models/compute/server_tests.rb +11 -1
  193. metadata +89 -19
  194. data/tests/core/user_agent_tests.rb +0 -6
@@ -131,16 +131,14 @@ module Fog
131
131
  :parser => parser
132
132
  })
133
133
  rescue Excon::Errors::HTTPStatusError => error
134
- if match = error.message.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)
135
- raise case match[1].split('.').last
136
- when 'InvalidParameterValue'
137
- Fog::AWS::ElasticBeanstalk::InvalidParameterError.slurp(error, match[2])
138
- else
139
- Fog::AWS::ElasticBeanstalk::Error.slurp(error, "#{match[1]} => #{match[2]}")
140
- end
141
- else
142
- raise error
143
- end
134
+ match = Fog::AWS::Errors.match_error(error)
135
+ raise if match.empty?
136
+ raise case match[:code]
137
+ when 'InvalidParameterValue'
138
+ Fog::AWS::ElasticBeanstalk::InvalidParameterError.slurp(error, match[:message])
139
+ else
140
+ Fog::AWS::ElasticBeanstalk::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
141
+ end
144
142
  end
145
143
 
146
144
  end
@@ -98,7 +98,7 @@ module Fog
98
98
  )
99
99
 
100
100
  begin
101
- response = @connection.request({
101
+ @connection.request({
102
102
  :body => body,
103
103
  :expects => 200,
104
104
  :idempotent => idempotent,
@@ -108,19 +108,16 @@ module Fog
108
108
  :parser => parser
109
109
  })
110
110
  rescue Excon::Errors::HTTPStatusError => error
111
- if match = error.message.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)
112
- raise case match[1].split('.').last
113
- when 'NotFound', 'ValidationError'
114
- Fog::AWS::CloudFormation::NotFound.slurp(error, match[2])
115
- else
116
- Fog::AWS::CloudFormation::Error.slurp(error, "#{match[1]} => #{match[2]}")
117
- end
118
- else
119
- raise error
120
- end
111
+ match = Fog::AWS::Errors.match_error(error)
112
+ raise if match.empty?
113
+ raise case match[:code]
114
+ when 'NotFound', 'ValidationError'
115
+ Fog::AWS::CloudFormation::NotFound.slurp(error, match[:message])
116
+ else
117
+ Fog::AWS::CloudFormation::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
118
+ end
121
119
  end
122
120
 
123
- response
124
121
  end
125
122
 
126
123
  end
@@ -392,16 +392,14 @@ module Fog
392
392
  :parser => parser
393
393
  })
394
394
  rescue Excon::Errors::HTTPStatusError => error
395
- if match = error.message.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)
396
- raise case match[1].split('.').last
397
- when 'NotFound', 'Unknown'
398
- Fog::Compute::AWS::NotFound.slurp(error, match[2])
399
- else
400
- Fog::Compute::AWS::Error.slurp(error, "#{match[1]} => #{match[2]}")
401
- end
402
- else
403
- raise error
404
- end
395
+ match = Fog::AWS::Errors.match_error(error)
396
+ raise if match.empty?
397
+ raise case match[:code]
398
+ when 'NotFound', 'Unknown'
399
+ Fog::Compute::AWS::NotFound.slurp(error, match[:message])
400
+ else
401
+ Fog::Compute::AWS::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
402
+ end
405
403
  end
406
404
 
407
405
  end
@@ -1,4 +1,5 @@
1
- require 'fog/core/json'
1
+ require "fog/json"
2
+
2
3
  module Fog
3
4
  module AWS
4
5
  module CredentialFetcher
@@ -14,7 +15,7 @@ module Fog
14
15
 
15
16
  session = Fog::JSON.decode(role_data)
16
17
  credentials = {}
17
- credentials[:aws_access_key_id] = session['AccessKeyId']
18
+ credentials[:aws_access_key_id] = session['AccessKeyId']
18
19
  credentials[:aws_secret_access_key] = session['SecretAccessKey']
19
20
  credentials[:aws_session_token] = session['Token']
20
21
  credentials[:aws_credentials_expire_at] = Time.xmlschema session['Expiration']
@@ -31,7 +32,7 @@ module Fog
31
32
  end
32
33
 
33
34
  module ConnectionMethods
34
-
35
+
35
36
  def refresh_credentials_if_expired
36
37
  refresh_credentials if credentials_expired?
37
38
  end
@@ -39,8 +40,8 @@ module Fog
39
40
  private
40
41
 
41
42
  def credentials_expired?
42
- @use_iam_profile &&
43
- (!@aws_credentials_expire_at ||
43
+ @use_iam_profile &&
44
+ (!@aws_credentials_expire_at ||
44
45
  (@aws_credentials_expire_at && Fog::Time.now > @aws_credentials_expire_at - 15)) #new credentials become available from around 5 minutes before expiration time
45
46
  end
46
47
 
@@ -61,4 +62,3 @@ module Fog
61
62
  end
62
63
  end
63
64
  end
64
-
@@ -94,7 +94,7 @@ module Fog
94
94
  )
95
95
 
96
96
  begin
97
- response = @connection.request({
97
+ @connection.request({
98
98
  :body => body,
99
99
  :expects => 200,
100
100
  :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
@@ -104,24 +104,20 @@ module Fog
104
104
  :parser => parser
105
105
  })
106
106
  rescue Excon::Errors::HTTPStatusError => error
107
- if match = error.message.match(/(?:.*<Code>(.*)<\/Code>?)/m)
108
- case match[1]
109
- when 'CacheSecurityGroupNotFound', 'CacheParameterGroupNotFound',
110
- 'CacheClusterNotFound'
111
- raise Fog::AWS::Elasticache::NotFound
112
- when 'CacheSecurityGroupAlreadyExists'
113
- raise Fog::AWS::Elasticache::IdentifierTaken
114
- when 'InvalidParameterValue'
115
- raise Fog::AWS::Elasticache::InvalidInstance
116
- else
117
- raise
118
- end
119
- else
120
- raise
121
- end
107
+ match = Fog::AWS::Errors.match_error(error)
108
+ raise if match.empty?
109
+ raise case match[:code]
110
+ when 'CacheSecurityGroupNotFound', 'CacheParameterGroupNotFound', 'CacheClusterNotFound'
111
+ Fog::AWS::Elasticache::NotFound.slurp(error, match[:message])
112
+ when 'CacheSecurityGroupAlreadyExists'
113
+ Fog::AWS::Elasticache::IdentifierTaken.slurp(error, match[:message])
114
+ when 'InvalidParameterValue'
115
+ Fog::AWS::Elasticache::InvalidInstance.slurp(error, match[:message])
116
+ else
117
+ Fog::AWS::Elasticache::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
118
+ end
122
119
  end
123
120
 
124
- response
125
121
  end
126
122
 
127
123
  end
@@ -191,37 +191,35 @@ module Fog
191
191
  :parser => parser
192
192
  })
193
193
  rescue Excon::Errors::HTTPStatusError => error
194
- if match = error.message.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)
195
- case match[1]
196
- when 'CertificateNotFound'
197
- raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
198
- when 'DuplicateLoadBalancerName'
199
- raise Fog::AWS::ELB::IdentifierTaken.slurp(error, match[2])
200
- when 'DuplicatePolicyName'
201
- raise Fog::AWS::ELB::DuplicatePolicyName.slurp(error, match[2])
202
- when 'InvalidInstance'
203
- raise Fog::AWS::ELB::InvalidInstance.slurp(error, match[2])
204
- when 'InvalidConfigurationRequest'
205
- # when do they fucking use this shit?
206
- raise Fog::AWS::ELB::InvalidConfigurationRequest.slurp(error, match[2])
207
- when 'LoadBalancerNotFound'
208
- raise Fog::AWS::ELB::NotFound.slurp(error, match[2])
209
- when 'PolicyNotFound'
210
- raise Fog::AWS::ELB::PolicyNotFound.slurp(error, match[2])
211
- when 'PolicyTypeNotFound'
212
- raise Fog::AWS::ELB::PolicyTypeNotFound.slurp(error, match[2])
213
- when 'Throttling'
214
- raise Fog::AWS::ELB::Throttled.slurp(error, match[2])
215
- when 'TooManyPolicies'
216
- raise Fog::AWS::ELB::TooManyPolicies.slurp(error, match[2])
217
- when 'ValidationError'
218
- raise Fog::AWS::ELB::ValidationError.slurp(error, match[2])
219
- else
220
- raise
221
- end
222
- else
223
- raise
224
- end
194
+ match = Fog::AWS::Errors.match_error(error)
195
+ raise if match.empty?
196
+ raise case match[:code]
197
+ when 'CertificateNotFound'
198
+ Fog::AWS::IAM::NotFound.slurp(error, match[:message])
199
+ when 'DuplicateLoadBalancerName'
200
+ Fog::AWS::ELB::IdentifierTaken.slurp(error, match[:message])
201
+ when 'DuplicatePolicyName'
202
+ Fog::AWS::ELB::DuplicatePolicyName.slurp(error, match[:message])
203
+ when 'InvalidInstance'
204
+ Fog::AWS::ELB::InvalidInstance.slurp(error, match[:message])
205
+ when 'InvalidConfigurationRequest'
206
+ # when do they fucking use this shit?
207
+ Fog::AWS::ELB::InvalidConfigurationRequest.slurp(error, match[:message])
208
+ when 'LoadBalancerNotFound'
209
+ Fog::AWS::ELB::NotFound.slurp(error, match[:message])
210
+ when 'PolicyNotFound'
211
+ Fog::AWS::ELB::PolicyNotFound.slurp(error, match[:message])
212
+ when 'PolicyTypeNotFound'
213
+ Fog::AWS::ELB::PolicyTypeNotFound.slurp(error, match[:message])
214
+ when 'Throttling'
215
+ Fog::AWS::ELB::Throttled.slurp(error, match[:message])
216
+ when 'TooManyPolicies'
217
+ Fog::AWS::ELB::TooManyPolicies.slurp(error, match[:message])
218
+ when 'ValidationError'
219
+ Fog::AWS::ELB::ValidationError.slurp(error, match[:message])
220
+ else
221
+ Fog::AWS::ELB::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
222
+ end
225
223
  end
226
224
  end
227
225
  end
@@ -208,19 +208,16 @@ module Fog
208
208
  :parser => parser
209
209
  })
210
210
  rescue Excon::Errors::HTTPStatusError => error
211
- if match = error.message.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)
212
- case match[1]
213
- when 'CertificateNotFound', 'NoSuchEntity'
214
- raise Fog::AWS::IAM::NotFound.slurp(error, match[2])
215
- when 'EntityAlreadyExists', 'KeyPairMismatch', 'LimitExceeded', 'MalformedCertificate', 'ValidationError'
216
- raise Fog::AWS::IAM.const_get(match[1]).slurp(error, match[2])
217
- else
218
- raise Fog::AWS::IAM::Error.slurp(error, "#{match[1]} => #{match[2]}") if match[1]
219
- raise
220
- end
221
- else
222
- raise
223
- end
211
+ match = Fog::AWS::Errors.match_error(error)
212
+ raise if match.empty?
213
+ raise case match[:code]
214
+ when 'CertificateNotFound', 'NoSuchEntity'
215
+ Fog::AWS::IAM::NotFound.slurp(error, match[:message])
216
+ when 'EntityAlreadyExists', 'KeyPairMismatch', 'LimitExceeded', 'MalformedCertificate', 'ValidationError'
217
+ Fog::AWS::IAM.const_get(match[:code]).slurp(error, match[:message])
218
+ else
219
+ Fog::AWS::IAM::Error.slurp(error, "#{match[:code]} => #{match[:message]}")
220
+ end
224
221
  end
225
222
 
226
223
  end
@@ -111,8 +111,7 @@ module Fog
111
111
  requires :launch_configuration_name
112
112
  requires :max_size
113
113
  requires :min_size
114
-
115
- service.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size, options)
114
+ service.create_auto_scaling_group(id, availability_zones, launch_configuration_name, max_size, min_size, filtered_options(:create_auto_scaling_group))
116
115
  reload
117
116
  end
118
117
 
@@ -132,10 +131,14 @@ module Fog
132
131
 
133
132
  def update
134
133
  requires :id
135
- service.update_auto_scaling_group(id, options)
134
+ service.update_auto_scaling_group(id, filtered_options(:update_auto_scaling_group) )
136
135
  reload
137
136
  end
138
137
 
138
+ def filtered_options(method)
139
+ Hash[options.select{|k,_| ExpectedOptions[method].include?(k)}]
140
+ end
141
+
139
142
  def options
140
143
  ret = Hash[self.class.aliases.map { |key, value| [key, send(value)] }]
141
144
  ret.delete_if { |key, value| value.nil? }
@@ -95,7 +95,7 @@ module Fog
95
95
  'LaunchSpecification.KeyName' => key_name,
96
96
  'LaunchSpecification.Monitoring.Enabled' => monitoring,
97
97
  'LaunchSpecification.Placement.AvailabilityZone' => availability_zone,
98
- 'LaunchSpecification.SecurityGroup' => groups,
98
+ 'LaunchSpecification.SecurityGroupId' => groups,
99
99
  'LaunchSpecification.EbsOptimized' => ebs_optimized,
100
100
  'LaunchSpecification.UserData' => user_data,
101
101
  'LaunchSpecification.SubnetId' => subnet_id,
@@ -106,16 +106,6 @@ module Fog
106
106
  'ValidUntil' => valid_until }
107
107
  options.delete_if {|key, value| value.nil?}
108
108
 
109
- # If subnet is defined then this is a Virtual Private Cloud.
110
- # subnet & security group cannot co-exist. Attempting to specify
111
- # both subnet and groups will cause an error. Instead please make
112
- # use of Security Group Ids when working in a VPC.
113
- if subnet_id
114
- options.delete('LaunchSpecification.SecurityGroup')
115
- else
116
- options.delete('LaunchSpecification.SubnetId')
117
- end
118
-
119
109
  data = service.request_spot_instances(image_id, flavor_id, price, options).body
120
110
  spot_instance_request = data['spotInstanceRequestSet'].first
121
111
  spot_instance_request['launchSpecification'].each do |name,value|
@@ -0,0 +1,26 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module AWS
5
+ class RDS
6
+
7
+ class LogFile < Fog::Model
8
+
9
+ attribute :rds_id, :aliases => 'DBInstanceIdentifier'
10
+ attribute :name, :aliases => 'LogFileName'
11
+ attribute :size, :aliases => 'Size', :type => :integer
12
+ attribute :last_written, :aliases => 'LastWritten', :type => :time
13
+ attribute :content, :aliases => 'LogFileData'
14
+ attribute :marker, :aliases => 'Marker'
15
+ attribute :more_content_available, :aliases => 'AdditionalDataPending', :type => :boolean
16
+
17
+ def content_excerpt(marker=nil)
18
+ result = service.download_db_logfile_portion(self.rds_id, self.name, {:marker => marker})
19
+ merge_attributes(result.body['DownloadDBLogFilePortionResult'])
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,50 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/aws/models/rds/log_file'
3
+
4
+ module Fog
5
+ module AWS
6
+ class RDS
7
+
8
+ class LogFiles < Fog::Collection
9
+ attribute :filters
10
+ attribute :rds_id
11
+ model Fog::AWS::RDS::LogFile
12
+
13
+ def initialize(attributes)
14
+ self.filters ||= {}
15
+ super
16
+ end
17
+
18
+ # This method deliberately returns only a single page of results
19
+ def all(filters=filters)
20
+ self.filters.merge!(filters)
21
+
22
+ result = service.describe_db_log_files(rds_id, self.filters).body['DescribeDBLogFilesResult']
23
+ self.filters[:marker] = result['Marker']
24
+ load(result['DBLogFiles'])
25
+ end
26
+
27
+ def each(filters=filters)
28
+ if block_given?
29
+ begin
30
+ page = self.all(filters)
31
+ # We need to explicitly use the base 'each' method here on the page, otherwise we get infinite recursion
32
+ base_each = Fog::Collection.instance_method(:each)
33
+ base_each.bind(page).call { |log_file| yield log_file }
34
+ end while self.filters[:marker]
35
+ end
36
+ self
37
+ end
38
+
39
+ def get(file_name=nil)
40
+ if file_name
41
+ matches = self.select {|log_file| log_file.name.upcase == file_name.upcase}
42
+ return matches.first unless matches.empty?
43
+ end
44
+ rescue Fog::AWS::RDS::NotFound
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -30,6 +30,7 @@ module Fog
30
30
  attribute :backup_retention_period, :aliases => 'BackupRetentionPeriod', :type => :integer
31
31
  attribute :license_model, :aliases => 'LicenseModel'
32
32
  attribute :db_subnet_group_name, :aliases => 'DBSubnetGroupName'
33
+ attribute :publicly_accessible, :aliases => 'PubliclyAccessible'
33
34
 
34
35
  attr_accessor :password, :parameter_group_name, :security_group_names, :port
35
36
 
@@ -120,7 +121,8 @@ module Fog
120
121
  'PreferredBackupWindow' => preferred_backup_window,
121
122
  'MultiAZ' => multi_az,
122
123
  'LicenseModel' => license_model,
123
- 'DBSubnetGroupName' => db_subnet_group_name
124
+ 'DBSubnetGroupName' => db_subnet_group_name,
125
+ 'PubliclyAccessible' => publicly_accessible
124
126
  }
125
127
 
126
128
  options.delete_if {|key, value| value.nil?}
@@ -18,6 +18,7 @@ module Fog
18
18
  attribute :allocated_storage, :aliases => 'AllocatedStorage', :type => :integer
19
19
  attribute :availability_zone, :aliases => 'AvailabilityZone'
20
20
  attribute :type, :aliases => 'SnapshotType'
21
+ attribute :publicly_accessible, :aliases => 'PubliclyAccessible'
21
22
 
22
23
  def ready?
23
24
  state == 'available'
@@ -21,26 +21,33 @@ module Fog
21
21
  super
22
22
  end
23
23
 
24
- # This will return a single page based on the current or provided filters,
25
- # updating the filters with the marker for the next page. Calling this repeatedly
26
- # will iterate through pages.
24
+ # This method does NOT return all snapshots. Its implementation deliberately returns a single page
25
+ # of results for any one call. It will return a single page based on the current or provided filters,
26
+ # updating the filters with the marker for the next page. Calling this repeatedly will iterate
27
+ # through pages. See the implementation of each for an example of such iteration.
28
+ #
29
+ # It is arguably incorrect for the method not to return all snapshots, particularly considering the
30
+ # implementation in the corresponding 'elb' files. But this implementation has been released, and
31
+ # backwards-compatibility requires leaving it as implemented.
27
32
  def all(filters = filters)
28
33
  self.filters.merge!(filters)
29
34
 
30
- snapshots = service.describe_db_snapshots(filters)
31
- self.filters[:marker] = snapshots.body['DescribeDBSnapshotsResult']['Marker']
32
- data = snapshots.body['DescribeDBSnapshotsResult']['DBSnapshots']
33
- load(data)
35
+ page = service.describe_db_snapshots(self.filters).body['DescribeDBSnapshotsResult']
36
+ self.filters[:marker] = page['Marker']
37
+ load(page['DBSnapshots'])
34
38
  end
35
39
 
36
40
  # This will execute a block for each snapshot, fetching new pages of snapshots as required.
37
41
  def each(filters = filters)
38
- begin
39
- page = self.all(filters)
40
- # We need to explicitly use the base 'each' method here on the page, otherwise we get infinite recursion
41
- base_each = Fog::Collection.instance_method(:each)
42
- base_each.bind(page).call {|snapshot| yield snapshot}
43
- end while self.filters[:marker]
42
+ if block_given?
43
+ begin
44
+ page = self.all(filters)
45
+ # We need to explicitly use the base 'each' method here on the page, otherwise we get infinite recursion
46
+ base_each = Fog::Collection.instance_method(:each)
47
+ base_each.bind(page).call { |snapshot| yield snapshot }
48
+ end while self.filters[:marker]
49
+ end
50
+ self
44
51
  end
45
52
 
46
53
  def get(identity)