aws 2.2.4 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -321,12 +321,13 @@ module Aws
321
321
  end
322
322
 
323
323
  # This is the direction we should head instead of writing our own parsers for everything, much simpler
324
- def request_info_xml_simple(connection_name, lib_params, request, logger)
324
+ def request_info_xml_simple(connection_name, lib_params, request, logger, params = {})
325
325
 
326
326
  @connection = get_conn(connection_name, lib_params, logger)
327
327
  @last_request = request[:request]
328
328
  @last_response = nil
329
- response=nil
329
+
330
+ response = nil
330
331
  blockexception = nil
331
332
 
332
333
  response = @connection.request(request)
@@ -337,7 +338,8 @@ module Aws
337
338
  @error_handler = nil
338
339
  # benchblock.xml.add! { parser.parse(response) }
339
340
  # return parser.result
340
- return XmlSimple.xml_in(response.body, {"KeyToSymbol"=>false, 'ForceArray' => false})
341
+ force_array = params[:force_array] || false
342
+ return XmlSimple.xml_in(response.body, {"KeyToSymbol"=>false, 'ForceArray' => force_array})
341
343
  else
342
344
  @error_handler = AWSErrorHandler.new(self, nil, :errors_list => self.class.amazon_problems) unless @error_handler
343
345
  check_result = @error_handler.check(request)
data/lib/rds/rds.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  module Aws
2
-
3
-
4
2
  require 'xmlsimple'
5
3
 
6
4
  # API Reference: http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/
@@ -142,12 +140,25 @@ module Aws
142
140
  end
143
141
 
144
142
 
143
+ def delete_db_security_group(group_name, options={})
144
+ params = {}
145
+ params['DBSecurityGroupName'] = group_name
146
+ link = generate_request("DeleteDBSecurityGroup", params)
147
+ resp = request_info_xml_simple(:rds_connection, @params, link, @logger)
148
+ rescue Exception
149
+ on_exception
150
+ end
151
+
152
+
145
153
  def describe_db_security_groups(options={})
146
154
  params = {}
147
155
  params['DBSecurityGroupName'] = options[:DBSecurityGroupName] if options[:DBSecurityGroupName]
148
156
  params['MaxRecords'] = options[:MaxRecords] if options[:MaxRecords]
157
+
158
+ force_array = options[:force_array].nil? ? false : options[:force_array]
159
+
149
160
  link = generate_request("DescribeDBSecurityGroups", params)
150
- resp = request_info_xml_simple(:rds_connection, @params, link, @logger)
161
+ resp = request_info_xml_simple(:rds_connection, @params, link, @logger, :force_array => force_array)
151
162
  rescue Exception
152
163
  on_exception
153
164
  end
@@ -186,6 +197,7 @@ module Aws
186
197
  on_exception
187
198
  end
188
199
 
200
+
189
201
  end
190
202
 
191
203
  end
data/test/rds/test_rds.rb CHANGED
@@ -4,7 +4,7 @@ require 'rds/rds'
4
4
  require 'pp'
5
5
  require File.dirname(__FILE__) + '/../test_credentials.rb'
6
6
 
7
- class TestElb < Test::Unit::TestCase
7
+ class TestRds < Test::Unit::TestCase
8
8
 
9
9
  # Some of RightEc2 instance methods concerning instance launching and image registration
10
10
  # are not tested here due to their potentially risk.
@@ -15,56 +15,144 @@ class TestElb < Test::Unit::TestCase
15
15
  @rds = Aws::Rds.new(TestCredentials.aws_access_key_id,
16
16
  TestCredentials.aws_secret_access_key)
17
17
 
18
- @identifier = 'my-db-instance'
19
- @identifier2 = 'my-db-instance2'
20
-
18
+ @identifier = 'test-db-instance1'
19
+ # deleting this one....
20
+ #@identifier2 = 'my-db-instance2'
21
21
  end
22
22
 
23
- def test_01_create_db_instance
24
-
25
23
 
24
+ def test_01_create_db_instance
26
25
  begin
27
- db_instance2 = @rds.create_db_instance('right_ec2_awesome_test_key', "db.m1.small", 5, "master", "masterpass")
26
+ db_instance3 = @rds.create_db_instance('right_ec2_awesome_test_key', "db.m1.small", 5, "master", "masterpass")
28
27
  rescue => ex
29
- puts "msg=" + ex.message
30
- puts "response=" + ex.response
31
- assert ex.message[0,"InvalidParameterValue".size] == "InvalidParameterValue"
28
+ #puts "msg=" + ex.message
29
+ #puts "response=" + ex.response
30
+ assert ex.message[0, "InvalidParameterValue".size] == "InvalidParameterValue"
32
31
  end
33
32
 
34
- db_instance = @rds.create_db_instance(@identifier, "db.m1.small", 5, "master", "masterpass")
35
- puts 'db_instance=' + db_instance.inspect
33
+ #db_instance = @rds.create_db_instance(@identifier, "db.m1.small", 5, "master", "masterpass")
34
+
35
+ tries=0
36
+ while tries < 100
37
+ instances_result = @rds.describe_db_instances
38
+ instances = instances_result["DescribeDBInstancesResult"]["DBInstances"]["DBInstance"]
36
39
 
37
- db_instance2 = @rds.create_db_instance(@identifier2, "db.m1.small", 5, "master", "masterpass")
38
- puts 'db_instance2=' + db_instance2.inspect
40
+ #puts "INSTANCES -----> " + instances.inspect
39
41
 
