fog-aws 0.7.4 → 0.7.5
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.
- checksums.yaml +4 -4
- data/lib/fog/aws.rb +30 -21
- data/lib/fog/aws/auto_scaling.rb +2 -4
- data/lib/fog/aws/cloud_watch.rb +1 -3
- data/lib/fog/aws/compute.rb +2 -4
- data/lib/fog/aws/ecs.rb +1 -3
- data/lib/fog/aws/elb.rb +9 -8
- data/lib/fog/aws/kinesis.rb +1 -3
- data/lib/fog/aws/kms.rb +1 -3
- data/lib/fog/aws/lambda.rb +1 -3
- data/lib/fog/aws/models/compute/volume.rb +14 -4
- data/lib/fog/aws/models/rds/server.rb +6 -1
- data/lib/fog/aws/parsers/compute/create_volume.rb +1 -1
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +1 -1
- data/lib/fog/aws/rds.rb +2 -3
- data/lib/fog/aws/requests/compute/create_volume.rb +15 -10
- data/lib/fog/aws/requests/rds/create_db_instance.rb +34 -3
- data/lib/fog/aws/requests/rds/create_db_instance_read_replica.rb +1 -0
- data/lib/fog/aws/requests/rds/describe_db_instances.rb +1 -1
- data/lib/fog/aws/requests/rds/describe_db_snapshots.rb +3 -2
- data/lib/fog/aws/requests/rds/modify_db_instance.rb +32 -4
- data/lib/fog/aws/requests/rds/promote_read_replica.rb +27 -18
- data/lib/fog/aws/requests/storage/put_bucket_notification.rb +1 -1
- data/lib/fog/aws/sns.rb +1 -3
- data/lib/fog/aws/sqs.rb +1 -3
- data/lib/fog/aws/storage.rb +1 -1
- data/lib/fog/aws/version.rb +1 -1
- data/tests/models/rds/server_tests.rb +13 -2
- data/tests/requests/compute/volume_tests.rb +44 -27
- metadata +2 -3
- data/lib/fog/aws/region_methods.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4397f9c8c33ed518c2029eaed97241723b4bde0b
|
4
|
+
data.tar.gz: 717bb82a0012393747acc56f4ab39213ea76d2ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22396fa794717e82b93969954722ae4614facf95107cbd0e03eeaa94c562a6d4dbced6beabbaed4f7fbdc844107223e2957b5255c30b254a89ea724c631b4ed
|
7
|
+
data.tar.gz: 4237cdf3e82649d353fadb7b9f1f6a89fa74e71d40b675ccb1e6462fddc807010031447a2522310b09eb98d8e3c39528f6bf8e205c18596a953e24acc9525d7b
|
data/lib/fog/aws.rb
CHANGED
@@ -27,7 +27,6 @@ module Fog
|
|
27
27
|
autoload :CredentialFetcher, File.expand_path('../aws/credential_fetcher', __FILE__)
|
28
28
|
autoload :Errors, File.expand_path('../aws/errors', __FILE__)
|
29
29
|
autoload :Mock, File.expand_path('../aws/mock', __FILE__)
|
30
|
-
autoload :RegionMethods, File.expand_path('../aws/region_methods', __FILE__)
|
31
30
|
autoload :SignatureV4, File.expand_path('../aws/signaturev4', __FILE__)
|
32
31
|
|
33
32
|
# Services
|
@@ -103,18 +102,18 @@ module Fog
|
|
103
102
|
|
104
103
|
def self.serialize_keys(key, value, options = {})
|
105
104
|
case value
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
105
|
+
when Hash
|
106
|
+
value.each do | k, v |
|
107
|
+
options.merge!(serialize_keys("#{key}.#{k}", v))
|
108
|
+
end
|
109
|
+
return options
|
110
|
+
when Array
|
111
|
+
value.each_with_index do | it, idx |
|
112
|
+
options.merge!(serialize_keys("#{key}.member.#{(idx + 1)}", it))
|
113
|
+
end
|
114
|
+
return options
|
115
|
+
else
|
116
|
+
return {key => value}
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
@@ -173,16 +172,16 @@ module Fog
|
|
173
172
|
|
174
173
|
def self.signed_params(params, options = {})
|
175
174
|
params.merge!({
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
175
|
+
'AWSAccessKeyId' => options[:aws_access_key_id],
|
176
|
+
'SignatureMethod' => 'HmacSHA256',
|
177
|
+
'SignatureVersion' => '2',
|
178
|
+
'Timestamp' => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
179
|
+
'Version' => options[:version]
|
180
|
+
})
|
182
181
|
|
183
182
|
params.merge!({
|
184
|
-
|
185
|
-
|
183
|
+
'SecurityToken' => options[:aws_session_token]
|
184
|
+
}) if options[:aws_session_token]
|
186
185
|
|
187
186
|
body = ''
|
188
187
|
for key in params.keys.sort
|
@@ -223,5 +222,15 @@ module Fog
|
|
223
222
|
return false unless response && response.headers
|
224
223
|
response.get_header('Content-Type') =~ %r{application/.*json.*}i ? true : false
|
225
224
|
end
|
225
|
+
|
226
|
+
def self.regions
|
227
|
+
@regions ||= ['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-central-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1', 'cn-north-1']
|
228
|
+
end
|
229
|
+
|
230
|
+
def self.validate_region!(region, host=nil)
|
231
|
+
if (!host || host.end_with?('.amazonaws.com')) && !regions.include?(region)
|
232
|
+
raise ArgumentError, "Unknown region: #{region.inspect}"
|
233
|
+
end
|
234
|
+
end
|
226
235
|
end
|
227
236
|
end
|
data/lib/fog/aws/auto_scaling.rb
CHANGED
@@ -147,7 +147,7 @@ module Fog
|
|
147
147
|
:body => body,
|
148
148
|
:expects => 200,
|
149
149
|
:idempotent => idempotent,
|
150
|
-
:headers => headers,
|
150
|
+
:headers => headers,
|
151
151
|
:method => 'POST',
|
152
152
|
:parser => parser
|
153
153
|
})
|
@@ -253,9 +253,7 @@ module Fog
|
|
253
253
|
setup_credentials(options)
|
254
254
|
@region = options[:region] || 'us-east-1'
|
255
255
|
|
256
|
-
|
257
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
258
|
-
end
|
256
|
+
Fog::AWS.validate_region!(@region)
|
259
257
|
end
|
260
258
|
|
261
259
|
def region_data
|
data/lib/fog/aws/cloud_watch.rb
CHANGED
@@ -52,9 +52,7 @@ module Fog
|
|
52
52
|
|
53
53
|
@region = options[:region] || 'us-east-1'
|
54
54
|
|
55
|
-
|
56
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
57
|
-
end
|
55
|
+
Fog::AWS.validate_region!(@region)
|
58
56
|
end
|
59
57
|
|
60
58
|
def data
|
data/lib/fog/aws/compute.rb
CHANGED
@@ -185,7 +185,6 @@ module Fog
|
|
185
185
|
}
|
186
186
|
|
187
187
|
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
188
|
-
include Fog::AWS::RegionMethods
|
189
188
|
|
190
189
|
def self.data
|
191
190
|
@data ||= Hash.new do |hash, region|
|
@@ -315,7 +314,7 @@ module Fog
|
|
315
314
|
@port = options[:port] || 443
|
316
315
|
@scheme = options[:scheme] || 'https'
|
317
316
|
end
|
318
|
-
|
317
|
+
Fog::AWS.validate_region!(@region, @host)
|
319
318
|
end
|
320
319
|
|
321
320
|
def region_data
|
@@ -429,7 +428,6 @@ module Fog
|
|
429
428
|
|
430
429
|
class Real
|
431
430
|
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
432
|
-
include Fog::AWS::RegionMethods
|
433
431
|
# Initialize connection to EC2
|
434
432
|
#
|
435
433
|
# ==== Notes
|
@@ -478,7 +476,7 @@ module Fog
|
|
478
476
|
@scheme = options[:scheme] || 'https'
|
479
477
|
end
|
480
478
|
|
481
|
-
|
479
|
+
Fog::AWS.validate_region!(@region, @host)
|
482
480
|
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
|
483
481
|
end
|
484
482
|
|
data/lib/fog/aws/ecs.rb
CHANGED
@@ -163,9 +163,7 @@ module Fog
|
|
163
163
|
@use_iam_profile = options[:use_iam_profile]
|
164
164
|
@region = options[:region] || 'us-east-1'
|
165
165
|
|
166
|
-
|
167
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
168
|
-
end
|
166
|
+
Fog::AWS.validate_region!(@region)
|
169
167
|
|
170
168
|
setup_credentials(options)
|
171
169
|
end
|
data/lib/fog/aws/elb.rb
CHANGED
@@ -80,15 +80,15 @@ module Fog
|
|
80
80
|
@data = nil
|
81
81
|
end
|
82
82
|
|
83
|
+
attr_reader :region
|
84
|
+
|
83
85
|
def initialize(options={})
|
84
86
|
@use_iam_profile = options[:use_iam_profile]
|
85
87
|
|
86
88
|
@region = options[:region] || 'us-east-1'
|
87
89
|
setup_credentials(options)
|
88
90
|
|
89
|
-
|
90
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
91
|
-
end
|
91
|
+
Fog::AWS.validate_region!(@region)
|
92
92
|
end
|
93
93
|
|
94
94
|
def setup_credentials(options)
|
@@ -144,9 +144,10 @@ module Fog
|
|
144
144
|
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
|
145
145
|
|
146
146
|
setup_credentials(options)
|
147
|
-
|
148
147
|
end
|
149
148
|
|
149
|
+
attr_reader :region
|
150
|
+
|
150
151
|
def reload
|
151
152
|
@connection.reset
|
152
153
|
end
|
@@ -154,12 +155,12 @@ module Fog
|
|
154
155
|
private
|
155
156
|
|
156
157
|
def setup_credentials(options={})
|
157
|
-
@aws_access_key_id
|
158
|
-
@aws_secret_access_key
|
159
|
-
@aws_session_token
|
158
|
+
@aws_access_key_id = options[:aws_access_key_id]
|
159
|
+
@aws_secret_access_key = options[:aws_secret_access_key]
|
160
|
+
@aws_session_token = options[:aws_session_token]
|
160
161
|
@aws_credentials_expire_at = options[:aws_credentials_expire_at]
|
161
162
|
|
162
|
-
@signer = Fog::AWS::SignatureV4.new(
|
163
|
+
@signer = Fog::AWS::SignatureV4.new(@aws_access_key_id, @aws_secret_access_key, @region, 'elasticloadbalancing')
|
163
164
|
end
|
164
165
|
|
165
166
|
def request(params)
|
data/lib/fog/aws/kinesis.rb
CHANGED
@@ -149,9 +149,7 @@ module Fog
|
|
149
149
|
@aws_access_key_id = options[:aws_access_key_id]
|
150
150
|
@region = options[:region] || 'us-east-1'
|
151
151
|
|
152
|
-
|
153
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
154
|
-
end
|
152
|
+
Fog::AWS.validate_region!(@region)
|
155
153
|
end
|
156
154
|
|
157
155
|
def data
|
data/lib/fog/aws/kms.rb
CHANGED
@@ -49,9 +49,7 @@ module Fog
|
|
49
49
|
@region = options[:region] || 'us-east-1'
|
50
50
|
setup_credentials(options)
|
51
51
|
|
52
|
-
|
53
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
54
|
-
end
|
52
|
+
Fog::AWS.validate_region!(@region)
|
55
53
|
end
|
56
54
|
|
57
55
|
def setup_credentials(options)
|
data/lib/fog/aws/lambda.rb
CHANGED
@@ -49,9 +49,7 @@ module Fog
|
|
49
49
|
@account_id = Fog::AWS::Mock.owner_id
|
50
50
|
@module = "lambda"
|
51
51
|
|
52
|
-
|
53
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
54
|
-
end
|
52
|
+
Fog::AWS.validate_region!(@region)
|
55
53
|
end
|
56
54
|
|
57
55
|
def data
|
@@ -9,10 +9,11 @@ module Fog
|
|
9
9
|
attribute :created_at, :aliases => 'createTime'
|
10
10
|
attribute :delete_on_termination, :aliases => 'deleteOnTermination'
|
11
11
|
attribute :device
|
12
|
+
attribute :encrypted
|
13
|
+
attribute :key_id, :aliases => ['KmsKeyId', 'kmsKeyId']
|
12
14
|
attribute :iops
|
13
15
|
attribute :server_id, :aliases => 'instanceId'
|
14
16
|
attribute :size
|
15
|
-
attribute :encrypted
|
16
17
|
attribute :snapshot_id, :aliases => 'snapshotId'
|
17
18
|
attribute :state, :aliases => 'status'
|
18
19
|
attribute :tags, :aliases => 'tagSet'
|
@@ -44,9 +45,8 @@ module Fog
|
|
44
45
|
requires :iops
|
45
46
|
end
|
46
47
|
|
47
|
-
data = service.create_volume(availability_zone, size,
|
48
|
-
|
49
|
-
merge_attributes(new_attributes)
|
48
|
+
data = service.create_volume(availability_zone, size, create_params).body
|
49
|
+
merge_attributes(data)
|
50
50
|
|
51
51
|
if tags = self.tags
|
52
52
|
# expect eventual consistency
|
@@ -118,6 +118,16 @@ module Fog
|
|
118
118
|
reload
|
119
119
|
end
|
120
120
|
end
|
121
|
+
|
122
|
+
def create_params
|
123
|
+
{
|
124
|
+
'Encrypted' => encrypted,
|
125
|
+
'KmsKeyId' => key_id,
|
126
|
+
'Iops' => iops,
|
127
|
+
'SnapshotId' => snapshot_id,
|
128
|
+
'VolumeType' => type
|
129
|
+
}
|
130
|
+
end
|
121
131
|
end
|
122
132
|
end
|
123
133
|
end
|
@@ -87,9 +87,14 @@ module Fog
|
|
87
87
|
|
88
88
|
def promote_read_replica
|
89
89
|
requires :id
|
90
|
-
|
90
|
+
|
91
|
+
data = service.promote_read_replica(id).body["PromoteReadReplicaResult"]["DBInstance"]
|
92
|
+
|
93
|
+
merge_attributes(data)
|
91
94
|
end
|
92
95
|
|
96
|
+
alias promote promote_read_replica
|
97
|
+
|
93
98
|
def modify(immediately, options)
|
94
99
|
options[:security_group_names] ||= options['DBSecurityGroups']
|
95
100
|
params = self.class.new(options).attributes_to_params
|
@@ -5,7 +5,7 @@ module Fog
|
|
5
5
|
class CreateVolume < Fog::Parsers::Base
|
6
6
|
def end_element(name)
|
7
7
|
case name
|
8
|
-
when 'availabilityZone', 'requestId', 'snapshotId', 'status', 'volumeId', 'volumeType'
|
8
|
+
when 'availabilityZone', 'requestId', 'snapshotId', 'status', 'volumeId', 'volumeType', 'kmsKeyId'
|
9
9
|
@response[name] = value
|
10
10
|
when 'createTime'
|
11
11
|
@response[name] = Time.parse(value)
|
@@ -30,7 +30,7 @@ module Fog
|
|
30
30
|
@attachment[name] = Time.parse(value)
|
31
31
|
when 'deleteOnTermination'
|
32
32
|
@attachment[name] = value == 'true'
|
33
|
-
when 'device', 'instanceId', 'status', 'volumeId'
|
33
|
+
when 'device', 'instanceId', 'status', 'volumeId', 'kmsKeyId'
|
34
34
|
@attachment[name] = value
|
35
35
|
when 'item'
|
36
36
|
@volume['attachmentSet'] << @attachment
|
data/lib/fog/aws/rds.rb
CHANGED
@@ -4,6 +4,7 @@ module Fog
|
|
4
4
|
extend Fog::AWS::CredentialFetcher::ServiceMethods
|
5
5
|
|
6
6
|
class IdentifierTaken < Fog::Errors::Error; end
|
7
|
+
class InvalidParameterCombination < Fog::Errors::Error; end
|
7
8
|
|
8
9
|
class AuthorizationAlreadyExists < Fog::Errors::Error; end
|
9
10
|
|
@@ -142,9 +143,7 @@ module Fog
|
|
142
143
|
@use_iam_profile = options[:use_iam_profile]
|
143
144
|
@region = options[:region] || 'us-east-1'
|
144
145
|
|
145
|
-
|
146
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
147
|
-
end
|
146
|
+
Fog::AWS.validate_region!(@region)
|
148
147
|
|
149
148
|
setup_credentials(options)
|
150
149
|
end
|
@@ -87,19 +87,24 @@ module Fog
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
if options['KmsKeyId'] && !options['Encrypted']
|
91
|
+
raise Fog::Compute::AWS::Error.new("InvalidParameterDependency => The parameter KmsKeyId requires the parameter Encrypted to be set.")
|
92
|
+
end
|
93
|
+
|
90
94
|
response.status = 200
|
91
95
|
volume_id = Fog::AWS::Mock.volume_id
|
92
96
|
data = {
|
93
|
-
'availabilityZone'
|
94
|
-
'attachmentSet'
|
95
|
-
'createTime'
|
96
|
-
'iops'
|
97
|
-
'encrypted'
|
98
|
-
'size'
|
99
|
-
'snapshotId'
|
100
|
-
'
|
101
|
-
'
|
102
|
-
'
|
97
|
+
'availabilityZone' => availability_zone,
|
98
|
+
'attachmentSet' => [],
|
99
|
+
'createTime' => Time.now,
|
100
|
+
'iops' => options['Iops'],
|
101
|
+
'encrypted' => options['Encrypted'] || false,
|
102
|
+
'size' => size,
|
103
|
+
'snapshotId' => options['SnapshotId'],
|
104
|
+
'kmsKeyId' => options['KmsKeyId'] || nil, # @todo validate
|
105
|
+
'status' => 'creating',
|
106
|
+
'volumeId' => volume_id,
|
107
|
+
'volumeType' => options['VolumeType'] || 'standard'
|
103
108
|
}
|
104
109
|
self.data[:volumes][volume_id] = data
|
105
110
|
response.body = {
|
@@ -78,6 +78,37 @@ module Fog
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
if !!options["MultiAZ"] && !!options["AvailabilityZone"]
|
82
|
+
raise Fog::AWS::RDS::InvalidParameterCombination.new('Requesting a specific availability zone is not valid for Multi-AZ instances.')
|
83
|
+
end
|
84
|
+
|
85
|
+
ec2 = Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id]
|
86
|
+
|
87
|
+
db_security_group_names = Array(options.delete("DBSecurityGroups"))
|
88
|
+
rds_security_groups = self.data[:security_groups].values
|
89
|
+
ec2_security_groups = ec2[:security_groups].values
|
90
|
+
vpc = !ec2[:account_attributes].find { |h| "supported-platforms" == h["attributeName"] }["values"].include?("EC2")
|
91
|
+
|
92
|
+
db_security_groups = db_security_group_names.map do |group_name|
|
93
|
+
unless rds_security_groups.find { |sg| sg["DBSecurityGroupName"] == group_name }
|
94
|
+
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId= , groupName=#{group_name}")
|
95
|
+
end
|
96
|
+
|
97
|
+
{"Status" => "active", "DBSecurityGroupName" => group_name }
|
98
|
+
end
|
99
|
+
|
100
|
+
if !vpc && db_security_groups.empty?
|
101
|
+
db_security_groups << { "Status" => "active", "DBSecurityGroupName" => "default" }
|
102
|
+
end
|
103
|
+
|
104
|
+
vpc_security_groups = Array(options.delete("VpcSecurityGroups")).map do |group_id|
|
105
|
+
unless ec2_security_groups.find { |sg| sg["groupId"] == group_id }
|
106
|
+
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId=#{group_id} , groupName=")
|
107
|
+
end
|
108
|
+
|
109
|
+
{"Status" => "active", "VpcSecurityGroupId" => group_id }
|
110
|
+
end
|
111
|
+
|
81
112
|
data = {
|
82
113
|
"AllocatedStorage" => options["AllocatedStorage"],
|
83
114
|
"AutoMinorVersionUpgrade" => options["AutoMinorVersionUpgrade"].nil? ? true : options["AutoMinorVersionUpgrade"],
|
@@ -89,7 +120,7 @@ module Fog
|
|
89
120
|
"DBInstanceStatus" =>"creating",
|
90
121
|
"DBName" => options["DBName"],
|
91
122
|
"DBParameterGroups" => [{ "DBParameterGroupName" => "default.mysql5.5", "ParameterApplyStatus" => "in-sync" }],
|
92
|
-
"DBSecurityGroups" =>
|
123
|
+
"DBSecurityGroups" => db_security_groups,
|
93
124
|
"DBSubnetGroupName" => options["DBSubnetGroupName"],
|
94
125
|
"Endpoint" =>{},
|
95
126
|
"Engine" => options["Engine"],
|
@@ -98,7 +129,7 @@ module Fog
|
|
98
129
|
"Iops" => options["Iops"],
|
99
130
|
"LicenseModel" => "general-public-license",
|
100
131
|
"MasterUsername" => options["MasterUsername"],
|
101
|
-
"MultiAZ" => !!options[
|
132
|
+
"MultiAZ" => !!options["MultiAZ"],
|
102
133
|
"PendingModifiedValues" => { "MasterUserPassword" => "****" }, # This clears when is available
|
103
134
|
"PreferredBackupWindow" => options["PreferredBackupWindow"] || "08:00-08:30",
|
104
135
|
"PreferredMaintenanceWindow" => options["PreferredMaintenanceWindow"] || "mon:04:30-mon:05:00",
|
@@ -106,7 +137,7 @@ module Fog
|
|
106
137
|
"ReadReplicaDBInstanceIdentifiers" => [],
|
107
138
|
"StorageEncrypted" => options["StorageEncrypted"] || false,
|
108
139
|
"StorageType" => options["StorageType"] || "standard",
|
109
|
-
"VpcSecurityGroups" =>
|
140
|
+
"VpcSecurityGroups" => vpc_security_groups,
|
110
141
|
}
|
111
142
|
|
112
143
|
self.data[:servers][db_name] = data
|
@@ -61,6 +61,7 @@ module Fog
|
|
61
61
|
'ReadReplicaSourceDBInstanceIdentifier' => source_identifier,
|
62
62
|
'StorageType' => options['StorageType'] || 'standard',
|
63
63
|
'StorageEncrypted' => false,
|
64
|
+
'VpcSecurityGroups' => source['VpcSecurityGroups'],
|
64
65
|
}
|
65
66
|
self.data[:servers][instance_identifier] = data
|
66
67
|
self.data[:servers][source_identifier]['ReadReplicaDBInstanceIdentifiers'] << instance_identifier
|
@@ -77,7 +77,7 @@ module Fog
|
|
77
77
|
|
78
78
|
response.status = 200
|
79
79
|
response.body = {
|
80
|
-
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
|
80
|
+
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
|
81
81
|
"DescribeDBInstancesResult" => { "DBInstances" => server_set }
|
82
82
|
}
|
83
83
|
response
|
@@ -35,11 +35,12 @@ module Fog
|
|
35
35
|
response = Excon::Response.new
|
36
36
|
snapshots = self.data[:snapshots].values
|
37
37
|
if opts[:identifier]
|
38
|
-
snapshots = snapshots.select{|snapshot| snapshot['DBInstanceIdentifier'] == opts[:identifier]}
|
38
|
+
snapshots = snapshots.select { |snapshot| snapshot['DBInstanceIdentifier'] == opts[:identifier] }
|
39
|
+
|
39
40
|
end
|
40
41
|
|
41
42
|
if opts[:snapshot_id]
|
42
|
-
snapshots = snapshots.select{|snapshot| snapshot['DBSnapshotIdentifier'] == opts[:snapshot_id]}
|
43
|
+
snapshots = snapshots.select { |snapshot| snapshot['DBSnapshotIdentifier'] == opts[:snapshot_id] }
|
43
44
|
raise Fog::AWS::RDS::NotFound.new("DBSnapshot #{opts[:snapshot_id]} not found") if snapshots.empty?
|
44
45
|
end
|
45
46
|
|
@@ -46,10 +46,11 @@ module Fog
|
|
46
46
|
end
|
47
47
|
|
48
48
|
class Mock
|
49
|
-
def modify_db_instance(db_name, apply_immediately,
|
49
|
+
def modify_db_instance(db_name, apply_immediately, _options={})
|
50
|
+
options = _options
|
50
51
|
response = Excon::Response.new
|
51
|
-
if self.data[:servers][db_name]
|
52
|
-
if
|
52
|
+
if server = self.data[:servers][db_name]
|
53
|
+
if server["DBInstanceStatus"] != "available"
|
53
54
|
raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for modification")
|
54
55
|
else
|
55
56
|
self.data[:modify_time] = Time.now
|
@@ -61,11 +62,38 @@ module Fog
|
|
61
62
|
#else
|
62
63
|
# modified_server = server["PendingModifiedValues"].merge!(options) # it appends
|
63
64
|
#end
|
65
|
+
|
66
|
+
db_security_group_names = Array(options.delete("DBSecurityGroups"))
|
67
|
+
|
68
|
+
rds_security_groups = self.data[:security_groups].values
|
69
|
+
|
70
|
+
db_security_groups = db_security_group_names.map do |r, group_name|
|
71
|
+
unless rds_security_groups.find { |sg| sg["DBSecurityGroupName"] == group_name }
|
72
|
+
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId= , groupName=#{group_name}")
|
73
|
+
end
|
74
|
+
r << {"Status" => "active", "DBSecurityGroupName" => group_name }
|
75
|
+
end
|
76
|
+
|
77
|
+
ec2_security_groups = Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:security_groups].values
|
78
|
+
|
79
|
+
vpc_security_groups = Array(options.delete("VpcSecurityGroups")).map do |group_id|
|
80
|
+
unless ec2_security_groups.find { |sg| sg["groupId"] == group_id }
|
81
|
+
raise Fog::AWS::RDS::Error.new("InvalidParameterValue => Invalid security group , groupId=#{group_id} , groupName=")
|
82
|
+
end
|
83
|
+
|
84
|
+
{"Status" => "active", "VpcSecurityGroupId" => group_id }
|
85
|
+
end
|
86
|
+
|
87
|
+
options.merge!(
|
88
|
+
"DBSecurityGroups" => db_security_groups,
|
89
|
+
"VpcSecurityGroups" => vpc_security_groups
|
90
|
+
)
|
91
|
+
|
64
92
|
self.data[:servers][db_name]["PendingModifiedValues"].merge!(options) # it appends
|
65
93
|
self.data[:servers][db_name]["DBInstanceStatus"] = "modifying"
|
66
94
|
response.status = 200
|
67
95
|
response.body = {
|
68
|
-
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
|
96
|
+
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
|
69
97
|
"ModifyDBInstanceResult" => { "DBInstance" => self.data[:servers][db_name] }
|
70
98
|
}
|
71
99
|
response
|
@@ -25,34 +25,43 @@ module Fog
|
|
25
25
|
params['BackupRetentionPeriod'] = backup_retention_period if backup_retention_period
|
26
26
|
params['PreferredBackupWindow'] = preferred_backup_window if preferred_backup_window
|
27
27
|
request({
|
28
|
-
'Action'
|
28
|
+
'Action' => 'PromoteReadReplica',
|
29
29
|
'DBInstanceIdentifier' => identifier,
|
30
|
-
:parser
|
30
|
+
:parser => Fog::Parsers::AWS::RDS::PromoteReadReplica.new
|
31
31
|
}.merge(params))
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
class Mock
|
36
36
|
def promote_read_replica(identifier, backup_retention_period = nil, preferred_backup_window = nil)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
server = self.data[:servers][identifier]
|
38
|
+
server || raise(Fog::AWS::RDS::NotFound.new("DBInstance #{identifier} not found"))
|
39
|
+
|
40
|
+
if server["ReadReplicaSourceDBInstanceIdentifier"].nil?
|
41
|
+
raise(Fog::AWS::RDS::Error.new("InvalidDBInstanceState => DB Instance is not a read replica."))
|
42
|
+
end
|
43
43
|
|
44
|
-
|
44
|
+
self.data[:modify_time] = Time.now
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
data = {
|
47
|
+
'BackupRetentionPeriod' => backup_retention_period || 1,
|
48
|
+
'PreferredBackupWindow' => preferred_backup_window || '08:00-08:30',
|
49
|
+
'DBInstanceIdentifier' => identifier,
|
50
|
+
'DBInstanceStatus' => "modifying",
|
51
|
+
'PendingModifiedValues' => {
|
52
|
+
'ReadReplicaSourceDBInstanceIdentifier' => nil,
|
50
53
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
}
|
55
|
+
|
56
|
+
server.merge!(data)
|
57
|
+
|
58
|
+
response = Excon::Response.new
|
59
|
+
response.body = {
|
60
|
+
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
|
61
|
+
"PromoteReadReplicaResult" => { "DBInstance" => server }
|
62
|
+
}
|
63
|
+
response.status = 200
|
64
|
+
response
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
data/lib/fog/aws/sns.rb
CHANGED
@@ -47,9 +47,7 @@ module Fog
|
|
47
47
|
@account_id = Fog::AWS::Mock.owner_id
|
48
48
|
@module = "sns"
|
49
49
|
|
50
|
-
|
51
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
52
|
-
end
|
50
|
+
Fog::AWS.validate_region!(@region)
|
53
51
|
end
|
54
52
|
|
55
53
|
def data
|
data/lib/fog/aws/sqs.rb
CHANGED
@@ -38,9 +38,7 @@ module Fog
|
|
38
38
|
setup_credentials(options)
|
39
39
|
@region = options[:region] || 'us-east-1'
|
40
40
|
|
41
|
-
|
42
|
-
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
43
|
-
end
|
41
|
+
Fog::AWS.validate_region!(@region)
|
44
42
|
end
|
45
43
|
|
46
44
|
def data
|
data/lib/fog/aws/storage.rb
CHANGED
@@ -606,7 +606,7 @@ module Fog
|
|
606
606
|
Fog::Logger.warning("fog: followed redirect to #{host}, connecting to the matching region will be more performant")
|
607
607
|
original_region, original_signer = @region, @signer
|
608
608
|
@region = @new_region || case new_params[:host]
|
609
|
-
when
|
609
|
+
when /s3.amazonaws.com/, /s3-external-1.amazonaws.com/
|
610
610
|
DEFAULT_REGION
|
611
611
|
else
|
612
612
|
%r{s3[\.\-]([^\.]*).amazonaws.com}.match(new_params[:host]).captures.first
|
data/lib/fog/aws/version.rb
CHANGED
@@ -87,8 +87,9 @@ Shindo.tests("AWS::RDS | server", ['aws', 'rds']) do
|
|
87
87
|
@instance.wait_for { state == 'rebooting' }
|
88
88
|
@instance.wait_for { ready? }
|
89
89
|
|
90
|
-
|
90
|
+
replica = nil
|
91
91
|
|
92
|
+
tests('#create_read_replica').succeeds do
|
92
93
|
replica = @instance_with_final_snapshot.create_read_replica(uniq_id('fog-replica'))
|
93
94
|
@instance_with_final_snapshot.reload
|
94
95
|
returns([replica.id]) { @instance_with_final_snapshot.read_replica_identifiers }
|
@@ -98,10 +99,20 @@ Shindo.tests("AWS::RDS | server", ['aws', 'rds']) do
|
|
98
99
|
|
99
100
|
# FinalDBSnapshotIdentifier can not be specified when deleting a replica instance
|
100
101
|
raises(Fog::AWS::RDS::Error) { replica.destroy("foobar") }
|
102
|
+
end
|
101
103
|
|
102
|
-
|
104
|
+
tests('#promote_read_replica').succeeds do
|
105
|
+
replica.promote.wait_for { state != "modifying" }
|
106
|
+
|
107
|
+
replica.read_replica_source == nil
|
103
108
|
end
|
104
109
|
|
110
|
+
tests('#promote_read_replica', 'master').raises(Fog::AWS::RDS::Error) {
|
111
|
+
@instance_with_final_snapshot.promote
|
112
|
+
}
|
113
|
+
|
114
|
+
replica && replica.destroy
|
115
|
+
|
105
116
|
test("Destroying with a final snapshot") do
|
106
117
|
final_snapshot_id = uniq_id('fog-test-snapshot')
|
107
118
|
|
@@ -1,25 +1,25 @@
|
|
1
1
|
Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
2
2
|
|
3
3
|
@volume_format = {
|
4
|
-
'availabilityZone'
|
5
|
-
'createTime'
|
6
|
-
'encrypted'
|
7
|
-
'iops'
|
8
|
-
'requestId'
|
9
|
-
'size'
|
10
|
-
'snapshotId'
|
11
|
-
'status'
|
12
|
-
'volumeId'
|
13
|
-
'volumeType'
|
4
|
+
'availabilityZone' => String,
|
5
|
+
'createTime' => Time,
|
6
|
+
'encrypted' => Fog::Boolean,
|
7
|
+
'iops' => Fog::Nullable::Integer,
|
8
|
+
'requestId' => String,
|
9
|
+
'size' => Integer,
|
10
|
+
'snapshotId' => Fog::Nullable::String,
|
11
|
+
'status' => String,
|
12
|
+
'volumeId' => String,
|
13
|
+
'volumeType' => String
|
14
14
|
}
|
15
15
|
|
16
16
|
@volume_attachment_format = {
|
17
|
-
'attachTime'
|
18
|
-
'device'
|
19
|
-
'instanceId'
|
20
|
-
'requestId'
|
21
|
-
'status'
|
22
|
-
'volumeId'
|
17
|
+
'attachTime' => Time,
|
18
|
+
'device' => String,
|
19
|
+
'instanceId' => String,
|
20
|
+
'requestId' => String,
|
21
|
+
'status' => String,
|
22
|
+
'volumeId' => String
|
23
23
|
}
|
24
24
|
|
25
25
|
@volume_status_format = {
|
@@ -52,17 +52,18 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|
52
52
|
|
53
53
|
@volumes_format = {
|
54
54
|
'volumeSet' => [{
|
55
|
-
'availabilityZone'
|
56
|
-
'attachmentSet'
|
57
|
-
'createTime'
|
58
|
-
'encrypted'
|
59
|
-
'iops'
|
60
|
-
'size'
|
61
|
-
'snapshotId'
|
62
|
-
'
|
63
|
-
'
|
64
|
-
'
|
65
|
-
'
|
55
|
+
'availabilityZone' => String,
|
56
|
+
'attachmentSet' => Array,
|
57
|
+
'createTime' => Time,
|
58
|
+
'encrypted' => Fog::Boolean,
|
59
|
+
'iops' => Fog::Nullable::Integer,
|
60
|
+
'size' => Integer,
|
61
|
+
'snapshotId' => Fog::Nullable::String,
|
62
|
+
'kmsKeyId' => Fog::Nullable::String,
|
63
|
+
'status' => String,
|
64
|
+
'tagSet' => Hash,
|
65
|
+
'volumeId' => String,
|
66
|
+
'volumeType' => String
|
66
67
|
}],
|
67
68
|
'requestId' => String
|
68
69
|
}
|
@@ -83,7 +84,11 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|
83
84
|
|
84
85
|
tests('#create_volume from snapshot').formats(@volume_format) do
|
85
86
|
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
87
|
+
volume.wait_for { ready? }
|
88
|
+
|
86
89
|
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
90
|
+
Fog::Compute[:aws].snapshots.new(snapshot).wait_for { ready? }
|
91
|
+
|
87
92
|
data = Fog::Compute[:aws].create_volume(@server.availability_zone, nil, 'SnapshotId' => snapshot['snapshotId']).body
|
88
93
|
@volume_id = data['volumeId']
|
89
94
|
data
|
@@ -99,9 +104,21 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
|
|
99
104
|
|
100
105
|
Fog::Compute[:aws].delete_volume(@volume_id)
|
101
106
|
|
107
|
+
tests('#create_volume with encryption').returns(true) do
|
108
|
+
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1, :encrypted => true)
|
109
|
+
@volume_id = volume.id
|
110
|
+
volume.reload.encrypted
|
111
|
+
end
|
112
|
+
|
113
|
+
Fog::Compute[:aws].delete_volume(@volume_id)
|
114
|
+
|
102
115
|
tests('#create_volume from snapshot with size').formats(@volume_format) do
|
103
116
|
volume = Fog::Compute[:aws].volumes.create(:availability_zone => 'us-east-1d', :size => 1)
|
117
|
+
volume.wait_for { ready? }
|
118
|
+
|
104
119
|
snapshot = Fog::Compute[:aws].create_snapshot(volume.identity).body
|
120
|
+
Fog::Compute[:aws].snapshots.new(snapshot).wait_for { ready? }
|
121
|
+
|
105
122
|
data = Fog::Compute[:aws].create_volume(@server.availability_zone, 1, 'SnapshotId' => snapshot['snapshotId']).body
|
106
123
|
@volume_id = data['volumeId']
|
107
124
|
data
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -693,7 +693,6 @@ files:
|
|
693
693
|
- lib/fog/aws/parsers/sts/get_session_token.rb
|
694
694
|
- lib/fog/aws/rds.rb
|
695
695
|
- lib/fog/aws/redshift.rb
|
696
|
-
- lib/fog/aws/region_methods.rb
|
697
696
|
- lib/fog/aws/requests/auto_scaling/attach_load_balancers.rb
|
698
697
|
- lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb
|
699
698
|
- lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module AWS
|
3
|
-
module RegionMethods
|
4
|
-
def validate_aws_region(host, region)
|
5
|
-
if host.end_with?('.amazonaws.com') && !['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1', 'us-gov-west-1', 'eu-central-1'].include?(region)
|
6
|
-
raise ArgumentError, "Unknown region: #{region.inspect}"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|