aws 2.3.13 → 2.3.20

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ec2/right_ec2.rb CHANGED
@@ -390,6 +390,26 @@ module Aws
390
390
  on_exception
391
391
  end
392
392
 
393
+ def describe_availability_zones(options={})
394
+ link = generate_request("DescribeAvailabilityZones", options={})
395
+ request_info_xml_simple(:rds_connection, @params, link, @logger,
396
+ :group_tags=>{"DBInstances"=>"DBInstance",
397
+ "DBParameterGroups"=>"DBParameterGroup",
398
+ "DBSecurityGroups"=>"DBSecurityGroup",
399
+ "EC2SecurityGroups"=>"EC2SecurityGroup",
400
+ "IPRanges"=>"IPRange"},
401
+ :force_array=>["DBInstances",
402
+ "DBParameterGroups",
403
+ "DBSecurityGroups",
404
+ "EC2SecurityGroups",
405
+ "IPRanges"],
406
+ :pull_out_array=>options[:pull_out_array],
407
+ :pull_out_single=>options[:pull_out_single],
408
+ :wrapper=>options[:wrapper])
409
+ rescue Exception
410
+ on_exception
411
+ end
412
+
393
413
  # Retrieve information about EC2 instances. If +list+ is omitted then returns the
394
414
  # list of all instances.
395
415
  #
@@ -1467,6 +1487,7 @@ module Aws
1467
1487
  when 'ramdiskId' then @instance[:aws_ramdisk_id] = @text
1468
1488
  when 'platform' then @instance[:aws_platform] = @text
1469
1489
  when 'availabilityZone' then @instance[:aws_availability_zone] = @text
1490
+ when 'privateIpAddress' then @instance[:aws_private_ip_address] = @text
1470
1491
  when 'state'
1471
1492
  if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/monitoring' || # DescribeInstances property
1472
1493
  @xmlpath == 'RunInstancesResponse/instancesSet/item/monitoring' # RunInstances property
@@ -1,4 +1,8 @@
1
- #
1
+ # THIS IS DEPRECATED NOW, PLEASE USE SimpleRecord instead:
2
+ # http://github.com/appoxy/simple_record
3
+
4
+
5
+
2
6
  # Copyright (c) 2008 RightScale Inc
3
7
  #
4
8
  # Permission is hereby granted, free of charge, to any person obtaining
@@ -128,7 +128,7 @@ module Aws
128
128
  #
129
129
  service_params = signed_service_params(@aws_secret_access_key, service_hash, :post, @params[:server], service)
130
130
  request = Net::HTTP::Post.new(AwsUtils::URLencode(service))
131
- request['Content-Type'] = 'application/x-www-form-urlencoded'
131
+ request['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'
132
132
  request.body = service_params
133
133
  # prepare output hash
134
134
  { :request => request,
data/test/ec2/test_ec2.rb CHANGED
@@ -6,105 +6,119 @@ class TestEc2 < Test::Unit::TestCase
6
6
 
7
7
  # Some of RightEc2 instance methods concerning instance launching and image registration
8
8
  # are not tested here due to their potentially risk.
9
-
10
- def setup
11
- TestCredentials.get_credentials
12
- @ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id,
13
- TestCredentials.aws_secret_access_key)
14
- @key = 'right_ec2_awesome_test_key'
15
- @group = 'right_ec2_awesome_test_security_group'
16
- end
17
-
18
- def test_01_create_describe_key_pairs
19
- new_key = @ec2.create_key_pair(@key)
20
- assert new_key[:aws_material][/BEGIN RSA PRIVATE KEY/], "New key material is absent"
21
- keys = @ec2.describe_key_pairs
22
- assert keys.map{|key| key[:aws_key_name] }.include?(@key), "#{@key} must exist"
23
- end
24
-
25
- def test_02_create_security_group
26
- assert @ec2.create_security_group(@group,'My awesone test group'), 'Create_security_group fail'
27
- group = @ec2.describe_security_groups([@group])[0]
28
- assert_equal @group, group[:aws_group_name], 'Group must be created but does not exist'
29
- end
30
-
31
- def test_03_perms_add
32
- assert @ec2.authorize_security_group_named_ingress(@group, TestCredentials.account_number, 'default')
33
- assert @ec2.authorize_security_group_IP_ingress(@group, 80,80,'udp','192.168.1.0/8')
34
- end
35
-
36
- def test_04_check_new_perms_exist
37
- assert_equal 2, @ec2.describe_security_groups([@group])[0][:aws_perms].size
38
- end
39
-
40
- def test_05_perms_remove
41
- assert @ec2.revoke_security_group_IP_ingress(@group, 80,80,'udp','192.168.1.0/8')
42
- assert @ec2.revoke_security_group_named_ingress(@group,
43
- TestCredentials.account_number, 'default')
44
- end
45
-
46
- def test_06_describe_images
47
- images = @ec2.describe_images
48
- assert images.size>0, 'Amazon must have at least some public images'
49
- # unknown image
50
- assert_raise(Aws::AwsError){ @ec2.describe_images(['ami-ABCDEFGH'])}
51
- end
52
-
53
- def test_07_describe_instanses
54
- assert @ec2.describe_instances
55
- # unknown image
56
- assert_raise(Aws::AwsError){ @ec2.describe_instances(['i-ABCDEFGH'])}
57
- end
58
-
59
- def test_08_delete_security_group
60
- assert @ec2.delete_security_group(@group), 'Delete_security_group fail'
61
- end
62
-
63
- def test_09_delete_key_pair
64
- assert @ec2.delete_key_pair(@key), 'Delete_key_pair fail'
9
+
10
+ def setup
11
+ TestCredentials.get_credentials
12
+ @ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id,
13
+ TestCredentials.aws_secret_access_key)
14
+ @key = 'right_ec2_awesome_test_key'
15
+ @group = 'right_ec2_awesome_test_security_group'
16
+ end
17
+
18
+ def test_001_describe_availability_zones
19
+ TestCredentials.get_credentials
20
+ @ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id,
21
+ TestCredentials.aws_secret_access_key)
22
+ zones = @ec2.describe_availability_zones
23
+ puts zones.inspect
24
+ assert zones.is_a? Array
25
+ assert zones.size > 3
26
+ zones.each do |z|
27
+ puts z[:zone_name]
28
+ end
29
+ assert zones[0][:zone_name] == "us-east-1a"
30
+ end
31
+
32
+ def test_01_create_describe_key_pairs
33
+ new_key = @ec2.create_key_pair(@key)
34
+ assert new_key[:aws_material][/BEGIN RSA PRIVATE KEY/], "New key material is absent"
35
+ keys = @ec2.describe_key_pairs
36
+ assert keys.map { |key| key[:aws_key_name] }.include?(@key), "#{@key} must exist"
37
+ end
38
+
39
+ def test_02_create_security_group
40
+ assert @ec2.create_security_group(@group, 'My awesone test group'), 'Create_security_group fail'
41
+ group = @ec2.describe_security_groups([@group])[0]
42
+ assert_equal @group, group[:aws_group_name], 'Group must be created but does not exist'
43
+ end
44
+
45
+ def test_03_perms_add
46
+ assert @ec2.authorize_security_group_named_ingress(@group, TestCredentials.account_number, 'default')
47
+ assert @ec2.authorize_security_group_IP_ingress(@group, 80, 80, 'udp', '192.168.1.0/8')
48
+ end
49
+
50
+ def test_04_check_new_perms_exist
51
+ assert_equal 2, @ec2.describe_security_groups([@group])[0][:aws_perms].size
52
+ end
53
+
54
+ def test_05_perms_remove
55
+ assert @ec2.revoke_security_group_IP_ingress(@group, 80, 80, 'udp', '192.168.1.0/8')
56
+ assert @ec2.revoke_security_group_named_ingress(@group,
57
+ TestCredentials.account_number, 'default')
58
+ end
59
+
60
+ def test_06_describe_images
61
+ images = @ec2.describe_images
62
+ assert images.size>0, 'Amazon must have at least some public images'
63
+ # unknown image
64
+ assert_raise(Aws::AwsError) { @ec2.describe_images(['ami-ABCDEFGH']) }
65
+ end
66
+
67
+ def test_07_describe_instanses
68
+ assert @ec2.describe_instances
69
+ # unknown image
70
+ assert_raise(Aws::AwsError) { @ec2.describe_instances(['i-ABCDEFGH']) }
71
+ end
72
+
73
+ def test_08_delete_security_group
74
+ assert @ec2.delete_security_group(@group), 'Delete_security_group fail'
75
+ end
76
+
77
+ def test_09_delete_key_pair
78
+ assert @ec2.delete_key_pair(@key), 'Delete_key_pair fail'
65
79
  ## Hmmm... Amazon does not through the exception any more. It now just returns a 'true' if the key does not exist any more...
