awsum 0.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.
- data/.autotest +1 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +19 -0
- data/README.rdoc +42 -0
- data/Rakefile +75 -0
- data/awsum.gemspec +199 -0
- data/lib/awsum.rb +20 -0
- data/lib/awsum/ec2.rb +741 -0
- data/lib/awsum/ec2/address.rb +67 -0
- data/lib/awsum/ec2/availability_zone.rb +16 -0
- data/lib/awsum/ec2/image.rb +62 -0
- data/lib/awsum/ec2/instance.rb +57 -0
- data/lib/awsum/ec2/keypair.rb +16 -0
- data/lib/awsum/ec2/parsers/address_parser.rb +61 -0
- data/lib/awsum/ec2/parsers/availability_zone_parser.rb +57 -0
- data/lib/awsum/ec2/parsers/image_parser.rb +74 -0
- data/lib/awsum/ec2/parsers/instance_parser.rb +90 -0
- data/lib/awsum/ec2/parsers/keypair_parser.rb +64 -0
- data/lib/awsum/ec2/parsers/purchase_reserved_instances_offering_parser.rb +34 -0
- data/lib/awsum/ec2/parsers/region_parser.rb +56 -0
- data/lib/awsum/ec2/parsers/register_image_parser.rb +34 -0
- data/lib/awsum/ec2/parsers/reserved_instance_parser.rb +64 -0
- data/lib/awsum/ec2/parsers/reserved_instances_offering_parser.rb +63 -0
- data/lib/awsum/ec2/parsers/security_group_parser.rb +106 -0
- data/lib/awsum/ec2/parsers/snapshot_parser.rb +64 -0
- data/lib/awsum/ec2/parsers/volume_parser.rb +77 -0
- data/lib/awsum/ec2/region.rb +54 -0
- data/lib/awsum/ec2/reserved_instance.rb +24 -0
- data/lib/awsum/ec2/reserved_instances_offering.rb +20 -0
- data/lib/awsum/ec2/security_group.rb +74 -0
- data/lib/awsum/ec2/snapshot.rb +23 -0
- data/lib/awsum/ec2/volume.rb +65 -0
- data/lib/awsum/error.rb +53 -0
- data/lib/awsum/net_fix.rb +100 -0
- data/lib/awsum/parser.rb +18 -0
- data/lib/awsum/requestable.rb +216 -0
- data/lib/awsum/s3.rb +220 -0
- data/lib/awsum/s3/bucket.rb +28 -0
- data/lib/awsum/s3/headers.rb +24 -0
- data/lib/awsum/s3/object.rb +138 -0
- data/lib/awsum/s3/parsers/bucket_parser.rb +43 -0
- data/lib/awsum/support.rb +94 -0
- data/spec/fixtures/ec2/addresses.xml +10 -0
- data/spec/fixtures/ec2/allocate_address.xml +5 -0
- data/spec/fixtures/ec2/associate_address.xml +5 -0
- data/spec/fixtures/ec2/attach_volume.xml +9 -0
- data/spec/fixtures/ec2/authorize_ip_access.xml +5 -0
- data/spec/fixtures/ec2/authorize_owner_group_access.xml +5 -0
- data/spec/fixtures/ec2/authorize_owner_group_access_error.xml +2 -0
- data/spec/fixtures/ec2/availability_zones.xml +16 -0
- data/spec/fixtures/ec2/available_volume.xml +14 -0
- data/spec/fixtures/ec2/create_key_pair.xml +29 -0
- data/spec/fixtures/ec2/create_security_group.xml +5 -0
- data/spec/fixtures/ec2/create_snapshot.xml +9 -0
- data/spec/fixtures/ec2/create_volume.xml +10 -0
- data/spec/fixtures/ec2/delete_key_pair.xml +5 -0
- data/spec/fixtures/ec2/delete_security_group.xml +5 -0
- data/spec/fixtures/ec2/delete_snapshot.xml +5 -0
- data/spec/fixtures/ec2/delete_volume.xml +5 -0
- data/spec/fixtures/ec2/deregister_image.xml +5 -0
- data/spec/fixtures/ec2/detach_volume.xml +9 -0
- data/spec/fixtures/ec2/disassociate_address.xml +5 -0
- data/spec/fixtures/ec2/image.xml +15 -0
- data/spec/fixtures/ec2/images.xml +77 -0
- data/spec/fixtures/ec2/instance.xml +36 -0
- data/spec/fixtures/ec2/instances.xml +88 -0
- data/spec/fixtures/ec2/internal_error.xml +2 -0
- data/spec/fixtures/ec2/invalid_amiid_error.xml +2 -0
- data/spec/fixtures/ec2/invalid_request_error.xml +2 -0
- data/spec/fixtures/ec2/key_pairs.xml +10 -0
- data/spec/fixtures/ec2/purchase_reserved_instances_offering.xml +5 -0
- data/spec/fixtures/ec2/purchase_reserved_instances_offerings.xml +6 -0
- data/spec/fixtures/ec2/regions.xml +14 -0
- data/spec/fixtures/ec2/register_image.xml +5 -0
- data/spec/fixtures/ec2/release_address.xml +5 -0
- data/spec/fixtures/ec2/reserved_instances.xml +18 -0
- data/spec/fixtures/ec2/reserved_instances_offering.xml +15 -0
- data/spec/fixtures/ec2/reserved_instances_offerings.xml +276 -0
- data/spec/fixtures/ec2/revoke_ip_access.xml +5 -0
- data/spec/fixtures/ec2/revoke_owner_group_access.xml +5 -0
- data/spec/fixtures/ec2/run_instances.xml +30 -0
- data/spec/fixtures/ec2/security_groups.xml +159 -0
- data/spec/fixtures/ec2/snapshots.xml +13 -0
- data/spec/fixtures/ec2/terminate_instances.xml +17 -0
- data/spec/fixtures/ec2/unassociated_address.xml +10 -0
- data/spec/fixtures/ec2/volumes.xml +23 -0
- data/spec/fixtures/errors/invalid_parameter_value.xml +2 -0
- data/spec/fixtures/s3/buckets.xml +2 -0
- data/spec/fixtures/s3/copy_failure.xml +23 -0
- data/spec/fixtures/s3/invalid_request_signature.xml +5 -0
- data/spec/fixtures/s3/keys.xml +2 -0
- data/spec/lib/awsum/ec2/address_spec.rb +149 -0
- data/spec/lib/awsum/ec2/availability_zones_spec.rb +21 -0
- data/spec/lib/awsum/ec2/image_spec.rb +92 -0
- data/spec/lib/awsum/ec2/instance_spec.rb +125 -0
- data/spec/lib/awsum/ec2/keypair_spec.rb +55 -0
- data/spec/lib/awsum/ec2/parsers/address_parser_spec.rb +51 -0
- data/spec/lib/awsum/ec2/parsers/availability_zone_parser_spec.rb +28 -0
- data/spec/lib/awsum/ec2/parsers/image_parser_spec.rb +66 -0
- data/spec/lib/awsum/ec2/parsers/instance_parser_spec.rb +75 -0
- data/spec/lib/awsum/ec2/parsers/keypair_parser_spec.rb +74 -0
- data/spec/lib/awsum/ec2/parsers/purchase_reserved_instances_offering_parser_spec.rb +14 -0
- data/spec/lib/awsum/ec2/parsers/region_parser_spec.rb +27 -0
- data/spec/lib/awsum/ec2/parsers/register_image_parser_spec.rb +15 -0
- data/spec/lib/awsum/ec2/parsers/reserved_instance_parser_spec.rb +35 -0
- data/spec/lib/awsum/ec2/parsers/reserved_instances_offering_parser_spec.rb +32 -0
- data/spec/lib/awsum/ec2/parsers/security_group_parser_spec.rb +78 -0
- data/spec/lib/awsum/ec2/parsers/snapshot_parser_spec.rb +30 -0
- data/spec/lib/awsum/ec2/parsers/volume_parser_spec.rb +35 -0
- data/spec/lib/awsum/ec2/region_spec.rb +73 -0
- data/spec/lib/awsum/ec2/reserved_instance_spec.rb +61 -0
- data/spec/lib/awsum/ec2/reserved_instances_offering_spec.rb +33 -0
- data/spec/lib/awsum/ec2/security_group_spec.rb +179 -0
- data/spec/lib/awsum/ec2/snapshots_spec.rb +69 -0
- data/spec/lib/awsum/ec2/volume_spec.rb +107 -0
- data/spec/lib/awsum/ec2_spec.rb +6 -0
- data/spec/lib/awsum/error_spec.rb +31 -0
- data/spec/lib/awsum/requestable_spec.rb +126 -0
- data/spec/lib/awsum/s3/bucket_spec.rb +95 -0
- data/spec/lib/awsum/s3/object_spec.rb +128 -0
- data/spec/lib/awsum/s3/parsers/bucket_parser_spec.rb +41 -0
- data/spec/lib/awsum/s3/parsers/object_parser_spec.rb +41 -0
- data/spec/spec_helper.rb +16 -0
- metadata +240 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::KeyPairParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::KeyPairParser.new(ec2) }
|
|
8
|
+
|
|
9
|
+
describe "parsing the result of a call to DescribeKeyPairs" do
|
|
10
|
+
let(:result) { parser.parse(fixture('ec2/key_pairs')) }
|
|
11
|
+
|
|
12
|
+
it "should return an array of key pairs" do
|
|
13
|
+
result.should be_a(Array)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "the first key pair" do
|
|
17
|
+
let(:key_pair) { result.first }
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
:name => 'gsg-keypair',
|
|
21
|
+
:fingerprint => 'ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab'
|
|
22
|
+
}.each do |key, value|
|
|
23
|
+
it "should have the correct #{key}" do
|
|
24
|
+
key_pair.send(key).should == value
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "parsing the result of a call to CreateKeyPair" do
|
|
31
|
+
let(:result) { parser.parse(fixture('ec2/create_key_pair')) }
|
|
32
|
+
|
|
33
|
+
it "should return an array of key pairs" do
|
|
34
|
+
result.should be_a(Array)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context "the first key pair" do
|
|
38
|
+
let(:key_pair) { result.first }
|
|
39
|
+
|
|
40
|
+
{
|
|
41
|
+
:name => 'test-keypair',
|
|
42
|
+
:fingerprint => 'ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab:ab',
|
|
43
|
+
:material => %q{-----BEGIN RSA PRIVATE KEY-----
|
|
44
|
+
MIIEogIBAAKCAQEAqkxIjNxLV/shvaep5Kum3N2xTV6aBbXezVA4HHE371HSq3haKTcST7QYeQha
|
|
45
|
+
92AmZojAm2ojqWMw9GJaeq/Q7NvXKdMgj3mKd7zY7tdC+HmKYVkAvJ9enuuVwPFxlt+5rPpZ2jS+
|
|
46
|
+
kl4MWEvWh1N5U1urx5gzHq2e/k7P+dCBwFnCHsg/p1mym4j4qwEHEviaUG6SnB8Xvuggp/pxCmJg
|
|
47
|
+
9Gie4cXNgbBboEyAQDRb/AmrehbBa90GOVDjDGIzB98rOcJ22FRrpLqSl2D+FQKsXWboqgbIrgKT
|
|
48
|
+
ven7mzb8cgDJNrWTI/MNP8p8gNTh+L7gTwPDcGfaDBiRpn9t3FiTBwIDAQABAoIBAEmuNZmUWpjX
|
|
49
|
+
U/LdjtkcF1bqKCMkchlUZfCI664KojvOOAruSHwakrafYhNDtS/gjtzAAC19z64i93RU9XatiQRh
|
|
50
|
+
3YcADM9ms604rNcxlY0x8NhLjNEPVv4FScav8AhqBci8jJGnTmi/fjHZphjo2c5iFEGILV3xmp/G
|
|
51
|
+
857PQsQ4nOAzoV7fQPYow4XiO/xhGh8p8o2Z9Og3GdbEGH1v/051g3O1eU7PFyQaxmOGNYmklMuM
|
|
52
|
+
V/8l/LK+OKR0f9KgqcgDSlEbidqsmWM0a1/t7+I5W/mgXSZl5U4HN680DKbkzoX0kgoPN7XMbcSX
|
|
53
|
+
sHNguqDfrvkBUQu1vEaXebWfpekCgYEA0qVbcFGxKniyYxmvtSrbb5bpEnh6zRCGXgSU4fX41i8P
|
|
54
|
+
Xg15R7FnwGO5nuRXqGW6CSgfbA7YAVEQHunUOB0XWuJWgn6gsqvnCZvyfRnqyMJJjRhvuaUMTn/5
|
|
55
|
+
ikcayflqPFHvv5Z+pB3pWNaTD6lM5imdF1In9RBYL4q5Vpt9gl0CgYEAzvb6cS6Yi0PkxU3OOEmg
|
|
56
|
+
98QcdTEd1hrk3r6uXI1TOeiUPIw+dyGCKa9OqpcFDs+0FskFs6RzztRh2gpwQZTH3UOYPqsjsWd+
|
|
57
|
+
AjL3jv+vmpU1OhnA0SpkyiiZtaSAV2N+Xlq8orG6fbnYFCdzHbufLFaoOpbGptmLfrwMSvnhXLMC
|
|
58
|
+
gYBxRsEcbqHycAOmLUsDBvAIW0QtTaLkIe3QI3CY7viI3bfK4T4GIs3jdP1+B9dn1IStpej36Cea
|
|
59
|
+
1afwp9ga8PH9Stgwxr3ON4k/7qABTG2o1mpNOQXj9HDgygs8pC4wzTKnC3z9L4Yc5YT15DYjZuzW
|
|
60
|
+
nSxAPUsFi2uQ7W3ruCRPdQKBgGslsCiyb+UBpEmFa3L2o3BCRl1hrUmwKLcszsY5oFHFmCD0lk5E
|
|
61
|
+
ucds6/QjNUoiu+Bj+CC1zgLRL0ubxdwd848YtJQVM+hfZPwseL++naIRBzpqJMnlAcMrW9CPNqaH
|
|
62
|
+
at/cZ/ZuvtbiRPzCI7XL8a8ZugSDFJtC2xYkstSKI2NDAoGAIiwUwKRMJyB9IRXhMfpf6vsEza2t
|
|
63
|
+
urHVUdJUyIwvPJSh2PfkumwrPuk+P+8v6jJjJ0hsqOS+TLQwWclIGwGey/PMNRYqQDqnSUofNmza
|
|
64
|
+
XtGGfWTOD3AdDEH39RTd3Zmfirrjm1YsY/Nb54X+V5TN2uvm/yJBIbb4aLvfG74Jmoc=
|
|
65
|
+
-----END RSA PRIVATE KEY-----}
|
|
66
|
+
}.each do |key, value|
|
|
67
|
+
it "should have the correct #{key}" do
|
|
68
|
+
key_pair.send(key).should == value
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::PurchaseReservedInstancesOfferingParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::PurchaseReservedInstancesOfferingParser.new(ec2) }
|
|
8
|
+
let(:result) { parser.parse(fixture('ec2/purchase_reserved_instances_offering')) }
|
|
9
|
+
|
|
10
|
+
it "should return an array of reserved instance ids" do
|
|
11
|
+
result.first.should == '1ba8e2e3-e6f7-4ef5-8c6c-6c6e4fad0a56'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::RegionParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::RegionParser.new(ec2) }
|
|
8
|
+
let(:result) { parser.parse(fixture('ec2/regions')) }
|
|
9
|
+
|
|
10
|
+
it "should return an array of regions" do
|
|
11
|
+
result.should be_a(Array)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "the first region" do
|
|
15
|
+
let(:region) { result.first }
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
:name => 'eu-west-1',
|
|
19
|
+
:end_point => 'eu-west-1.ec2.amazonaws.com'
|
|
20
|
+
}.each do |key, value|
|
|
21
|
+
it "should have the correct #{key}" do
|
|
22
|
+
region.send(key).should == value
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::RegisterImageParser do
|
|
5
|
+
|
|
6
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
7
|
+
let(:ec2) { subject }
|
|
8
|
+
let(:parser) { Awsum::Ec2::RegisterImageParser.new(ec2) }
|
|
9
|
+
let(:result) { parser.parse(fixture('ec2/register_image')) }
|
|
10
|
+
|
|
11
|
+
it "should return an image id" do
|
|
12
|
+
result.should == 'ami-4782652e'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::ReservedInstanceParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::ReservedInstanceParser.new(ec2) }
|
|
8
|
+
let(:result) { parser.parse(fixture('ec2/reserved_instances')) }
|
|
9
|
+
|
|
10
|
+
it "should return an array of reserved instances" do
|
|
11
|
+
result.should be_a(Array)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "the first reserved instance" do
|
|
15
|
+
let(:reserved_instance) { result.first }
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
:id => '1ba8e2e3-e6f7-4ef5-8c6c-6c6e4fad0a56',
|
|
19
|
+
:instance_type => 'm1.large',
|
|
20
|
+
:availability_zone => 'us-east-1a',
|
|
21
|
+
:start => Time.parse('2009-03-17T09:57:20.668Z'),
|
|
22
|
+
:duration => 31536000,
|
|
23
|
+
:fixed_price => 0.12,
|
|
24
|
+
:usage_price => 1300.0,
|
|
25
|
+
:instance_count => 1,
|
|
26
|
+
:product_description => 'Linux/UNIX',
|
|
27
|
+
:state => 'payment-pending'
|
|
28
|
+
}.each do |key, value|
|
|
29
|
+
it "should have the correct #{key}" do
|
|
30
|
+
reserved_instance.send(key).should == value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::ReservedInstancesOfferingParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::ReservedInstancesOfferingParser.new(ec2) }
|
|
8
|
+
let(:result) { parser.parse(fixture('ec2/reserved_instances_offerings')) }
|
|
9
|
+
|
|
10
|
+
it "should return an array of reserved instances offerings" do
|
|
11
|
+
result.should be_a(Array)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "the first offering" do
|
|
15
|
+
let(:offering) { result.first }
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
:id => 'e5a2ff3b-f6eb-4b4e-83f8-b879d7060257',
|
|
19
|
+
:instance_type => 'c1.medium',
|
|
20
|
+
:availability_zone => 'us-east-1b',
|
|
21
|
+
:duration => 94608000,
|
|
22
|
+
:fixed_price => 1000.0,
|
|
23
|
+
:usage_price => 0.06,
|
|
24
|
+
:product_description => 'Linux/UNIX'
|
|
25
|
+
}.each do |key, value|
|
|
26
|
+
it "should have the correct #{key}" do
|
|
27
|
+
offering.send(key).should == value
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::SecurityGroupParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::SecurityGroupParser.new(ec2) }
|
|
8
|
+
|
|
9
|
+
describe "parsing the result of a call to DescribeSecurityGroups" do
|
|
10
|
+
let(:result) { parser.parse(fixture('ec2/security_groups')) }
|
|
11
|
+
|
|
12
|
+
it "should return an array of security groups" do
|
|
13
|
+
result.should be_a(Array)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "the first security group" do
|
|
17
|
+
let(:security_group) { result.first }
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
:name => 'default',
|
|
21
|
+
:description => 'default group',
|
|
22
|
+
:owner_id => '111111111111'
|
|
23
|
+
}.each do |key, value|
|
|
24
|
+
it "should have the correct #{key}" do
|
|
25
|
+
security_group.send(key).should == value
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should have 3 group permissions" do
|
|
30
|
+
security_group.should have(3).group_permissions
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should have SecurityGroup::GroupPermission in the group_permissions array" do
|
|
34
|
+
security_group.group_permissions.first.should be_a(Awsum::Ec2::SecurityGroup::GroupPermission)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should have 4 ip permissions" do
|
|
38
|
+
security_group.should have(4).ip_permissions
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should have SecurityGroup::IpPermission in the ip_permissions array" do
|
|
42
|
+
security_group.ip_permissions.first.should be_a(Awsum::Ec2::SecurityGroup::IpPermission)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "in the first group permission" do
|
|
46
|
+
let(:group_permission) { security_group.group_permissions.first }
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
:protocol => 'tcp',
|
|
50
|
+
:from_port => 0,
|
|
51
|
+
:to_port => 65535,
|
|
52
|
+
:group => 'default',
|
|
53
|
+
:user_id => '111111111111'
|
|
54
|
+
}.each do |key, value|
|
|
55
|
+
it "should have the correct #{key}" do
|
|
56
|
+
group_permission.send(key).should == value
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context "in the first ip permission" do
|
|
62
|
+
let(:ip_permission) { security_group.ip_permissions.first }
|
|
63
|
+
|
|
64
|
+
{
|
|
65
|
+
:protocol => 'tcp',
|
|
66
|
+
:from_port => 22,
|
|
67
|
+
:to_port => 22,
|
|
68
|
+
:ip => '0.0.0.0/0'
|
|
69
|
+
}.each do |key, value|
|
|
70
|
+
it "should have the correct #{key}" do
|
|
71
|
+
ip_permission.send(key).should == value
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::SnapshotParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::SnapshotParser.new(ec2) }
|
|
8
|
+
let(:result) { parser.parse(fixture('ec2/snapshots')) }
|
|
9
|
+
|
|
10
|
+
it "should return an array of snapshot" do
|
|
11
|
+
result.should be_a(Array)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "the first snapshot" do
|
|
15
|
+
let(:snapshot) { result.first }
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
:id => 'snap-747c911d',
|
|
19
|
+
:volume_id => 'vol-44d6322d',
|
|
20
|
+
:status => 'completed',
|
|
21
|
+
:start_time => Time.parse('2009-01-15T03:59:26.000Z'),
|
|
22
|
+
:progress => '100%'
|
|
23
|
+
}.each do |key, value|
|
|
24
|
+
it "should have the correct #{key}" do
|
|
25
|
+
snapshot.send(key).should == value
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::VolumeParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::VolumeParser.new(ec2) }
|
|
8
|
+
let(:result) { parser.parse(fixture('ec2/volumes')) }
|
|
9
|
+
|
|
10
|
+
it "should return an array of volumes" do
|
|
11
|
+
result.should be_a(Array)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "the first volume" do
|
|
15
|
+
let(:volume) { result.first }
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
:id => 'vol-44d6322d',
|
|
19
|
+
:size => 10,
|
|
20
|
+
:snapshot_id => nil,
|
|
21
|
+
:availability_zone => 'us-east-1b',
|
|
22
|
+
:status => 'in-use',
|
|
23
|
+
:create_time => Time.parse('2009-01-14T03:57:08.000Z'),
|
|
24
|
+
:instance_id => 'i-3f1cc856',
|
|
25
|
+
:device => '/dev/sdb',
|
|
26
|
+
:attachment_status => 'attached',
|
|
27
|
+
:attach_time => Time.parse('2009-01-14T04:34:35.000Z')
|
|
28
|
+
}.each do |key, value|
|
|
29
|
+
it "should have the correct #{key}" do
|
|
30
|
+
volume.send(key).should == value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2 do
|
|
5
|
+
|
|
6
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
7
|
+
let(:ec2) { subject }
|
|
8
|
+
|
|
9
|
+
describe "retrieving a list of regions" do
|
|
10
|
+
before do
|
|
11
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeRegions|, :body => fixture('ec2/regions'), :status => 200)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:result) { ec2.regions }
|
|
15
|
+
|
|
16
|
+
it "should return an array of regions" do
|
|
17
|
+
result.first.should be_a(Awsum::Ec2::Region)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "retrieving a single region" do
|
|
22
|
+
before do
|
|
23
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeRegions.*RegionName.1=eu-west-1|, :body => fixture('ec2/regions'), :status => 200)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
let(:result) { ec2.region 'eu-west-1' }
|
|
27
|
+
|
|
28
|
+
it "should return a region" do
|
|
29
|
+
result.should be_a(Awsum::Ec2::Region)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "a region" do
|
|
34
|
+
before do
|
|
35
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeRegions.*RegionName.1=eu-west-1|, :body => fixture('ec2/regions'), :status => 200)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
let(:region) { ec2.region 'eu-west-1'}
|
|
39
|
+
|
|
40
|
+
it "should be able to list it's availability zones" do
|
|
41
|
+
FakeWeb.register_uri(:get, %r|https://eu-west-1\.ec2\.amazonaws\.com/?.*Action=DescribeAvailabilityZones|, :body => fixture('ec2/availability_zones'), :status => 200)
|
|
42
|
+
|
|
43
|
+
region.availability_zones.first.should be_a(Awsum::Ec2::AvailabilityZone)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should work in block mode (with a supplied parameter)" do
|
|
47
|
+
FakeWeb.register_uri(:get, %r|https://eu-west-1\.ec2\.amazonaws\.com/?.*Action=DescribeAvailabilityZones|, :body => fixture('ec2/availability_zones'), :status => 200)
|
|
48
|
+
|
|
49
|
+
zones = ec2.region('eu-west-1') do |region|
|
|
50
|
+
region.availability_zones
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
zones.first.should be_a(Awsum::Ec2::AvailabilityZone)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should work in block mode (without a supplied parameter)" do
|
|
57
|
+
FakeWeb.register_uri(:get, %r|https://eu-west-1\.ec2\.amazonaws\.com/?.*Action=DescribeAvailabilityZones|, :body => fixture('ec2/availability_zones'), :status => 200)
|
|
58
|
+
|
|
59
|
+
zones = ec2.region('eu-west-1') do
|
|
60
|
+
availability_zones
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
zones.first.should be_a(Awsum::Ec2::AvailabilityZone)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should receive ec2 methods (pass-through)" do
|
|
67
|
+
FakeWeb.register_uri(:get, %r|https://eu-west-1\.ec2\.amazonaws\.com/?.*Action=RunInstances.*ImageId=9-123456789|, :body => fixture('ec2/run_instances'), :status => 200)
|
|
68
|
+
|
|
69
|
+
region.run_instances('9-123456789').should be_true
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2 do
|
|
5
|
+
|
|
6
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
7
|
+
let(:ec2) { subject }
|
|
8
|
+
|
|
9
|
+
describe "purchasing a reserved instance" do
|
|
10
|
+
before do
|
|
11
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=PurchaseReservedInstancesOffering.*InstanceCount.1=1.*ReservedInstancesOfferingId.1=e5a2ff3b-f6eb-4b4e-83f8-b879d7060257|, :body => fixture('ec2/purchase_reserved_instances_offering'), :status => 200)
|
|
12
|
+
|
|
13
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeReservedInstances.*ReservedInstanceId.1=1ba8e2e3-e6f7-4ef5-8c6c-6c6e4fad0a56|, :body => fixture('ec2/reserved_instances'), :status => 200)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:result) { ec2.purchase_reserved_instances_offering 'e5a2ff3b-f6eb-4b4e-83f8-b879d7060257' }
|
|
17
|
+
|
|
18
|
+
it "should return a reserverd instance" do
|
|
19
|
+
result.should be_a(Awsum::Ec2::ReservedInstance)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "purchasing multiple reserved instances" do
|
|
24
|
+
before do
|
|
25
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=PurchaseReservedInstancesOffering.*InstanceCount.1=1.*InstanceCount.2=2.*ReservedInstancesOfferingId.1=e5a2ff3b-f6eb-4b4e-83f8-b879d7060257.*ReservedInstancesOfferingId.2=248e7b75-afbc-4724-82b2-d78353299433|, :body => fixture('ec2/purchase_reserved_instances_offering'), :status => 200)
|
|
26
|
+
|
|
27
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeReservedInstances.*ReservedInstanceId.1=1ba8e2e3-e6f7-4ef5-8c6c-6c6e4fad0a56|, :body => fixture('ec2/reserved_instances'), :status => 200)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
let(:result) { ec2.purchase_reserved_instances_offering ['e5a2ff3b-f6eb-4b4e-83f8-b879d7060257', '248e7b75-afbc-4724-82b2-d78353299433'], [1, 2] }
|
|
31
|
+
|
|
32
|
+
it "should return an array of reserverd instances" do
|
|
33
|
+
result.first.should be_a(Awsum::Ec2::ReservedInstance)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "retrieving a list of reserved instances" do
|
|
38
|
+
before do
|
|
39
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeReservedInstances|, :body => fixture('ec2/reserved_instances'), :status => 200)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
let(:result) { ec2.reserved_instances }
|
|
43
|
+
|
|
44
|
+
it "should return an array of reserverd instances" do
|
|
45
|
+
result.first.should be_a(Awsum::Ec2::ReservedInstance)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "retrieving a single reserved instance" do
|
|
50
|
+
before do
|
|
51
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeReservedInstances.*ReservedInstanceId.1=1ba8e2e3-e6f7-4ef5-8c6c-6c6e4fad0a56|, :body => fixture('ec2/reserved_instances'), :status => 200)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
let(:result) { ec2.reserved_instance '1ba8e2e3-e6f7-4ef5-8c6c-6c6e4fad0a56' }
|
|
55
|
+
|
|
56
|
+
it "should return a reserverd instance" do
|
|
57
|
+
result.should be_a(Awsum::Ec2::ReservedInstance)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|