aws 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ec2/ec2.rb +1 -1
- data/lib/elb/elb_interface.rb +9 -4
- data/lib/rds/rds.rb +185 -181
- metadata +3 -3
data/lib/ec2/ec2.rb
CHANGED
@@ -405,7 +405,7 @@ module Aws
|
|
405
405
|
|
406
406
|
def describe_availability_zones(options={})
|
407
407
|
link = generate_request("DescribeAvailabilityZones", options={})
|
408
|
-
request_info_xml_simple(
|
408
|
+
request_info_xml_simple(self.class.connection_name, @params, link, @logger,
|
409
409
|
:group_tags =>{"DBInstances" =>"DBInstance",
|
410
410
|
"DBParameterGroups"=>"DBParameterGroup",
|
411
411
|
"DBSecurityGroups" =>"DBSecurityGroup",
|
data/lib/elb/elb_interface.rb
CHANGED
@@ -14,11 +14,16 @@ module Aws
|
|
14
14
|
DEFAULT_PROTOCOL = 'https'
|
15
15
|
DEFAULT_PORT = 443
|
16
16
|
|
17
|
+
def self.connection_name
|
18
|
+
:elb_connection
|
19
|
+
end
|
20
|
+
|
21
|
+
@@bench = AwsBenchmarkingBlock.new
|
17
22
|
|
18
|
-
|
19
|
-
def self.bench
|
23
|
+
def self.bench
|
20
24
|
@@bench
|
21
25
|
end
|
26
|
+
|
22
27
|
def self.bench_xml
|
23
28
|
@@bench.xml
|
24
29
|
end
|
@@ -51,13 +56,13 @@ module Aws
|
|
51
56
|
# Sends request to Amazon and parses the response
|
52
57
|
# Raises AwsError if any banana happened
|
53
58
|
def request_info(request, parser, options={})
|
54
|
-
request_info2(request, parser, @params,
|
59
|
+
request_info2(request, parser, @params, self.class.connection_name, @logger, @@bench, options)
|
55
60
|
end
|
56
61
|
|
57
62
|
# todo: convert to xml-simple version and get rid of parser below
|
58
63
|
def do_request(action, params, options={})
|
59
64
|
link = generate_request(action, params)
|
60
|
-
resp = request_info_xml_simple(
|
65
|
+
resp = request_info_xml_simple(self.class.connection_name, @params, link, @logger,
|
61
66
|
:group_tags =>{"LoadBalancersDescriptions"=>"LoadBalancersDescription",
|
62
67
|
"DBParameterGroups" =>"DBParameterGroup",
|
63
68
|
"DBSecurityGroups" =>"DBSecurityGroup",
|
data/lib/rds/rds.rb
CHANGED
@@ -1,218 +1,222 @@
|
|
1
1
|
module Aws
|
2
|
-
|
2
|
+
require 'xmlsimple'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# API Reference: http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/
|
5
|
+
class Rds < AwsBase
|
6
|
+
include AwsBaseInterface
|
7
7
|
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
# Amazon API version being used
|
10
|
+
API_VERSION = nil
|
11
|
+
DEFAULT_HOST = "rds.amazonaws.com"
|
12
|
+
DEFAULT_PATH = '/'
|
13
|
+
DEFAULT_PROTOCOL = 'https'
|
14
|
+
DEFAULT_PORT = 443
|
15
15
|
|
16
|
-
|
16
|
+
@@api = ENV['RDS_API_VERSION'] || API_VERSION
|
17
17
|
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def self.connection_name
|
20
|
+
:rds_connection
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.api
|
24
|
+
@@api
|
25
|
+
end
|
26
|
+
|
22
27
|
|
28
|
+
@@bench = AwsBenchmarkingBlock.new
|
23
29
|
|
24
|
-
|
25
|
-
def self.bench
|
30
|
+
def self.bench
|
26
31
|
@@bench
|
27
32
|
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
:api_version
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
34
|
+
def self.bench_xml
|
35
|
+
@@bench.xml
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def self.bench_ec2
|
40
|
+
@@bench.service
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
45
|
+
uri = ENV['RDS_URL'] ? URI.parse(ENV['RDS_URL']) : nil
|
46
|
+
init({:name => 'RDS',
|
47
|
+
:default_host => uri ? uri.host : DEFAULT_HOST,
|
48
|
+
:default_port => uri ? uri.port : DEFAULT_PORT,
|
49
|
+
:default_service => uri ? uri.path : DEFAULT_PATH,
|
50
|
+
:default_protocol => uri ? uri.scheme : DEFAULT_PROTOCOL,
|
51
|
+
:api_version => API_VERSION},
|
52
|
+
aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
|
53
|
+
aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
|
54
|
+
params)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def do_request(action, params, options={})
|
59
|
+
link = generate_request(action, params)
|
60
|
+
resp = request_info_xml_simple(self.class.connection_name, @params, link, @logger,
|
61
|
+
:group_tags =>{"DBInstances" =>"DBInstance",
|
62
|
+
"DBParameterGroups"=>"DBParameterGroup",
|
63
|
+
"DBSecurityGroups" =>"DBSecurityGroup",
|
64
|
+
"EC2SecurityGroups"=>"EC2SecurityGroup",
|
65
|
+
"IPRanges" =>"IPRange"},
|
66
|
+
:force_array =>["DBInstances",
|
67
|
+
"DBParameterGroups",
|
68
|
+
"DBSecurityGroups",
|
69
|
+
"EC2SecurityGroups",
|
70
|
+
"IPRanges"],
|
71
|
+
:pull_out_array =>options[:pull_out_array],
|
72
|
+
:pull_out_single=>options[:pull_out_single],
|
73
|
+
:wrapper =>options[:wrapper])
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
#-----------------------------------------------------------------
|
78
|
+
# REQUESTS
|
79
|
+
#-----------------------------------------------------------------
|
80
|
+
|
81
|
+
#
|
82
|
+
# identifier: db instance identifier. Must be unique per account per zone.
|
83
|
+
# instance_class: db.m1.small | db.m1.large | db.m1.xlarge | db.m2.2xlarge | db.m2.4xlarge
|
84
|
+
# See this for other values: http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/
|
85
|
+
#
|
86
|
+
# options:
|
87
|
+
# db_name: if you want a database created at the same time as the instance, specify :db_name option.
|
88
|
+
# availability_zone: default is random zone.
|
89
|
+
def create_db_instance(identifier, instance_class, allocated_storage, master_username, master_password, options={})
|
90
|
+
params = {}
|
91
|
+
params['DBInstanceIdentifier'] = identifier
|
92
|
+
params['DBInstanceClass'] = instance_class
|
93
|
+
params['AllocatedStorage'] = allocated_storage
|
94
|
+
params['MasterUsername'] = master_username
|
95
|
+
params['MasterUserPassword'] = master_password
|
96
|
+
|
97
|
+
params['Engine'] = options[:engine] || "MySQL5.1"
|
98
|
+
params['DBName'] = options[:db_name] if options[:db_name]
|
99
|
+
params['AvailabilityZone'] = options[:availability_zone] if options[:availability_zone]
|
100
|
+
params['PreferredMaintenanceWindow'] = options[:preferred_maintenance_window] if options[:preferred_maintenance_window]
|
101
|
+
params['BackupRetentionPeriod'] = options[:preferred_retention_period] if options[:preferred_retention_period]
|
102
|
+
params['PreferredBackupWindow'] = options[:preferred_backup_window] if options[:preferred_backup_window]
|
103
|
+
|
104
|
+
@logger.info("Creating DB Instance called #{identifier}")
|
105
|
+
|
106
|
+
link = do_request("CreateDBInstance", params, :pull_out_single=>[:create_db_instance_result, :db_instance])
|
107
|
+
|
108
|
+
rescue Exception
|
109
|
+
on_exception
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
# options:
|
114
|
+
# DBInstanceIdentifier
|
115
|
+
# MaxRecords
|
116
|
+
# Marker
|
117
|
+
#
|
118
|
+
# Returns array of instances as hashes.
|
119
|
+
# Response metadata can be retreived by calling array.response_metadata on the returned array.
|
120
|
+
def describe_db_instances(options={})
|
121
|
+
params = {}
|
122
|
+
params['DBInstanceIdentifier'] = options[:db_instance_identifier] if options[:db_instance_identifier]
|
123
|
+
params['MaxRecords'] = options[:max_records] if options[:max_records]
|
124
|
+
params['Marker'] = options[:marker] if options[:marker]
|
125
|
+
|
126
|
+
resp = do_request("DescribeDBInstances", params, :pull_out_array=>[:describe_db_instances_result, :db_instances])
|
127
|
+
|
128
|
+
rescue Exception
|
129
|
+
on_exception
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
# identifier: identifier of db instance to delete.
|
134
|
+
# final_snapshot_identifier: if specified, RDS will crate a final snapshot before deleting so you can restore it later.
|
135
|
+
def delete_db_instance(identifier, final_snapshot_identifier=nil)
|
136
|
+
@logger.info("Deleting DB Instance - " + identifier.to_s)
|
120
137
|
|
121
|
-
|
138
|
+
params = {}
|
139
|
+
params['DBInstanceIdentifier'] = identifier
|
140
|
+
if final_snapshot_identifier
|
141
|
+
params['FinalDBSnapshotIdentifier'] = final_snapshot_identifier
|
142
|
+
else
|
143
|
+
params['SkipFinalSnapshot'] = true
|
144
|
+
end
|
122
145
|
|
123
|
-
|
124
|
-
on_exception
|
125
|
-
end
|
146
|
+
link = do_request("DeleteDBInstance", params, :pull_out_single=>[:delete_db_instance_result, :db_instance])
|
126
147
|
|
148
|
+
rescue Exception
|
149
|
+
on_exception
|
150
|
+
end
|
127
151
|
|
128
|
-
# identifier: identifier of db instance to delete.
|
129
|
-
# final_snapshot_identifier: if specified, RDS will crate a final snapshot before deleting so you can restore it later.
|
130
|
-
def delete_db_instance(identifier, final_snapshot_identifier=nil)
|
131
|
-
@logger.info("Deleting DB Instance - " + identifier.to_s)
|
132
|
-
|
133
|
-
params = {}
|
134
|
-
params['DBInstanceIdentifier'] = identifier
|
135
|
-
if final_snapshot_identifier
|
136
|
-
params['FinalDBSnapshotIdentifier'] = final_snapshot_identifier
|
137
|
-
else
|
138
|
-
params['SkipFinalSnapshot'] = true
|
139
|
-
end
|
140
|
-
|
141
|
-
link = do_request("DeleteDBInstance", params, :pull_out_single=>[:delete_db_instance_result, :db_instance])
|
142
|
-
|
143
|
-
rescue Exception
|
144
|
-
on_exception
|
145
|
-
end
|
146
|
-
|
147
|
-
|
148
|
-
def create_db_security_group(group_name, description, options={})
|
149
|
-
params = {}
|
150
|
-
params['DBSecurityGroupName'] = group_name
|
151
|
-
params['DBSecurityGroupDescription'] = description
|
152
|
-
|
153
|
-
link = do_request("CreateDBSecurityGroup", params, :pull_out_single => [:create_db_security_group_result, :db_security_group])
|
154
|
-
|
155
|
-
rescue Exception
|
156
|
-
on_exception
|
157
|
-
end
|
158
152
|
|
153
|
+
def create_db_security_group(group_name, description, options={})
|
154
|
+
params = {}
|
155
|
+
params['DBSecurityGroupName'] = group_name
|
156
|
+
params['DBSecurityGroupDescription'] = description
|
159
157
|
|
160
|
-
|
161
|
-
params = {}
|
162
|
-
params['DBSecurityGroupName'] = group_name
|
158
|
+
link = do_request("CreateDBSecurityGroup", params, :pull_out_single => [:create_db_security_group_result, :db_security_group])
|
163
159
|
|
164
|
-
|
160
|
+
rescue Exception
|
161
|
+
on_exception
|
162
|
+
end
|
165
163
|
|
166
|
-
rescue Exception
|
167
|
-
on_exception
|
168
|
-
end
|
169
164
|
|
165
|
+
def delete_db_security_group(group_name, options={})
|
166
|
+
params = {}
|
167
|
+
params['DBSecurityGroupName'] = group_name
|
170
168
|
|
171
|
-
|
172
|
-
params = {}
|
173
|
-
params['DBSecurityGroupName'] = options[:DBSecurityGroupName] if options[:DBSecurityGroupName]
|
174
|
-
params['MaxRecords'] = options[:MaxRecords] if options[:MaxRecords]
|
169
|
+
link = do_request("DeleteDBSecurityGroup", params)
|
175
170
|
|
176
|
-
|
171
|
+
rescue Exception
|
172
|
+
on_exception
|
173
|
+
end
|
177
174
|
|
178
175
|
|
179
|
-
|
180
|
-
|
181
|
-
|
176
|
+
def describe_db_security_groups(options={})
|
177
|
+
params = {}
|
178
|
+
params['DBSecurityGroupName'] = options[:DBSecurityGroupName] if options[:DBSecurityGroupName]
|
179
|
+
params['MaxRecords'] = options[:MaxRecords] if options[:MaxRecords]
|
182
180
|
|
181
|
+
link = do_request("DescribeDBSecurityGroups", params, :pull_out_array=>[:describe_db_security_groups_result, :db_security_groups], :wrapper=>:db_security_group)
|
183
182
|
|
184
|
-
def authorize_db_security_group_ingress_ec2group(group_name, ec2_group_name, ec2_group_owner_id, options={})
|
185
|
-
params = {}
|
186
|
-
params['DBSecurityGroupName'] = group_name
|
187
|
-
params['EC2SecurityGroupOwnerId'] = ec2_group_owner_id
|
188
|
-
params['EC2SecurityGroupName'] = ec2_group_name
|
189
|
-
link = do_request("AuthorizeDBSecurityGroupIngress", params)
|
190
|
-
rescue Exception
|
191
|
-
on_exception
|
192
|
-
end
|
193
183
|
|
184
|
+
rescue Exception
|
185
|
+
on_exception
|
186
|
+
end
|
194
187
|
|
195
|
-
def authorize_db_security_group_ingress_range(group_name, ip_range, options={})
|
196
|
-
params = {}
|
197
|
-
params['DBSecurityGroupName'] = group_name
|
198
|
-
params['CIDRIP'] = ip_range
|
199
|
-
link = do_request("AuthorizeDBSecurityGroupIngress", params)
|
200
|
-
rescue Exception
|
201
|
-
on_exception
|
202
|
-
end
|
203
188
|
|
189
|
+
def authorize_db_security_group_ingress_ec2group(group_name, ec2_group_name, ec2_group_owner_id, options={})
|
190
|
+
params = {}
|
191
|
+
params['DBSecurityGroupName'] = group_name
|
192
|
+
params['EC2SecurityGroupOwnerId'] = ec2_group_owner_id
|
193
|
+
params['EC2SecurityGroupName'] = ec2_group_name
|
194
|
+
link = do_request("AuthorizeDBSecurityGroupIngress", params)
|
195
|
+
rescue Exception
|
196
|
+
on_exception
|
197
|
+
end
|
204
198
|
|
205
|
-
def revoke_db_security_group_ingress(group_name, ip_range, options={})
|
206
|
-
params = {}
|
207
|
-
params['DBSecurityGroupName'] = group_name
|
208
|
-
params['CIDRIP'] = ip_range
|
209
|
-
link = do_request("RevokeDBSecurityGroupIngress", params)
|
210
|
-
rescue Exception
|
211
|
-
on_exception
|
212
|
-
end
|
213
199
|
|
200
|
+
def authorize_db_security_group_ingress_range(group_name, ip_range, options={})
|
201
|
+
params = {}
|
202
|
+
params['DBSecurityGroupName'] = group_name
|
203
|
+
params['CIDRIP'] = ip_range
|
204
|
+
link = do_request("AuthorizeDBSecurityGroupIngress", params)
|
205
|
+
rescue Exception
|
206
|
+
on_exception
|
207
|
+
end
|
214
208
|
|
215
209
|
|
210
|
+
def revoke_db_security_group_ingress(group_name, ip_range, options={})
|
211
|
+
params = {}
|
212
|
+
params['DBSecurityGroupName'] = group_name
|
213
|
+
params['CIDRIP'] = ip_range
|
214
|
+
link = do_request("RevokeDBSecurityGroupIngress", params)
|
215
|
+
rescue Exception
|
216
|
+
on_exception
|
216
217
|
end
|
217
218
|
|
219
|
+
|
220
|
+
end
|
221
|
+
|
218
222
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 2.4.
|
8
|
+
- 2
|
9
|
+
version: 2.4.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Reeder
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-01-
|
19
|
+
date: 2011-01-21 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|