fog-aws 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fog/aws.rb +205 -28
  3. data/lib/fog/aws/auto_scaling.rb +0 -2
  4. data/lib/fog/aws/beanstalk.rb +0 -2
  5. data/lib/fog/aws/cdn.rb +0 -2
  6. data/lib/fog/aws/cloud_formation.rb +0 -2
  7. data/lib/fog/aws/cloud_watch.rb +0 -2
  8. data/lib/fog/aws/compute.rb +0 -2
  9. data/lib/fog/aws/credential_fetcher.rb +0 -2
  10. data/lib/fog/aws/data_pipeline.rb +0 -2
  11. data/lib/fog/aws/dns.rb +0 -2
  12. data/lib/fog/aws/dynamodb.rb +0 -2
  13. data/lib/fog/aws/elasticache.rb +0 -2
  14. data/lib/fog/aws/elb.rb +0 -2
  15. data/lib/fog/aws/emr.rb +0 -2
  16. data/lib/fog/aws/errors.rb +14 -0
  17. data/lib/fog/aws/federation.rb +0 -2
  18. data/lib/fog/aws/glacier.rb +0 -2
  19. data/lib/fog/aws/iam.rb +0 -2
  20. data/lib/fog/aws/mock.rb +170 -0
  21. data/lib/fog/aws/models/auto_scaling/activity.rb +0 -2
  22. data/lib/fog/aws/models/auto_scaling/configuration.rb +0 -2
  23. data/lib/fog/aws/models/auto_scaling/group.rb +0 -2
  24. data/lib/fog/aws/models/auto_scaling/instance.rb +0 -2
  25. data/lib/fog/aws/models/auto_scaling/policy.rb +0 -2
  26. data/lib/fog/aws/models/beanstalk/application.rb +0 -2
  27. data/lib/fog/aws/models/beanstalk/applications.rb +0 -1
  28. data/lib/fog/aws/models/beanstalk/environment.rb +0 -2
  29. data/lib/fog/aws/models/beanstalk/environments.rb +0 -1
  30. data/lib/fog/aws/models/beanstalk/event.rb +0 -2
  31. data/lib/fog/aws/models/beanstalk/events.rb +0 -1
  32. data/lib/fog/aws/models/beanstalk/template.rb +0 -2
  33. data/lib/fog/aws/models/beanstalk/templates.rb +0 -1
  34. data/lib/fog/aws/models/beanstalk/version.rb +0 -2
  35. data/lib/fog/aws/models/beanstalk/versions.rb +0 -1
  36. data/lib/fog/aws/models/cdn/distribution.rb +0 -1
  37. data/lib/fog/aws/models/cdn/distribution_helper.rb +0 -2
  38. data/lib/fog/aws/models/cdn/distributions.rb +0 -1
  39. data/lib/fog/aws/models/cdn/distributions_helper.rb +0 -2
  40. data/lib/fog/aws/models/cdn/invalidation.rb +0 -2
  41. data/lib/fog/aws/models/cdn/invalidations.rb +0 -1
  42. data/lib/fog/aws/models/cdn/streaming_distribution.rb +0 -1
  43. data/lib/fog/aws/models/cdn/streaming_distributions.rb +0 -1
  44. data/lib/fog/aws/models/cloud_watch/alarm.rb +0 -2
  45. data/lib/fog/aws/models/cloud_watch/alarm_data.rb +0 -1
  46. data/lib/fog/aws/models/cloud_watch/alarm_datum.rb +0 -2
  47. data/lib/fog/aws/models/cloud_watch/alarm_histories.rb +0 -1
  48. data/lib/fog/aws/models/cloud_watch/alarm_history.rb +0 -2
  49. data/lib/fog/aws/models/cloud_watch/alarms.rb +0 -1
  50. data/lib/fog/aws/models/cloud_watch/metric.rb +0 -2
  51. data/lib/fog/aws/models/cloud_watch/metric_statistic.rb +0 -2
  52. data/lib/fog/aws/models/cloud_watch/metric_statistics.rb +0 -1
  53. data/lib/fog/aws/models/cloud_watch/metrics.rb +0 -1
  54. data/lib/fog/aws/models/compute/address.rb +0 -2
  55. data/lib/fog/aws/models/compute/addresses.rb +0 -1
  56. data/lib/fog/aws/models/compute/dhcp_option.rb +0 -2
  57. data/lib/fog/aws/models/compute/dhcp_options.rb +0 -1
  58. data/lib/fog/aws/models/compute/flavor.rb +0 -2
  59. data/lib/fog/aws/models/compute/flavors.rb +0 -1
  60. data/lib/fog/aws/models/compute/image.rb +0 -2
  61. data/lib/fog/aws/models/compute/images.rb +0 -1
  62. data/lib/fog/aws/models/compute/internet_gateway.rb +0 -2
  63. data/lib/fog/aws/models/compute/internet_gateways.rb +0 -1
  64. data/lib/fog/aws/models/compute/key_pair.rb +0 -2
  65. data/lib/fog/aws/models/compute/key_pairs.rb +0 -1
  66. data/lib/fog/aws/models/compute/network_acl.rb +0 -2
  67. data/lib/fog/aws/models/compute/network_acls.rb +0 -1
  68. data/lib/fog/aws/models/compute/network_interface.rb +0 -2
  69. data/lib/fog/aws/models/compute/network_interfaces.rb +0 -1
  70. data/lib/fog/aws/models/compute/route_table.rb +0 -2
  71. data/lib/fog/aws/models/compute/route_tables.rb +0 -1
  72. data/lib/fog/aws/models/compute/security_group.rb +0 -2
  73. data/lib/fog/aws/models/compute/security_groups.rb +0 -1
  74. data/lib/fog/aws/models/compute/servers.rb +1 -2
  75. data/lib/fog/aws/models/compute/snapshot.rb +0 -2
  76. data/lib/fog/aws/models/compute/snapshots.rb +0 -1
  77. data/lib/fog/aws/models/compute/spot_requests.rb +0 -1
  78. data/lib/fog/aws/models/compute/subnet.rb +0 -2
  79. data/lib/fog/aws/models/compute/subnets.rb +0 -1
  80. data/lib/fog/aws/models/compute/tag.rb +0 -2
  81. data/lib/fog/aws/models/compute/tags.rb +0 -1
  82. data/lib/fog/aws/models/compute/volume.rb +0 -2
  83. data/lib/fog/aws/models/compute/volumes.rb +0 -1
  84. data/lib/fog/aws/models/compute/vpc.rb +0 -2
  85. data/lib/fog/aws/models/compute/vpcs.rb +0 -1
  86. data/lib/fog/aws/models/data_pipeline/pipeline.rb +0 -2
  87. data/lib/fog/aws/models/data_pipeline/pipelines.rb +0 -1
  88. data/lib/fog/aws/models/dns/record.rb +0 -2
  89. data/lib/fog/aws/models/dns/records.rb +0 -1
  90. data/lib/fog/aws/models/dns/zone.rb +0 -1
  91. data/lib/fog/aws/models/dns/zones.rb +0 -1
  92. data/lib/fog/aws/models/elasticache/cluster.rb +0 -2
  93. data/lib/fog/aws/models/elasticache/clusters.rb +0 -1
  94. data/lib/fog/aws/models/elasticache/parameter_group.rb +0 -2
  95. data/lib/fog/aws/models/elasticache/parameter_groups.rb +0 -1
  96. data/lib/fog/aws/models/elasticache/security_group.rb +0 -2
  97. data/lib/fog/aws/models/elasticache/security_groups.rb +0 -1
  98. data/lib/fog/aws/models/elasticache/subnet_group.rb +0 -2
  99. data/lib/fog/aws/models/elasticache/subnet_groups.rb +0 -1
  100. data/lib/fog/aws/models/elb/backend_server_description.rb +0 -1
  101. data/lib/fog/aws/models/elb/listener.rb +0 -1
  102. data/lib/fog/aws/models/elb/load_balancer.rb +0 -1
  103. data/lib/fog/aws/models/elb/policy.rb +0 -1
  104. data/lib/fog/aws/models/glacier/archive.rb +0 -2
  105. data/lib/fog/aws/models/glacier/archives.rb +0 -1
  106. data/lib/fog/aws/models/glacier/job.rb +0 -2
  107. data/lib/fog/aws/models/glacier/jobs.rb +0 -1
  108. data/lib/fog/aws/models/glacier/vault.rb +0 -1
  109. data/lib/fog/aws/models/glacier/vaults.rb +0 -1
  110. data/lib/fog/aws/models/iam/access_key.rb +0 -2
  111. data/lib/fog/aws/models/iam/access_keys.rb +0 -1
  112. data/lib/fog/aws/models/iam/policies.rb +0 -1
  113. data/lib/fog/aws/models/iam/policy.rb +0 -2
  114. data/lib/fog/aws/models/iam/role.rb +0 -2
  115. data/lib/fog/aws/models/iam/roles.rb +0 -1
  116. data/lib/fog/aws/models/iam/user.rb +0 -2
  117. data/lib/fog/aws/models/iam/users.rb +0 -1
  118. data/lib/fog/aws/models/rds/event_subscription.rb +0 -2
  119. data/lib/fog/aws/models/rds/event_subscriptions.rb +0 -1
  120. data/lib/fog/aws/models/rds/instance_option.rb +0 -2
  121. data/lib/fog/aws/models/rds/instance_options.rb +0 -1
  122. data/lib/fog/aws/models/rds/log_file.rb +0 -2
  123. data/lib/fog/aws/models/rds/log_files.rb +0 -1
  124. data/lib/fog/aws/models/rds/parameter.rb +0 -2
  125. data/lib/fog/aws/models/rds/parameter_group.rb +0 -2
  126. data/lib/fog/aws/models/rds/parameter_groups.rb +0 -1
  127. data/lib/fog/aws/models/rds/parameters.rb +0 -1
  128. data/lib/fog/aws/models/rds/security_group.rb +0 -3
  129. data/lib/fog/aws/models/rds/security_groups.rb +0 -1
  130. data/lib/fog/aws/models/rds/server.rb +0 -2
  131. data/lib/fog/aws/models/rds/servers.rb +0 -1
  132. data/lib/fog/aws/models/rds/snapshot.rb +0 -2
  133. data/lib/fog/aws/models/rds/snapshots.rb +0 -1
  134. data/lib/fog/aws/models/rds/subnet_group.rb +0 -2
  135. data/lib/fog/aws/models/rds/subnet_groups.rb +0 -1
  136. data/lib/fog/aws/models/sns/subscriptions.rb +0 -1
  137. data/lib/fog/aws/models/sns/topic.rb +0 -2
  138. data/lib/fog/aws/models/sns/topics.rb +0 -1
  139. data/lib/fog/aws/models/storage/directories.rb +0 -1
  140. data/lib/fog/aws/models/storage/directory.rb +0 -1
  141. data/lib/fog/aws/models/storage/file.rb +8 -5
  142. data/lib/fog/aws/models/storage/files.rb +0 -1
  143. data/lib/fog/aws/models/storage/version.rb +0 -2
  144. data/lib/fog/aws/models/storage/versions.rb +0 -1
  145. data/lib/fog/aws/parsers/compute/associate_route_table.rb +0 -0
  146. data/lib/fog/aws/parsers/compute/create_route_table.rb +0 -0
  147. data/lib/fog/aws/parsers/compute/describe_route_tables.rb +0 -0
  148. data/lib/fog/aws/parsers/compute/describe_spot_price_history.rb +1 -1
  149. data/lib/fog/aws/rds.rb +16 -2
  150. data/lib/fog/aws/redshift.rb +0 -2
  151. data/lib/fog/aws/requests/compute/associate_route_table.rb +0 -0
  152. data/lib/fog/aws/requests/compute/create_route.rb +0 -0
  153. data/lib/fog/aws/requests/compute/create_route_table.rb +0 -0
  154. data/lib/fog/aws/requests/compute/delete_route.rb +0 -0
  155. data/lib/fog/aws/requests/compute/delete_route_table.rb +0 -0
  156. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +3 -0
  157. data/lib/fog/aws/requests/compute/describe_route_tables.rb +0 -0
  158. data/lib/fog/aws/requests/compute/describe_spot_price_history.rb +27 -1
  159. data/lib/fog/aws/requests/compute/disassociate_route_table.rb +0 -0
  160. data/lib/fog/aws/requests/compute/replace_route.rb +0 -0
  161. data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +3 -2
  162. data/lib/fog/aws/requests/rds/create_db_snapshot.rb +1 -0
  163. data/lib/fog/aws/requests/rds/delete_db_instance.rb +20 -14
  164. data/lib/fog/aws/requests/rds/describe_db_engine_versions.rb +8 -1
  165. data/lib/fog/aws/requests/rds/describe_db_instances.rb +2 -3
  166. data/lib/fog/aws/requests/storage/post_object_hidden_fields.rb +9 -3
  167. data/lib/fog/aws/ses.rb +0 -2
  168. data/lib/fog/aws/signaturev4.rb +2 -3
  169. data/lib/fog/aws/simpledb.rb +0 -2
  170. data/lib/fog/aws/sns.rb +0 -2
  171. data/lib/fog/aws/sqs.rb +0 -2
  172. data/lib/fog/aws/storage.rb +27 -17
  173. data/lib/fog/aws/sts.rb +0 -2
  174. data/lib/fog/aws/version.rb +1 -1
  175. data/tests/models/rds/server_tests.rb +4 -3
  176. data/tests/requests/compute/spot_price_history_tests.rb +2 -1
  177. data/tests/requests/dns/change_resource_record_sets_tests.rb +10 -0
  178. data/tests/requests/rds/db_engine_versions.rb +7 -0
  179. data/tests/requests/rds/helper.rb +14 -0
  180. metadata +6 -5
  181. data/lib/fog/aws/core.rb +0 -344
  182. data/lib/fog/aws/parsers/.DS_Store +0 -0
  183. data/lib/fog/aws/requests/.DS_Store +0 -0
