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,21 @@
|
|
|
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 availability zones" do
|
|
10
|
+
before do
|
|
11
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeAvailabilityZones|, :body => fixture('ec2/availability_zones'), :status => 200)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:result) { ec2.availability_zones }
|
|
15
|
+
|
|
16
|
+
it "should return an array of availability zones" do
|
|
17
|
+
result.first.should be_a(Awsum::Ec2::AvailabilityZone)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
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 images" do
|
|
10
|
+
before do
|
|
11
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeImages|, :body => fixture('ec2/images'), :status => 200)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:result) { ec2.images }
|
|
15
|
+
|
|
16
|
+
it "should return an array of images" do
|
|
17
|
+
result.first.should be_a(Awsum::Ec2::Image)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "retrieving a list of owned images" do
|
|
22
|
+
before do
|
|
23
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeImages.*Owner.1=self|, :body => fixture('ec2/images'), :status => 200)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
let(:result) { ec2.my_images }
|
|
27
|
+
|
|
28
|
+
it "should return an array of images" do
|
|
29
|
+
result.first.should be_a(Awsum::Ec2::Image)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "retrieving an image by id" do
|
|
34
|
+
before do
|
|
35
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeImages.*ImageId.1=ari-f9c22690|, :body => fixture('ec2/image'), :status => 200)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
let(:result) { ec2.image('ari-f9c22690') }
|
|
39
|
+
|
|
40
|
+
it "should return the image" do
|
|
41
|
+
result.should be_a(Awsum::Ec2::Image)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "registering an image" do
|
|
46
|
+
before do
|
|
47
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=RegisterImage.*ImageLocation=s3.bucket.location|, :body => fixture('ec2/register_image'), :status => 200)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should be able to create an image" do
|
|
51
|
+
image_id = ec2.register_image('s3.bucket.location')
|
|
52
|
+
|
|
53
|
+
image_id.should == 'ami-4782652e'
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "deregistering an image" do
|
|
58
|
+
before do
|
|
59
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DeregisterImage.*ImageId=ami-4782652e|, :body => fixture('ec2/deregister_image'), :status => 200)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should return true" do
|
|
63
|
+
ec2.deregister_image('ami-4782652e').should be_true
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "an image" do
|
|
68
|
+
before do
|
|
69
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeImages.*ImageId.1=ari-f9c22690|, :body => fixture('ec2/image'), :status => 200)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
let(:image) { ec2.image('ari-f9c22690') }
|
|
73
|
+
|
|
74
|
+
it "should be able to create an image" do
|
|
75
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=RunInstances.*ImageId=ari-f9c22690|, :body => fixture('ec2/instance'), :status => 200)
|
|
76
|
+
result = image.run
|
|
77
|
+
result.first.should be_a(Awsum::Ec2::Instance)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should be able to deregister itself" do
|
|
81
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DeregisterImage.*ImageId=ari-f9c22690|, :body => fixture('ec2/deregister_image'), :status => 200)
|
|
82
|
+
image.deregister.should be_true
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should be able reregister itself" do
|
|
86
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DeregisterImage.*ImageId=ari-f9c22690|, :body => fixture('ec2/deregister_image'), :status => 200)
|
|
87
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=RegisterImage.*ImageLocation=s3.bucket.location|, :body => fixture('ec2/register_image'), :status => 200)
|
|
88
|
+
image.reregister.should be_true
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
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 "running an instance" do
|
|
10
|
+
before do
|
|
11
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=RunInstances.*ImageId=ari-f9c22690|, :body => fixture('ec2/run_instances'), :status => 200)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:result) { ec2.run_instances 'ari-f9c22690' }
|
|
15
|
+
|
|
16
|
+
it "should return an array of instances" do
|
|
17
|
+
result.first.should be_a(Awsum::Ec2::Instance)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "retrieving a list of instances" do
|
|
22
|
+
before do
|
|
23
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeInstances|, :body => fixture('ec2/run_instances'), :status => 200)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
let(:result) { ec2.instances }
|
|
27
|
+
|
|
28
|
+
it "should return an array of instances" do
|
|
29
|
+
result.first.should be_a(Awsum::Ec2::Instance)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "retrieving a single instance" do
|
|
34
|
+
before do
|
|
35
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeInstances.*InstanceId.1=i-3f1cc856|, :body => fixture('ec2/instance'), :status => 200)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
let(:result) { ec2.instance 'i-3f1cc856' }
|
|
39
|
+
|
|
40
|
+
it "should return an instance" do
|
|
41
|
+
result.should be_a(Awsum::Ec2::Instance)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "terminating an instance" do
|
|
46
|
+
before do
|
|
47
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=TerminateInstances.*InstanceId.1=i-3f1cc856|, :body => fixture('ec2/terminate_instances'), :status => 200)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should return an instance" do
|
|
51
|
+
ec2.terminate_instances('i-3f1cc856').should be_true
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "an instance" do
|
|
56
|
+
before do
|
|
57
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeInstances.*InstanceId.1=i-3f1cc856|, :body => fixture('ec2/instance'), :status => 200)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
let(:instance) { ec2.instance 'i-3f1cc856' }
|
|
61
|
+
|
|
62
|
+
it "should be able to terminate" do
|
|
63
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=TerminateInstances.*InstanceId.1=i-3f1cc856|, :body => fixture('ec2/terminate_instances'), :status => 200)
|
|
64
|
+
|
|
65
|
+
instance.terminate.should be_true
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should be able to list it's volumes" do
|
|
69
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeVolumes|, :body => fixture('ec2/volumes'), :status => 200)
|
|
70
|
+
|
|
71
|
+
volumes = instance.volumes
|
|
72
|
+
volumes.first.should be_a(Awsum::Ec2::Volume)
|
|
73
|
+
volumes.first.instance_id.should == instance.id
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should be able to attach a volume" do
|
|
77
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeVolumes|, :body => fixture('ec2/volumes'), :status => 200)
|
|
78
|
+
|
|
79
|
+
volume = ec2.volumes.last
|
|
80
|
+
|
|
81
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=AttachVolume.*InstanceId=i-3f1cc856.*VolumeId=vol-44d6322d|, :body => fixture('ec2/attach_volume'), :status => 200)
|
|
82
|
+
|
|
83
|
+
instance.attach(volume).should be_true
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should be able to create a volume" do
|
|
87
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=CreateVolume|, :body => fixture('ec2/create_volume'), :status => 200)
|
|
88
|
+
|
|
89
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeVolumes.*VolumeId.1=vol-44d6322d|, :body => fixture('ec2/available_volume'), :status => 200)
|
|
90
|
+
|
|
91
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=AttachVolume.*InstanceId=i-3f1cc856.*VolumeId=vol-44d6322d|, :body => fixture('ec2/attach_volume'), :status => 200)
|
|
92
|
+
|
|
93
|
+
instance.create_volume(10)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe "on a running instance" do
|
|
98
|
+
it "should be able to retrieve an instance of itself" do
|
|
99
|
+
FakeWeb.register_uri(:get, 'http://169.254.169.254/latest/meta-data/instance-id', :body => 'i-3f1cc856', :status => 200)
|
|
100
|
+
|
|
101
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeInstances.*InstanceId.1=i-3f1cc856|, :body => fixture('ec2/instance'), :status => 200)
|
|
102
|
+
|
|
103
|
+
ec2.me.should be_a(Awsum::Ec2::Instance)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should return nil if not a running instance" do
|
|
107
|
+
FakeWeb.register_uri(:get, 'http://169.254.169.254/latest/meta-data/instance-id', :body => '', :status => 404)
|
|
108
|
+
|
|
109
|
+
ec2.me.should be_nil
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should be able to retrieve the user data" do
|
|
113
|
+
FakeWeb.register_uri(:get, 'http://169.254.169.254/latest/user-data', :body => 'This is the user data', :status => 200)
|
|
114
|
+
|
|
115
|
+
ec2.user_data.should == 'This is the user data'
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should return nil if there's no user data" do
|
|
119
|
+
FakeWeb.register_uri(:get, 'http://169.254.169.254/latest/user-data', :body => '', :status => 404)
|
|
120
|
+
|
|
121
|
+
ec2.user_data.should be_nil
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
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 key pairs" do
|
|
10
|
+
before do
|
|
11
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeKeyPairs|, :body => fixture('ec2/key_pairs'), :status => 200)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:result) { ec2.key_pairs }
|
|
15
|
+
|
|
16
|
+
it "should return an array of key pairs" do
|
|
17
|
+
result.first.should be_a(Awsum::Ec2::KeyPair)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "retrieving a single key pair by name" do
|
|
22
|
+
before do
|
|
23
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DescribeKeyPairs.*KeyName.1=gsg_keypair|, :body => fixture('ec2/key_pairs'), :status => 200)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
let(:result) { ec2.key_pair 'gsg_keypair' }
|
|
27
|
+
|
|
28
|
+
it "should return a key pair" do
|
|
29
|
+
result.should be_a(Awsum::Ec2::KeyPair)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "creating a key pair" do
|
|
34
|
+
before do
|
|
35
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=CreateKeyPair.*KeyName=test-keypair|, :body => fixture('ec2/key_pairs'), :status => 200)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
let(:result) { ec2.create_key_pair('test-keypair') }
|
|
39
|
+
|
|
40
|
+
it "should return a key pair" do
|
|
41
|
+
result.should be_a(Awsum::Ec2::KeyPair)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "deleting a key pair" do
|
|
46
|
+
before do
|
|
47
|
+
FakeWeb.register_uri(:get, %r|https://ec2\.amazonaws\.com/?.*Action=DeleteKeyPair.*KeyName=test-keypair|, :body => fixture('ec2/key_pairs'), :status => 200)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should return a key pair" do
|
|
51
|
+
ec2.delete_key_pair('test-keypair').should be_true
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::AddressParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::AddressParser.new(ec2) }
|
|
8
|
+
|
|
9
|
+
describe "parsing the result of a call to DescribeAddresses" do
|
|
10
|
+
let(:result) { parser.parse(fixture('ec2/addresses')) }
|
|
11
|
+
|
|
12
|
+
it "should return an array of addresses" do
|
|
13
|
+
result.should be_a(Array)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "the first address" do
|
|
17
|
+
let(:address) { result.first }
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
:public_ip => '127.0.0.1',
|
|
21
|
+
:instance_id => 'i-3f1cc856'
|
|
22
|
+
}.each do |key, value|
|
|
23
|
+
it "should have the correct #{key}" do
|
|
24
|
+
address.send(key).should == value
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "parsing the result of a call to AllocateAddress" do
|
|
31
|
+
let(:result) { parser.parse(fixture('ec2/allocate_address')) }
|
|
32
|
+
|
|
33
|
+
it "should return an array of addresses" do
|
|
34
|
+
result.should be_a(Array)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context "the address" do
|
|
38
|
+
let(:address) { result.first }
|
|
39
|
+
|
|
40
|
+
{
|
|
41
|
+
:public_ip => '127.0.0.1',
|
|
42
|
+
:instance_id => nil
|
|
43
|
+
}.each do |key, value|
|
|
44
|
+
it "should have the correct #{key}" do
|
|
45
|
+
address.send(key).should == value
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::AvailabilityZoneParser do
|
|
5
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
6
|
+
let(:ec2) { subject }
|
|
7
|
+
let(:parser) { Awsum::Ec2::AvailabilityZoneParser.new(ec2) }
|
|
8
|
+
let(:result) { parser.parse(fixture('ec2/availability_zones')) }
|
|
9
|
+
|
|
10
|
+
it "should return an array of availability zones" do
|
|
11
|
+
result.should be_a(Array)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "the first availability zone" do
|
|
15
|
+
let(:availability_zone) { result.first }
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
:name => 'eu-west-1a',
|
|
19
|
+
:state => 'available',
|
|
20
|
+
:region_name => 'eu-west-1'
|
|
21
|
+
}.each do |key, value|
|
|
22
|
+
it "should have the correct #{key}" do
|
|
23
|
+
availability_zone.send(key).should == value
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::ImageParser do
|
|
5
|
+
|
|
6
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
7
|
+
let(:ec2) { subject }
|
|
8
|
+
let(:parser) { Awsum::Ec2::ImageParser.new(ec2) }
|
|
9
|
+
let(:result) { parser.parse(fixture('ec2/images')) }
|
|
10
|
+
|
|
11
|
+
it "should return an array of images" do
|
|
12
|
+
result.should be_a(Array)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "the first image" do
|
|
16
|
+
let(:image) { result.first }
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
:id => 'aki-0d9f7b64',
|
|
20
|
+
:location => 'oracle_linux_kernels/2.6.18-53.1.13.9.1.el5xen/vmlinuz-2.6.18-53.1.13.9.1.el5xen.manifest.xml',
|
|
21
|
+
:state => 'available',
|
|
22
|
+
:owner => '725966715235',
|
|
23
|
+
:architecture => 'x86_64',
|
|
24
|
+
:type => 'kernel'
|
|
25
|
+
}.each do |key, value|
|
|
26
|
+
it "should have the correct #{key}" do
|
|
27
|
+
image.send(key).should == value
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should be marked as public" do
|
|
32
|
+
image.should be_public
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "the second image" do
|
|
37
|
+
let(:image) { result[1] }
|
|
38
|
+
|
|
39
|
+
it "should have the correct id" do
|
|
40
|
+
image.id.should == 'aki-25de3b4c'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should have an array of product codes" do
|
|
44
|
+
image.product_codes.should be_a(Array)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should have the correct product codes" do
|
|
48
|
+
image.product_codes.first.should == '54DBF944'
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "the third image" do
|
|
53
|
+
let(:image) { result[2] }
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
:id => 'ami-005db969',
|
|
57
|
+
:kernel_id => 'aki-b51cf9dc',
|
|
58
|
+
:ramdisk_id => 'ari-b31cf9da'
|
|
59
|
+
}.each do |key, value|
|
|
60
|
+
it "should have the correct #{key}" do
|
|
61
|
+
image.send(key).should == value
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Awsum
|
|
4
|
+
describe Ec2::InstanceParser do
|
|
5
|
+
|
|
6
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
7
|
+
let(:ec2) { subject }
|
|
8
|
+
let(:parser) { Awsum::Ec2::InstanceParser.new(ec2) }
|
|
9
|
+
let(:result) { parser.parse(fixture('ec2/instances')) }
|
|
10
|
+
|
|
11
|
+
it "should return an array of instances" do
|
|
12
|
+
result.should be_a(Array)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "the first instance" do
|
|
16
|
+
let(:instance) { result.first }
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
:id => 'i-3f1cc856',
|
|
20
|
+
:private_dns_name => 'ip-10-255-255-255.ec2.internal',
|
|
21
|
+
:dns_name => 'ec2-75-255-255-255.compute-1.amazonaws.com',
|
|
22
|
+
:key_name => 'gsg-keypair',
|
|
23
|
+
:launch_index => 0,
|
|
24
|
+
:type => 'm1.small',
|
|
25
|
+
:availability_zone => 'us-east-1b',
|
|
26
|
+
:launch_time => Time.parse('2008-06-18T12:51:52.000Z'),
|
|
27
|
+
:state => {:code => 0, :name => 'pending'}
|
|
28
|
+
}.each do |key, value|
|
|
29
|
+
it "should have the correct #{key}" do
|
|
30
|
+
instance.send(key).should == value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context "the second instance" do
|
|
36
|
+
let(:instance) { result[1] }
|
|
37
|
+
|
|
38
|
+
it "should have the correct state" do
|
|
39
|
+
instance.state.should == {:code => 16, :name => 'running'}
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "Ec2::InstanceParser with the result of RunInstances" do
|
|
45
|
+
|
|
46
|
+
subject { Ec2.new('abc', 'xyz') }
|
|
47
|
+
let(:ec2) { subject }
|
|
48
|
+
let(:parser) { Awsum::Ec2::InstanceParser.new(ec2) }
|
|
49
|
+
let(:result) { parser.parse(fixture('ec2/run_instances')) }
|
|
50
|
+
|
|
51
|
+
it "should return an array of instances" do
|
|
52
|
+
result.should be_a(Array)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "the first instance" do
|
|
56
|
+
let(:instance) { result.first }
|
|
57
|
+
|
|
58
|
+
{
|
|
59
|
+
:id => 'i-f92fa890',
|
|
60
|
+
:private_dns_name => nil,
|
|
61
|
+
:dns_name => nil,
|
|
62
|
+
:key_name => nil,
|
|
63
|
+
:launch_index => 0,
|
|
64
|
+
:type => 'm1.small',
|
|
65
|
+
:availability_zone => 'us-east-1b',
|
|
66
|
+
:launch_time => Time.parse('2009-01-11T13:09:01.000Z'),
|
|
67
|
+
:state => {:code => 0, :name => 'pending'}
|
|
68
|
+
}.each do |key, value|
|
|
69
|
+
it "should have the correct #{key}" do
|
|
70
|
+
instance.send(key).should == value
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|