40
- sleep 10
41
-
42
+ instances.each do |i|
43
+ next unless i["DBInstanceIdentifier"] == @identifier
44
+ break if i["DBInstanceStatus"] == "available"
45
+ puts "Database not ready yet.... attempt #{tries.to_s} of 100, db state --> #{i["DBInstanceStatus"].to_s}"
46
+ tries += 1
47
+ sleep 5
48
+ end
42
49
 
50
+
51
+ end
43
52
  end
44
53
 
54
+
45
55
  def test_02_describe_db_instances
46
56
  instances_result = @rds.describe_db_instances
47
- puts "instances_result=" + instances_result.inspect
57
+ #puts "instances_result=" + instances_result.inspect
48
58
  instances = instances_result["DescribeDBInstancesResult"]["DBInstances"]["DBInstance"]
49
- puts 'instances=' + instances.inspect
50
- assert instances.size == 2
59
+ #puts "\n\ninstances count = " + instances.count.to_s + " \n\n "
60
+
61
+ assert instances.size > 0
51
62
  end
52
63
 
53
- def test_06_delete_db_instance
54
64
 
55
- @rds.delete_db_instance(@identifier)
56
- @rds.delete_db_instance(@identifier2)
65
+ def test_03_describe_security_groups
66
+ security_result = @rds.describe_db_security_groups()
67
+ #puts "security_result=" + security_result.inspect
68
+ security_groups=security_result["DescribeDBSecurityGroupsResult"]["DBSecurityGroups"]["DBSecurityGroup"]
69
+ default_present = false
70
+ if security_groups.is_a?(Array)
71
+ security_groups.each do |security_group|
72
+ security_group.inspect
73
+ if security_group["DBSecurityGroupName"]=="default"
74
+ default_present=true
75
+ end
76
+ end
77
+ else
78
+ if security_groups["DBSecurityGroupName"]=="default"
79
+ default_present=true
80
+ end
81
+ end
82
+ assert default_present
83
+ end
57
84
 
58
- sleep 2
85
+
86
+ def test_04_authorize_security_groups_ingress
87
+ # Create
88
+ @security_info = @rds.describe_db_security_groups({:force_array => ["DBSecurityGroup", "IPRange"]})["DescribeDBSecurityGroupsResult"]["DBSecurityGroups"]["DBSecurityGroup"]
89
+ @rds.authorize_db_security_group_ingress_range("default", "122.122.122.122/12")
90
+
91
+ # Check
92
+ @security_info = @rds.describe_db_security_groups({:force_array => ["DBSecurityGroup", "IPRange"]})["DescribeDBSecurityGroupsResult"]["DBSecurityGroups"]["DBSecurityGroup"]
93
+
94
+ ip_found = @security_info.inspect.include? "122.122.122.122/12"
95
+ assert ip_found
96
+ end
97
+
98
+
99
+ def test_05_delete_db_instance
100
+ @rds.delete_db_instance(@identifier)
101
+ #@rds.delete_db_instance(@identifier2)
102
+ sleep 3
59
103
 
60
104
  instances_result = @rds.describe_db_instances
61
- puts "instances_result=" + instances_result.inspect
105
+ #puts "instances_result=" + instances_result.inspect
106
+
62
107
  instances_result["DescribeDBInstancesResult"]["DBInstances"]["DBInstance"].each do |i|
108
+ puts "Trying to delete and getting i[DBInstanceStatus] -----------> " + i["DBInstanceStatus"]
63
109
  assert i["DBInstanceStatus"] == "deleting"
64
110
  end
65
- # assert instances_result["DescribeDBInstancesResult"]["DBInstances"]["DBInstance"].size == 0
66
111
 
112
+ assert instances_result["DescribeDBInstancesResult"]["DBInstances"]["DBInstance"].size < 2
113
+ end
114
+
115
+
116
+ def test_06_create_security_groups
117
+ group_present=false
118
+
119
+ @rds.create_db_security_groups("new_sample_group", "new_sample_group_description")
120
+
121
+ @security_info = @rds.describe_db_security_groups({:force_array => ["DBSecurityGroup", "IPRange"]})["DescribeDBSecurityGroupsResult"]["DBSecurityGroups"]["DBSecurityGroup"]
122
+
123
+ @security_info.each do |security_group|
124
+ if (security_group["DBSecurityGroupName"]=="new_sample_group")&&(security_group["DBSecurityGroupDescription"]=="new_sample_group_description")
125
+ group_present = true
126
+ end
127
+ end
128
+
129
+ assert group_present
130
+ end
131
+
132
+
133
+ def test_07_revoking_security_groups_ingress
134
+ sleep 15
135
+ @rds.revoke_db_security_group_ingress("default", "122.122.122.122/12")
136
+ sleep 2
137
+ @security_info = @rds.describe_db_security_groups({:force_array => ["DBSecurityGroup", "IPRange"]})["DescribeDBSecurityGroupsResult"]["DBSecurityGroups"]["DBSecurityGroup"]
138
+ revoking = @security_info[0].inspect.include? "revoking"
139
+ assert revoking
140
+ end
141
+
142
+
143
+
144
+ def test_08_delete_security_group
145
+ group_present=false
146
+ @rds.delete_db_security_group("new_sample_group")
147
+ sleep 2
148
+ @security_info = @rds.describe_db_security_groups({:force_array => ["DBSecurityGroup", "IPRange"]})["DescribeDBSecurityGroupsResult"]["DBSecurityGroups"]["DBSecurityGroup"]
149
+ @security_info.each do |security_group|
150
+ if (security_group["DBSecurityGroupName"]=="new_sample_group")
151
+ group_present=true
152
+ end
153
+ end
154
+ assert !group_present
67
155
  end
68
156
 
69
157
 
70
- end
158
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-02-09 00:00:00 -08:00
14
+ date: 2010-02-13 00:00:00 -08:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency