nirvdrum-amazon-ec2 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.yardopts +1 -0
- data/ChangeLog +304 -0
- data/LICENSE +66 -0
- data/README.rdoc +359 -0
- data/README_dev.rdoc +10 -0
- data/Rakefile +70 -0
- data/VERSION +1 -0
- data/amazon-ec2.gemspec +142 -0
- data/bin/ec2-gem-example.rb +137 -0
- data/bin/ec2-gem-profile.rb +10 -0
- data/bin/ec2sh +62 -0
- data/bin/setup.rb +29 -0
- data/deps.rip +1 -0
- data/lib/AWS.rb +321 -0
- data/lib/AWS/Autoscaling.rb +70 -0
- data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
- data/lib/AWS/Cloudwatch.rb +32 -0
- data/lib/AWS/Cloudwatch/monitoring.rb +80 -0
- data/lib/AWS/EC2.rb +33 -0
- data/lib/AWS/EC2/availability_zones.rb +29 -0
- data/lib/AWS/EC2/console.rb +25 -0
- data/lib/AWS/EC2/devpay.rb +18 -0
- data/lib/AWS/EC2/elastic_ips.rb +86 -0
- data/lib/AWS/EC2/image_attributes.rb +133 -0
- data/lib/AWS/EC2/images.rb +117 -0
- data/lib/AWS/EC2/instances.rb +234 -0
- data/lib/AWS/EC2/keypairs.rb +47 -0
- data/lib/AWS/EC2/products.rb +21 -0
- data/lib/AWS/EC2/security_groups.rb +164 -0
- data/lib/AWS/EC2/snapshots.rb +102 -0
- data/lib/AWS/EC2/spot_instance_requests.rb +105 -0
- data/lib/AWS/EC2/volumes.rb +100 -0
- data/lib/AWS/ELB.rb +71 -0
- data/lib/AWS/ELB/load_balancers.rb +178 -0
- data/lib/AWS/RDS.rb +73 -0
- data/lib/AWS/RDS/rds.rb +522 -0
- data/lib/AWS/exceptions.rb +200 -0
- data/lib/AWS/responses.rb +21 -0
- data/perftools/ec2prof +0 -0
- data/perftools/ec2prof-results.dot +132 -0
- data/perftools/ec2prof-results.txt +100 -0
- data/perftools/ec2prof.symbols +102 -0
- data/test/test_Autoscaling_groups.rb +337 -0
- data/test/test_EC2.rb +68 -0
- data/test/test_EC2_availability_zones.rb +49 -0
- data/test/test_EC2_console.rb +54 -0
- data/test/test_EC2_elastic_ips.rb +144 -0
- data/test/test_EC2_image_attributes.rb +238 -0
- data/test/test_EC2_images.rb +229 -0
- data/test/test_EC2_instances.rb +611 -0
- data/test/test_EC2_keypairs.rb +123 -0
- data/test/test_EC2_products.rb +48 -0
- data/test/test_EC2_responses.rb +53 -0
- data/test/test_EC2_s3_xmlsimple.rb +80 -0
- data/test/test_EC2_security_groups.rb +205 -0
- data/test/test_EC2_snapshots.rb +83 -0
- data/test/test_EC2_spot_instance_requests.rb +178 -0
- data/test/test_EC2_volumes.rb +142 -0
- data/test/test_ELB_load_balancers.rb +239 -0
- data/test/test_RDS.rb +354 -0
- data/test/test_helper.rb +23 -0
- data/wsdl/2007-08-29.ec2.wsdl +1269 -0
- data/wsdl/2008-02-01.ec2.wsdl +1614 -0
- data/wsdl/2008-05-05.ec2.wsdl +2052 -0
- data/wsdl/2008-12-01.ec2.wsdl +2354 -0
- data/wsdl/2009-10-31.ec2.wsdl +4261 -0
- data/wsdl/2009-11-30.ec2.wsdl +4668 -0
- metadata +199 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 availability zones" do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@describe_availability_zones_response_body = <<-RESPONSE
|
19
|
+
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01/">
|
20
|
+
<availabilityZoneInfo>
|
21
|
+
<item>
|
22
|
+
<zoneName>us-east-1a</zoneName>
|
23
|
+
<zoneState>available</zoneState>
|
24
|
+
</item>
|
25
|
+
<item>
|
26
|
+
<zoneName>us-east-1b</zoneName>
|
27
|
+
<zoneState>available</zoneState>
|
28
|
+
</item>
|
29
|
+
</availabilityZoneInfo>
|
30
|
+
</DescribeAvailabilityZonesResponse>
|
31
|
+
RESPONSE
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "should be able to be described with describe_availability_zones" do
|
36
|
+
@ec2.stubs(:make_request).with('DescribeAvailabilityZones', { "ZoneName.1" => "us-east-1a", "ZoneName.2" => "us-east-1b" }).
|
37
|
+
returns stub(:body => @describe_availability_zones_response_body, :is_a? => true)
|
38
|
+
@ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] ).should.be.an.instance_of Hash
|
39
|
+
|
40
|
+
response = @ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] )
|
41
|
+
|
42
|
+
response.availabilityZoneInfo.item[0].zoneName.should.equal "us-east-1a"
|
43
|
+
response.availabilityZoneInfo.item[0].zoneState.should.equal "available"
|
44
|
+
|
45
|
+
response.availabilityZoneInfo.item[1].zoneName.should.equal "us-east-1b"
|
46
|
+
response.availabilityZoneInfo.item[1].zoneState.should.equal "available"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "The EC2 console " do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@get_console_output_response_body = <<-RESPONSE
|
19
|
+
<GetConsoleOutputResponse xmlns="http://ec2.amazonaws.com/doc/2007-03-01">
|
20
|
+
<instanceId>i-28a64341</instanceId>
|
21
|
+
<timestamp>2007-01-03 15:00:00</timestamp>
|
22
|
+
<output>
|
23
|
+
YyB2ZXJzaW9uIDQuMC4xIDIwMDUwNzI3IChSZWQgSGF0IDQuMC4xLTUpKSAjMSBTTVAgVGh1IE9j
|
24
|
+
dCAyNiAwODo0MToyNiBTQVNUIDIwMDYKQklPUy1wcm92aWRlZCBwaHlzaWNhbCBSQU0gbWFwOgpY
|
25
|
+
ZW46IDAwMDAwMDAwMDAwMDAwMDAgLSAwMDAwMDAwMDZhNDAwMDAwICh1c2FibGUpCjk4ME1CIEhJ
|
26
|
+
R0hNRU0gYXZhaWxhYmxlLgo3MjdNQiBMT1dNRU0gYXZhaWxhYmxlLgpOWCAoRXhlY3V0ZSBEaXNh
|
27
|
+
YmxlKSBwcm90ZWN0aW9uOiBhY3RpdmUKSVJRIGxvY2t1cCBkZXRlY3Rpb24gZGlzYWJsZWQKQnVp
|
28
|
+
bHQgMSB6b25lbGlzdHMKS2VybmVsIGNvbW1hbmQgbGluZTogcm9vdD0vZGV2L3NkYTEgcm8gNApF
|
29
|
+
bmFibGluZyBmYXN0IEZQVSBzYXZlIGFuZCByZXN0b3JlLi4uIGRvbmUuCg==
|
30
|
+
</output>
|
31
|
+
</GetConsoleOutputResponse>
|
32
|
+
RESPONSE
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
specify "should return info written to a specific instances console" do
|
38
|
+
@ec2.stubs(:make_request).with('GetConsoleOutput', {"InstanceId"=>"i-2ea64347"}).
|
39
|
+
returns stub(:body => @get_console_output_response_body, :is_a? => true)
|
40
|
+
@ec2.get_console_output( :instance_id => "i-2ea64347" ).should.be.an.instance_of Hash
|
41
|
+
response = @ec2.get_console_output( :instance_id => "i-2ea64347" )
|
42
|
+
response.instanceId.should.equal "i-28a64341"
|
43
|
+
response.timestamp.should.equal "2007-01-03 15:00:00"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
specify "method get_console_output should raise an exception when called without nil/empty string arguments" do
|
48
|
+
lambda { @ec2.get_console_output() }.should.raise(AWS::ArgumentError)
|
49
|
+
lambda { @ec2.get_console_output(:instance_id => nil) }.should.raise(AWS::ArgumentError)
|
50
|
+
lambda { @ec2.get_console_output(:instance_id => "") }.should.raise(AWS::ArgumentError)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 elastic IP addresses " do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@allocate_address_body = <<-RESPONSE
|
19
|
+
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01">
|
20
|
+
<publicIp>67.202.55.255</publicIp>
|
21
|
+
</AllocateAddressResponse>
|
22
|
+
RESPONSE
|
23
|
+
|
24
|
+
@describe_addresses_response_body = <<-RESPONSE
|
25
|
+
<DescribeAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01">
|
26
|
+
<addressesSet>
|
27
|
+
<item>
|
28
|
+
<instanceId>i-28a64341</instanceId>
|
29
|
+
<publicIp>67.202.55.255</publicIp>
|
30
|
+
</item>
|
31
|
+
</addressesSet>
|
32
|
+
</DescribeAddressesResponse>
|
33
|
+
RESPONSE
|
34
|
+
|
35
|
+
@release_address_response_body = <<-RESPONSE
|
36
|
+
<ReleaseAddressResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01">
|
37
|
+
<return>true</return>
|
38
|
+
</ReleaseAddressResponse>
|
39
|
+
RESPONSE
|
40
|
+
|
41
|
+
@associate_address_response_body = <<-RESPONSE
|
42
|
+
<AssociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01">
|
43
|
+
<return>true</return>
|
44
|
+
</AssociateAddressResponse>
|
45
|
+
RESPONSE
|
46
|
+
|
47
|
+
@disassociate_address_response_body = <<-RESPONSE
|
48
|
+
<DisassociateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01">
|
49
|
+
<return>true</return>
|
50
|
+
</DisassociateAddressResponse>
|
51
|
+
RESPONSE
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
specify "should be able to be created" do
|
57
|
+
@ec2.stubs(:make_request).with('AllocateAddress', {}).
|
58
|
+
returns stub(:body => @allocate_address_body, :is_a? => true)
|
59
|
+
|
60
|
+
@ec2.allocate_address.should.be.an.instance_of Hash
|
61
|
+
|
62
|
+
response = @ec2.allocate_address
|
63
|
+
response.publicIp.should.equal "67.202.55.255"
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
#specify "method create_keypair should reject bad arguments" do
|
68
|
+
# @ec2.stubs(:make_request).with('CreateKeyPair', {"KeyName"=>"example-key-name"}).
|
69
|
+
# returns stub(:body => @create_keypair_response_body, :is_a? => true)
|
70
|
+
#
|
71
|
+
# lambda { @ec2.create_keypair( :key_name => "example-key-name" ) }.should.not.raise(AWS::ArgumentError)
|
72
|
+
# lambda { @ec2.create_keypair() }.should.raise(AWS::ArgumentError)
|
73
|
+
# lambda { @ec2.create_keypair( :key_name => nil ) }.should.raise(AWS::ArgumentError)
|
74
|
+
# lambda { @ec2.create_keypair( :key_name => "" ) }.should.raise(AWS::ArgumentError)
|
75
|
+
#end
|
76
|
+
|
77
|
+
|
78
|
+
specify "should be able to be described with describe_addresses" do
|
79
|
+
@ec2.stubs(:make_request).with('DescribeAddresses', {"PublicIp.1"=>"67.202.55.255"}).
|
80
|
+
returns stub(:body => @describe_addresses_response_body, :is_a? => true)
|
81
|
+
|
82
|
+
@ec2.describe_addresses( :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
83
|
+
|
84
|
+
response = @ec2.describe_addresses( :public_ip => "67.202.55.255" )
|
85
|
+
response.addressesSet.item[0].instanceId.should.equal "i-28a64341"
|
86
|
+
response.addressesSet.item[0].publicIp.should.equal "67.202.55.255"
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
specify "should be able to be released with release_address" do
|
91
|
+
@ec2.stubs(:make_request).with('ReleaseAddress', {"PublicIp" => "67.202.55.255"}).
|
92
|
+
returns stub(:body => @release_address_response_body, :is_a? => true)
|
93
|
+
|
94
|
+
@ec2.release_address( :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
95
|
+
|
96
|
+
response = @ec2.release_address( :public_ip => "67.202.55.255" )
|
97
|
+
response.return.should.equal "true"
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
specify "should be able to be associated with an instance with associate_address" do
|
102
|
+
@ec2.stubs(:make_request).with('AssociateAddress', {"InstanceId" => "i-2ea64347", "PublicIp"=>"67.202.55.255"}).
|
103
|
+
returns stub(:body => @associate_address_response_body, :is_a? => true)
|
104
|
+
|
105
|
+
@ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
106
|
+
|
107
|
+
response = @ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" )
|
108
|
+
response.return.should.equal "true"
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
specify "method associate_address should reject bad arguments" do
|
113
|
+
@ec2.stubs(:make_request).with('AssociateAddress', {"InstanceId" => "i-2ea64347", "PublicIp"=>"67.202.55.255"}).
|
114
|
+
returns stub(:body => @associate_address_response_body, :is_a? => true)
|
115
|
+
|
116
|
+
lambda { @ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" ) }.should.not.raise(AWS::ArgumentError)
|
117
|
+
lambda { @ec2.associate_address() }.should.raise(AWS::ArgumentError)
|
118
|
+
lambda { @ec2.associate_address( :instance_id => nil ) }.should.raise(AWS::ArgumentError)
|
119
|
+
lambda { @ec2.associate_address( :public_ip => "" ) }.should.raise(AWS::ArgumentError)
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
specify "should be able to be disassociated with an instance with disassociate_address" do
|
124
|
+
@ec2.stubs(:make_request).with('DisassociateAddress', {'PublicIp' => '67.202.55.255'}).
|
125
|
+
returns stub(:body => @disassociate_address_response_body, :is_a? => true)
|
126
|
+
|
127
|
+
@ec2.disassociate_address( :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
128
|
+
|
129
|
+
response = @ec2.disassociate_address( :public_ip => "67.202.55.255" )
|
130
|
+
response.return.should.equal "true"
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
specify "method disassociate_address should reject bad arguments" do
|
135
|
+
@ec2.stubs(:make_request).with('DisassociateAddress', {'PublicIp' => '67.202.55.255'}).
|
136
|
+
returns stub(:body => @disassociate_address_response_body, :is_a? => true)
|
137
|
+
|
138
|
+
lambda { @ec2.disassociate_address( :public_ip => "67.202.55.255" ) }.should.not.raise(AWS::ArgumentError)
|
139
|
+
lambda { @ec2.disassociate_address() }.should.raise(AWS::ArgumentError)
|
140
|
+
lambda { @ec2.disassociate_address( :public_ip => "" ) }.should.raise(AWS::ArgumentError)
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 image_attributes " do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@modify_image_attribute_response_body = <<-RESPONSE
|
19
|
+
<ModifyImageAttributeResponse xm-lns="http://ec2.amazonaws.com/doc/2007-03-01">
|
20
|
+
<return>true</return>
|
21
|
+
</ModifyImageAttributeResponse>
|
22
|
+
RESPONSE
|
23
|
+
|
24
|
+
@reset_image_attribute_response_body = <<-RESPONSE
|
25
|
+
<ResetImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2007-03-01">
|
26
|
+
<return>true</return>
|
27
|
+
</ResetImageAttributeResponse>
|
28
|
+
RESPONSE
|
29
|
+
|
30
|
+
@describe_image_attribute_response_body_launch_permissions = <<-RESPONSE
|
31
|
+
<DescribeImageAttributeResponse xm-lns="http://ec2.amazonaws.com/doc/2007-03-01">
|
32
|
+
<imageId>ami-61a54008</imageId>
|
33
|
+
<launchPermission>
|
34
|
+
<item>
|
35
|
+
<group>all</group>
|
36
|
+
</item>
|
37
|
+
<item>
|
38
|
+
<userId>495219933132</userId>
|
39
|
+
</item>
|
40
|
+
</launchPermission>
|
41
|
+
</DescribeImageAttributeResponse>
|
42
|
+
RESPONSE
|
43
|
+
|
44
|
+
@describe_image_attribute_response_body_product_codes = <<-RESPONSE
|
45
|
+
<DescribeImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-03">
|
46
|
+
<imageId>ami-61a54008</imageId>
|
47
|
+
<productCodes>
|
48
|
+
<item>
|
49
|
+
<productCode>774F4FF8</productCode>
|
50
|
+
</item>
|
51
|
+
</productCodes>
|
52
|
+
</DescribeImageAttributeResponse>
|
53
|
+
RESPONSE
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
specify "should be able to be changed with modify_image_attribute (with :attribute and single value :user_id and :group)" do
|
59
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
60
|
+
"Attribute"=>"launchPermission",
|
61
|
+
"OperationType"=>"add",
|
62
|
+
"UserId.1"=>"123",
|
63
|
+
"Group.1"=>"all"}).
|
64
|
+
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
65
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id=>["123"], :group=>["all"]).should.be.an.instance_of Hash
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
specify "should be able to be changed with modify_image_attribute ( with :attribute but specifying :group only)" do
|
70
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
71
|
+
"Attribute"=>"launchPermission",
|
72
|
+
"OperationType"=>"add",
|
73
|
+
"Group.1"=>"all"}).
|
74
|
+
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
75
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]).should.be.an.instance_of Hash
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
specify "should be able to be changed with modify_image_attribute ( with :operation_type 'remove')" do
|
80
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
81
|
+
"Attribute"=>"launchPermission",
|
82
|
+
"OperationType"=>"remove",
|
83
|
+
"Group.1"=>"all"}).
|
84
|
+
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
85
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"remove", :group=>["all"]).should.be.an.instance_of Hash
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
specify "should be able to be changed with modify_image_attribute ( with :attribute but specifying :user_id only)" do
|
90
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
91
|
+
"Attribute"=>"launchPermission",
|
92
|
+
"OperationType"=>"add",
|
93
|
+
"UserId.1"=>"123"}).returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
94
|
+
|
95
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008",
|
96
|
+
:attribute=>"launchPermission",
|
97
|
+
:operation_type=>"add",
|
98
|
+
:user_id=>["123"]).should.be.an.instance_of Hash
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
specify "should be able to be changed with modify_image_attribute ( with :attribute=>'productCodes')" do
|
103
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
104
|
+
"Attribute"=>"productCodes",
|
105
|
+
"OperationType"=>"",
|
106
|
+
"ProductCode.1"=>"774F4FF8"}).returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
107
|
+
|
108
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008",
|
109
|
+
:attribute=>"productCodes",
|
110
|
+
:product_code=>["774F4FF8"]).should.be.an.instance_of Hash
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
specify "should be able to be changed with modify_image_attribute ( with :attribute and multiple :user_id and :group elements)" do
|
115
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
116
|
+
"Attribute"=>"launchPermission",
|
117
|
+
"OperationType"=>"add",
|
118
|
+
"UserId.1"=>"123",
|
119
|
+
"UserId.2"=>"345",
|
120
|
+
"Group.1"=>"123",
|
121
|
+
"Group.2"=>"all"}).returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
122
|
+
|
123
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008",
|
124
|
+
:attribute=>"launchPermission",
|
125
|
+
:operation_type=>"add",
|
126
|
+
:user_id=>["123", "345"],
|
127
|
+
:group=>["123", "all"]).should.be.an.instance_of Hash
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
specify "should raise an exception when modify_image_attribute is called with incorrect arguments" do
|
132
|
+
# method args can't be nil or empty
|
133
|
+
lambda { @ec2.modify_image_attribute() }.should.raise(AWS::ArgumentError)
|
134
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"") }.should.raise(AWS::ArgumentError)
|
135
|
+
|
136
|
+
# :image_id option must be not be empty or nil
|
137
|
+
lambda { @ec2.modify_image_attribute(:image_id=>nil, :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
138
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
139
|
+
|
140
|
+
# :attribute currently has two options which are 'launchPermission' and 'productCodes, it should fail with any other value, nil, or empty
|
141
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil, :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
142
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
143
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
144
|
+
|
145
|
+
# :attribute => 'launchPermission' option should fail if neither :group nor :user_id are also provided
|
146
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add") }.should.raise(AWS::ArgumentError)
|
147
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group => nil) }.should.raise(AWS::ArgumentError)
|
148
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group => "") }.should.raise(AWS::ArgumentError)
|
149
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id => nil) }.should.raise(AWS::ArgumentError)
|
150
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id => "") }.should.raise(AWS::ArgumentError)
|
151
|
+
|
152
|
+
# :attribute => 'productCodes' option should fail if :product_code isn't also provided
|
153
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes", :product_code=>nil) }.should.raise(AWS::ArgumentError)
|
154
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes", :product_code=>"") }.should.raise(AWS::ArgumentError)
|
155
|
+
|
156
|
+
# :operation_type currently has two options which are 'add' and 'remove', and it should fail with any other, nil or empty
|
157
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>nil, :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
158
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"", :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
159
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"foo", :group=>["all"]) }.should.raise(AWS::ArgumentError)
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
specify "method describe_image_attribute should return the proper attributes when called with launchPermission" do
|
164
|
+
@ec2.stubs(:make_request).with('DescribeImageAttribute', {"ImageId"=>"ami-61a54008",
|
165
|
+
"Attribute"=>"launchPermission" }).
|
166
|
+
returns stub(:body => @describe_image_attribute_response_body_launch_permissions, :is_a? => true)
|
167
|
+
|
168
|
+
@ec2.describe_image_attribute(:image_id => "ami-61a54008", :attribute => "launchPermission").
|
169
|
+
should.be.an.instance_of Hash
|
170
|
+
|
171
|
+
response = @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission")
|
172
|
+
response.imageId.should.equal "ami-61a54008"
|
173
|
+
response.launchPermission.item[0].group.should.equal "all"
|
174
|
+
response.launchPermission.item[1].userId.should.equal "495219933132"
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
specify "method describe_image_attribute should return the proper attributes when called with productCodes" do
|
179
|
+
@ec2.stubs(:make_request).with('DescribeImageAttribute', {"ImageId"=>"ami-61a54008",
|
180
|
+
"Attribute"=>"productCodes" }).
|
181
|
+
returns stub(:body => @describe_image_attribute_response_body_product_codes, :is_a? => true)
|
182
|
+
|
183
|
+
@ec2.describe_image_attribute(:image_id => "ami-61a54008", :attribute => "productCodes").
|
184
|
+
should.be.an.instance_of Hash
|
185
|
+
|
186
|
+
response = @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes")
|
187
|
+
response.imageId.should.equal "ami-61a54008"
|
188
|
+
response.productCodes.item[0].productCode.should.equal "774F4FF8"
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
specify "should raise an exception when describe_image_attribute is called with incorrect arguments" do
|
193
|
+
# method args can't be nil or empty
|
194
|
+
lambda { @ec2.describe_image_attribute() }.should.raise(AWS::ArgumentError)
|
195
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"") }.should.raise(AWS::ArgumentError)
|
196
|
+
|
197
|
+
# :image_id option must be not be empty or nil w/ launchPermission
|
198
|
+
lambda { @ec2.describe_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError)
|
199
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError)
|
200
|
+
|
201
|
+
# :image_id option must be not be empty or nil w/ productCodes
|
202
|
+
lambda { @ec2.describe_image_attribute(:image_id=>nil, :attribute=>"productCodes") }.should.raise(AWS::ArgumentError)
|
203
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"", :attribute=>"productCodes") }.should.raise(AWS::ArgumentError)
|
204
|
+
|
205
|
+
# :attribute currently has two options which are 'launchPermission' and 'productCodes', it should fail with any other values,
|
206
|
+
# nil, or empty
|
207
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(AWS::ArgumentError)
|
208
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(AWS::ArgumentError)
|
209
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(AWS::ArgumentError)
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
specify "should be able to reset attributes with reset_image_attribute " do
|
214
|
+
@ec2.stubs(:make_request).with('ResetImageAttribute', {"ImageId"=>"ami-61a54008",
|
215
|
+
"Attribute"=>"launchPermission"}).
|
216
|
+
returns stub(:body => @reset_image_attribute_response_body, :is_a? => true)
|
217
|
+
@ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission").should.be.an.instance_of Hash
|
218
|
+
@ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission").return.should.equal "true"
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
specify "should raise an exception when reset_image_attribute is called with incorrect arguments" do
|
223
|
+
# method args can't be nil or empty
|
224
|
+
lambda { @ec2.reset_image_attribute() }.should.raise(AWS::ArgumentError)
|
225
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"") }.should.raise(AWS::ArgumentError)
|
226
|
+
|
227
|
+
# :image_id option must be not be empty or nil
|
228
|
+
lambda { @ec2.reset_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError)
|
229
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError)
|
230
|
+
|
231
|
+
# :attribute currently has one option which is 'launchPermission', it should fail with any other value, nil, or empty
|
232
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(AWS::ArgumentError)
|
233
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(AWS::ArgumentError)
|
234
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(AWS::ArgumentError)
|
235
|
+
end
|
236
|
+
|
237
|
+
|
238
|
+
end
|