@@ -1,344 +0,0 @@
1
- require 'fog/core'
2
- require 'fog/xml'
3
- require 'fog/json'
4
- require 'fog/aws/credential_fetcher'
5
- require 'fog/aws/region_methods'
6
- require 'fog/aws/signaturev4'
7
-
8
- module Fog
9
- module AWS
10
- extend Fog::Provider
11
-
12
- service(:auto_scaling, 'AutoScaling')
13
- service(:beanstalk, 'ElasticBeanstalk')
14
- service(:cdn, 'CDN')
15
- service(:compute, 'Compute')
16
- service(:cloud_formation, 'CloudFormation')
17
- service(:cloud_watch, 'CloudWatch')
18
- service(:data_pipeline, 'DataPipeline')
19
- service(:dynamodb, 'DynamoDB')
20
- service(:dns, 'DNS')
21
- service(:elasticache, 'Elasticache')
22
- service(:elb, 'ELB')
23
- service(:emr, 'EMR')
24
- service(:federation, 'Federation')
25
- service(:glacier, 'Glacier')
26
- service(:iam, 'IAM')
27
- service(:rds, 'RDS')
28
- service(:redshift, 'Redshift')
29
- service(:ses, 'SES')
30
- service(:simpledb, 'SimpleDB')
31
- service(:sns, 'SNS')
32
- service(:sqs, 'SQS')
33
- service(:sts, 'STS')
34
- service(:storage, 'Storage')
35
-
36
- def self.indexed_param(key, values)
37
- params = {}
38
- unless key.include?('%d')
39
- key << '.%d'
40
- end
41
- [*values].each_with_index do |value, index|
42
- if value.respond_to?('keys')
43
- k = format(key, index + 1)
44
- value.each do | vkey, vvalue |
45
- params["#{k}.#{vkey}"] = vvalue
46
- end
47
- else
48
- params[format(key, index + 1)] = value
49
- end
50
- end
51
- params
52
- end
53
-
54
- def self.serialize_keys(key, value, options = {})
55
- case value
56
- when Hash
57
- value.each do | k, v |
58
- options.merge!(serialize_keys("#{key}.#{k}", v))
59
- end
60
- return options
61
- when Array
62
- value.each_with_index do | it, idx |
63
- options.merge!(serialize_keys("#{key}.member.#{(idx + 1)}", it))
64
- end
65
- return options
66
- else
67
- return {key => value}
68
- end
69
- end
70
-
71
- def self.indexed_request_param(name, values)
72
- idx = -1
73
- Array(values).reduce({}) do |params, value|
74
- params["#{name}.#{idx += 1}"] = value
75
- params
76
- end
77
- end
78
-
79
- def self.indexed_filters(filters)
80
- params = {}
81
- filters.keys.each_with_index do |key, key_index|
82
- key_index += 1
83
- params[format('Filter.%d.Name', key_index)] = key
84
- [*filters[key]].each_with_index do |value, value_index|
85
- value_index += 1
86
- params[format('Filter.%d.Value.%d', key_index, value_index)] = value
87
- end
88
- end
89
- params
90
- end
91
-
92
- def self.escape(string)
93
- string.gsub(/([^a-zA-Z0-9_.\-~]+)/) {
94
- "%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
95
- }
96
- end
97
-
98
- def self.signed_params_v4(params, headers, options={})
99
- date = Fog::Time.now
100
-
101
- params = params.merge('Version' => options[:version])
102
-
103
- headers = headers.merge('Host' => options[:host], 'x-amz-date' => date.to_iso8601_basic)
104
- headers['x-amz-security-token'] = options[:aws_session_token] if options[:aws_session_token]
105
-
106
- body = ''
107
- for key in params.keys.sort
108
- unless (value = params[key]).nil?
109
- body << "#{key}=#{escape(value.to_s)}&"
110
- end
111
- end
112
- body.chop!
113
-
114
- headers['Authorization'] = options[:signer].sign({:method => options[:method], :headers => headers, :body => body, :query => {}, :path => options[:path]}, date)
115
-
116
- return body, headers
117
- end
118
-
119
- def self.signed_params(params, options = {})
120
- params.merge!({
121
- 'AWSAccessKeyId' => options[:aws_access_key_id],
122
- 'SignatureMethod' => 'HmacSHA256',
123
- 'SignatureVersion' => '2',
124
- 'Timestamp' => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
125
- 'Version' => options[:version]
126
- })
127
-
128
- params.merge!({
129
- 'SecurityToken' => options[:aws_session_token]
130
- }) if options[:aws_session_token]
131
-
132
- body = ''
133
- for key in params.keys.sort
134
- unless (value = params[key]).nil?
135
- body << "#{key}=#{escape(value.to_s)}&"
136
- end
137
- end
138
- string_to_sign = "POST\n#{options[:host]}:#{options[:port]}\n#{options[:path]}\n" << body.chop
139
- signed_string = options[:hmac].sign(string_to_sign)
140
- body << "Signature=#{escape(Base64.encode64(signed_string).chomp!)}"
141
-
142
- body
143
- end
144
-
145
- class Mock
146
- def self.arn(vendor, account_id, path, region = nil)
147
- "arn:aws:#{vendor}:#{region}:#{account_id}:#{path}"
148
- end
149
-
150
- def self.availability_zone(region)
151
- "#{region}#{Fog::Mock.random_selection('abcd', 1)}"
152
- end
153
-
154
- def self.box_usage
155
- sprintf("%0.10f", rand / 100).to_f
156
- end
157
-
158
- def self.console_output
159
- # "[ 0.000000] Linux version 2.6.18-xenU-ec2-v1.2 (root@domU-12-31-39-07-51-82) (gcc version 4.1.2 20070626 (Red Hat 4.1.2-13)) #2 SMP Wed Aug 19 09:04:38 EDT 2009"
160
- Base64.decode64("WyAwLjAwMDAwMF0gTGludXggdmVyc2lvbiAyLjYuMTgteGVuVS1lYzItdjEu\nMiAocm9vdEBkb21VLTEyLTMxLTM5LTA3LTUxLTgyKSAoZ2NjIHZlcnNpb24g\nNC4xLjIgMjAwNzA2MjYgKFJlZCBIYXQgNC4xLjItMTMpKSAjMiBTTVAgV2Vk\nIEF1ZyAxOSAwOTowNDozOCBFRFQgMjAwOQ==\n")
161
- end
162
-
163
- def self.dns_name_for(ip_address)
164
- "ec2-#{ip_address.gsub('.','-')}.compute-1.amazonaws.com"
165
- end
166
-
167
- def self.private_dns_name_for(ip_address)
168
- "ip-#{ip_address.gsub('.','-')}.ec2.internal"
169
- end
170
-
171
- def self.image
172
- path = []
173
- (rand(3) + 2).times do
174
- path << Fog::Mock.random_letters(rand(9) + 8)
175
- end
176
- {
177
- "imageOwnerId" => Fog::Mock.random_letters(rand(5) + 4),
178
- "blockDeviceMapping" => [],
179
- "productCodes" => [],
180
- "kernelId" => kernel_id,
181
- "ramdiskId" => ramdisk_id,
182
- "imageState" => "available",
183
- "imageId" => image_id,
184
- "architecture" => "i386",
185
- "isPublic" => true,
186
- "imageLocation" => path.join('/'),
187
- "imageType" => "machine",
188
- "rootDeviceType" => ["ebs","instance-store"][rand(2)],
189
- "rootDeviceName" => "/dev/sda1"
190
- }
191
- end
192
-
193
- def self.image_id
194
- "ami-#{Fog::Mock.random_hex(8)}"
195
- end
196
-
197
- def self.key_fingerprint
198
- fingerprint = []
199
- 20.times do
200
- fingerprint << Fog::Mock.random_hex(2)
201
- end
202
- fingerprint.join(':')
203
- end
204
-
205
- def self.instance_id
206
- "i-#{Fog::Mock.random_hex(8)}"
207
- end
208
-
209
- def self.ip_address
210
- Fog::Mock.random_ip
211
- end
212
-
213
- def self.private_ip_address
214
- ip_address.gsub(/^\d{1,3}\./,"10.")
215
- end
216
-
217
- def self.kernel_id
218
- "aki-#{Fog::Mock.random_hex(8)}"
219
- end
220
-
221
- def self.key_material
222
- OpenSSL::PKey::RSA.generate(1024).to_s
223
- end
224
-
225
- def self.owner_id
226
- Fog::Mock.random_numbers(12)
227
- end
228
-
229
- def self.ramdisk_id
230
- "ari-#{Fog::Mock.random_hex(8)}"
231
- end
232
-
233
- def self.request_id
234
- request_id = []
235
- request_id << Fog::Mock.random_hex(8)
236
- 3.times do
237
- request_id << Fog::Mock.random_hex(4)
238
- end
239
- request_id << Fog::Mock.random_hex(12)
240
- request_id.join('-')
241
- end
242
- class << self
243
- alias_method :reserved_instances_id, :request_id
244
- alias_method :reserved_instances_offering_id, :request_id
245
- alias_method :sqs_message_id, :request_id
246
- alias_method :sqs_sender_id, :request_id
247
- end
248
-
249
- def self.reservation_id
250
- "r-#{Fog::Mock.random_hex(8)}"
251
- end
252
-
253
- def self.snapshot_id
254
- "snap-#{Fog::Mock.random_hex(8)}"
255
- end
256
-
257
- def self.volume_id
258
- "vol-#{Fog::Mock.random_hex(8)}"
259
- end
260
-
261
- def self.security_group_id
262
- "sg-#{Fog::Mock.random_hex(8)}"
263
- end
264
-
265
- def self.network_acl_id
266
- "acl-#{Fog::Mock.random_hex(8)}"
267
- end
268
- def self.network_acl_association_id
269
- "aclassoc-#{Fog::Mock.random_hex(8)}"
270
- end
271
- def self.network_interface_id
272
- "eni-#{Fog::Mock.random_hex(8)}"
273
- end
274
- def self.internet_gateway_id
275
- "igw-#{Fog::Mock.random_hex(8)}"
276
- end
277
- def self.dhcp_options_id
278
- "dopt-#{Fog::Mock.random_hex(8)}"
279
- end
280
- def self.vpc_id
281
- "vpc-#{Fog::Mock.random_hex(8)}"
282
- end
283
- def self.subnet_id
284
- "subnet-#{Fog::Mock.random_hex(8)}"
285
- end
286
- def self.zone_id
287
- "zone-#{Fog::Mock.random_hex(8)}"
288
- end
289
- def self.change_id
290
- Fog::Mock.random_letters_and_numbers(14)
291
- end
292
- def self.nameservers
293
- [
294
- 'ns-2048.awsdns-64.com',
295
- 'ns-2049.awsdns-65.net',
296
- 'ns-2050.awsdns-66.org',
297
- 'ns-2051.awsdns-67.co.uk'
298
- ]
299
- end
300
-
301
- def self.key_id(length=21)
302
- #Probably close enough
303
- Fog::Mock.random_selection('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',length)
304
- end
305
-
306
- def self.rds_address(db_name,region)
307
- "#{db_name}.#{Fog::Mock.random_letters(rand(12) + 4)}.#{region}.rds.amazonaws.com"
308
- end
309
- end
310
-
311
- def self.parse_security_group_options(group_name, options)
312
- options ||= Hash.new
313
- if group_name.is_a?(Hash)
314
- options = group_name
315
- elsif group_name
316
- if options.key?('GroupName')
317
- raise Fog::Compute::AWS::Error, 'Arguments specified both group_name and GroupName in options'
318
- end
319
- options = options.clone
320
- options['GroupName'] = group_name
321
- end
322
- name_specified = options.key?('GroupName') && !options['GroupName'].nil?
323
- group_id_specified = options.key?('GroupId') && !options['GroupId'].nil?
324
- unless name_specified || group_id_specified
325
- raise Fog::Compute::AWS::Error, 'Neither GroupName nor GroupId specified'
326
- end
327
- if name_specified && group_id_specified
328
- options.delete('GroupName')
329
- end
330
- options
331
- end
332
-
333
- module Errors
334
- def self.match_error(error)
335
- matcher = lambda {|s| s.match(/(?:.*<Code>(.*)<\/Code>)(?:.*<Message>(.*)<\/Message>)/m)}
336
- [error.message, error.response.body].each(&Proc.new {|s|
337
- match = matcher.call(s)
338
- return {:code => match[1].split('.').last, :message => match[2]} if match
339
- })
340
- {} # we did not match the message or response body
341
- end
342
- end
343
- end
344
- end