66
80
  ## # key must be deleted already
67
81
  ## assert_raise(Aws::AwsError) { @ec2.delete_key_pair(@key) }
68
- end
69
-
70
- def test_10_signature_version_0
71
- ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :signature_version => '0')
72
- images = ec2.describe_images
73
- assert images.size>0, 'Amazon must have at least some public images'
74
- # check that the request has correct signature version
75
- assert ec2.last_request.path.include?('SignatureVersion=0')
76
- end
77
-
78
- def test_11_regions
79
- regions = nil
80
- assert_nothing_raised do
81
- regions = @ec2.describe_regions
82
82
  end
83
- # check we got more that 0 regions
84
- assert regions.size > 0
85
- # check an access to regions
86
- regions.each do |region|
87
- regional_ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :region => region)
88
- # do we have a correct endpoint server?
89
- assert_equal "#{region}.ec2.amazonaws.com", regional_ec2.params[:server]
90
- # get a list of images from every region
91
- images = nil
92
- assert_nothing_raised do
93
- images = regional_ec2.describe_regions
94
- end
95
- # every region must have images
96
- assert images.size > 0
83
+
84
+ def test_10_signature_version_0
85
+ ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :signature_version => '0')
86
+ images = ec2.describe_images
87
+ assert images.size>0, 'Amazon must have at least some public images'
88
+ # check that the request has correct signature version
89
+ assert ec2.last_request.path.include?('SignatureVersion=0')
90
+ end
91
+
92
+ def test_11_regions
93
+ regions = nil
94
+ assert_nothing_raised do
95
+ regions = @ec2.describe_regions
96
+ end
97
+ # check we got more that 0 regions
98
+ assert regions.size > 0
99
+ # check an access to regions
100
+ regions.each do |region|
101
+ regional_ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :region => region)
102
+ # do we have a correct endpoint server?
103
+ assert_equal "#{region}.ec2.amazonaws.com", regional_ec2.params[:server]
104
+ # get a list of images from every region
105
+ images = nil
106
+ assert_nothing_raised do
107
+ images = regional_ec2.describe_regions
108
+ end
109
+ # every region must have images
110
+ assert images.size > 0
111
+ end
112
+ end
113
+
114
+ def test_12_endpoint_url
115
+ ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :endpoint_url => 'a://b.c:0/d/', :region => 'z')
116
+ # :endpoint_url has a priority hence :region should be ommitted
117
+ assert_equal 'a', ec2.params[:protocol]
118
+ assert_equal 'b.c', ec2.params[:server]
119
+ assert_equal '/d/', ec2.params[:service]
120
+ assert_equal 0, ec2.params[:port]
121
+ assert_nil ec2.params[:region]
97
122
  end
98
- end
99
-
100
- def test_12_endpoint_url
101
- ec2 = Aws::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :endpoint_url => 'a://b.c:0/d/', :region => 'z')
102
- # :endpoint_url has a priority hence :region should be ommitted
103
- assert_equal 'a', ec2.params[:protocol]
104
- assert_equal 'b.c', ec2.params[:server]
105
- assert_equal '/d/', ec2.params[:service]
106
- assert_equal 0, ec2.params[:port]
107
- assert_nil ec2.params[:region]
108
- end
109
123
 
110
124
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 43
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 13
10
- version: 2.3.13
9
+ - 20
10
+ version: 2.3.20
11
11
  platform: ruby
12
12
  authors:
13
13
  - Travis Reeder
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-06-25 00:00:00 -07:00
20
+ date: 2010-07-27 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency