geemus-fog 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +94 -0
- data/VERSION +1 -0
- data/benchs/fog_vs.rb +76 -0
- data/benchs/headers_split_vs_match.rb +18 -0
- data/benchs/params.rb +43 -0
- data/benchs/parse_vs_push.rb +60 -0
- data/benchs/stripping.rb +26 -0
- data/lib/fog/aws/ec2.rb +159 -0
- data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
- data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
- data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
- data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
- data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
- data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
- data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
- data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
- data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
- data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
- data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
- data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
- data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
- data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
- data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
- data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
- data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
- data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
- data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/associate_address.rb +26 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +32 -0
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
- data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +28 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
- data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
- data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
- data/lib/fog/aws/requests/ec2/delete_snapshot.rb +24 -0
- data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +27 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +48 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +26 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +29 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +32 -0
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +24 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
- data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +74 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +31 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +80 -0
- data/lib/fog/aws/requests/s3/delete_bucket.rb +49 -0
- data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +92 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
- data/lib/fog/aws/requests/s3/get_object.rb +81 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
- data/lib/fog/aws/requests/s3/get_service.rb +58 -0
- data/lib/fog/aws/requests/s3/head_object.rb +61 -0
- data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
- data/lib/fog/aws/requests/s3/put_object.rb +75 -0
- data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
- data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
- data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
- data/lib/fog/aws/requests/simpledb/select.rb +29 -0
- data/lib/fog/aws/s3.rb +143 -0
- data/lib/fog/aws/simpledb.rb +157 -0
- data/lib/fog/aws.rb +127 -0
- data/lib/fog/connection.rb +122 -0
- data/lib/fog/errors.rb +131 -0
- data/lib/fog/parser.rb +30 -0
- data/lib/fog/response.rb +12 -0
- data/lib/fog.rb +22 -0
- data/spec/aws/ec2/allocate_address_spec.rb +20 -0
- data/spec/aws/ec2/associate_address_spec.rb +22 -0
- data/spec/aws/ec2/attach_volume_spec.rb +33 -0
- data/spec/aws/ec2/authorize_security_group_ingress_spec.rb +25 -0
- data/spec/aws/ec2/create_key_pair_spec.rb +27 -0
- data/spec/aws/ec2/create_security_group_spec.rb +25 -0
- data/spec/aws/ec2/create_snapshot_spec.rb +27 -0
- data/spec/aws/ec2/create_volume_spec.rb +25 -0
- data/spec/aws/ec2/delete_key_pair_spec.rb +20 -0
- data/spec/aws/ec2/delete_security_group_spec.rb +22 -0
- data/spec/aws/ec2/delete_snapshot_spec.rb +25 -0
- data/spec/aws/ec2/delete_volume_spec.rb +22 -0
- data/spec/aws/ec2/describe_addresses_spec.rb +34 -0
- data/spec/aws/ec2/describe_availability_zones_spec.rb +25 -0
- data/spec/aws/ec2/describe_images_spec.rb +41 -0
- data/spec/aws/ec2/describe_instances_spec.rb +76 -0
- data/spec/aws/ec2/describe_key_pairs_spec.rb +38 -0
- data/spec/aws/ec2/describe_regions_spec.rb +23 -0
- data/spec/aws/ec2/describe_security_groups_spec.rb +47 -0
- data/spec/aws/ec2/describe_snapshot_spec.rb +44 -0
- data/spec/aws/ec2/describe_volumes_spec.rb +46 -0
- data/spec/aws/ec2/detach_volume_spec.rb +33 -0
- data/spec/aws/ec2/disassociate_address_spec.rb +23 -0
- data/spec/aws/ec2/get_console_output_spec.rb +22 -0
- data/spec/aws/ec2/reboot_instances_spec.rb +20 -0
- data/spec/aws/ec2/release_address_spec.rb +22 -0
- data/spec/aws/ec2/revoke_security_group_ingress_spec.rb +31 -0
- data/spec/aws/ec2/run_instances_spec.rb +43 -0
- data/spec/aws/ec2/terminate_instances_spec.rb +25 -0
- data/spec/aws/s3/copy_object_spec.rb +57 -0
- data/spec/aws/s3/delete_bucket_spec.rb +21 -0
- data/spec/aws/s3/delete_object_spec.rb +31 -0
- data/spec/aws/s3/get_bucket_location_spec.rb +30 -0
- data/spec/aws/s3/get_bucket_spec.rb +42 -0
- data/spec/aws/s3/get_object_spec.rb +40 -0
- data/spec/aws/s3/get_request_payment_spec.rb +26 -0
- data/spec/aws/s3/get_service_spec.rb +32 -0
- data/spec/aws/s3/head_object_spec.rb +27 -0
- data/spec/aws/s3/put_bucket_spec.rb +22 -0
- data/spec/aws/s3/put_object_spec.rb +34 -0
- data/spec/aws/s3/put_request_payment_spec.rb +25 -0
- data/spec/aws/simpledb/batch_put_attributes_spec.rb +21 -0
- data/spec/aws/simpledb/create_domain_spec.rb +20 -0
- data/spec/aws/simpledb/delete_attributes_spec.rb +21 -0
- data/spec/aws/simpledb/delete_domain_spec.rb +20 -0
- data/spec/aws/simpledb/domain_metadata_spec.rb +42 -0
- data/spec/aws/simpledb/get_attributes_spec.rb +30 -0
- data/spec/aws/simpledb/list_domains_spec.rb +29 -0
- data/spec/aws/simpledb/put_attributes_spec.rb +21 -0
- data/spec/aws/simpledb/select_spec.rb +7 -0
- data/spec/lorem.txt +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +74 -0
- metadata +256 -0
data/lib/fog/parser.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'base64'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Fog
|
7
|
+
module Parsers
|
8
|
+
class Base < Nokogiri::XML::SAX::Document
|
9
|
+
|
10
|
+
attr_reader :response
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
reset
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset
|
17
|
+
@response = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def characters(string)
|
21
|
+
@value << string.strip
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_element(name, attrs = [])
|
25
|
+
@value = ''
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/fog/response.rb
ADDED
data/lib/fog.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fog
|
2
|
+
|
3
|
+
def self.mocking=(new_mocking)
|
4
|
+
old_mocking = @mocking
|
5
|
+
@mocking = new_mocking
|
6
|
+
unless old_mocking == new_mocking
|
7
|
+
self.reload
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.mocking?
|
12
|
+
!!@mocking
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.reload
|
16
|
+
load "#{File.dirname(__FILE__)}/fog/aws.rb"
|
17
|
+
Fog::AWS.reload
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
Fog.reload
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.allocate_address' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:all) do
|
10
|
+
@ec2.release_address(@public_ip)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return proper attributes" do
|
14
|
+
actual = @ec2.allocate_address
|
15
|
+
actual.body['requestId'].should be_a(String)
|
16
|
+
@public_ip = actual.body['publicIp']
|
17
|
+
actual.body['publicIp'].should be_a(String)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.associate_address' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
8
|
+
@public_ip = @ec2.allocate_address.body['publicIp']
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
@ec2.release_address(@public_ip)
|
13
|
+
@ec2.terminate_instances([@instance_id])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return proper attributes" do
|
17
|
+
actual = @ec2.associate_address(@instance_id, @public_ip)
|
18
|
+
actual.body['requestId'].should be_a(String)
|
19
|
+
[false, true].should include(actual.body['return'])
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.attach_volume' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@instance_id = @ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
8
|
+
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
eventually do
|
13
|
+
@ec2.detach_volume(@volume_id)
|
14
|
+
end
|
15
|
+
eventually do
|
16
|
+
@ec2.delete_volume(@volume_id)
|
17
|
+
@ec2.terminate_instances([@instance_id])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return proper attributes" do
|
22
|
+
eventually(128) do
|
23
|
+
actual = @ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
|
24
|
+
actual.body['attachTime'].should be_a(Time)
|
25
|
+
actual.body['device'].should be_a(String)
|
26
|
+
actual.body['instanceId'].should be_a(String)
|
27
|
+
actual.body['requestId'].should be_a(String)
|
28
|
+
actual.body['status'].should be_a(String)
|
29
|
+
actual.body['volumeId'].should be_a(String)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.authorize_security_group_ingress' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
@ec2.delete_security_group('fog_security_group')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes" do
|
15
|
+
actual = @ec2.authorize_security_group_ingress({
|
16
|
+
'FromPort' => 80,
|
17
|
+
'GroupName' => 'fog_security_group',
|
18
|
+
'IpProtocol' => 'tcp',
|
19
|
+
'ToPort' => 80,
|
20
|
+
})
|
21
|
+
actual.body['requestId'].should be_a(String)
|
22
|
+
[false, true].should include(actual.body['return'])
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.create_key_pair' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:all) do
|
10
|
+
@ec2.delete_key_pair('fog_key_pair')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return proper attributes" do
|
14
|
+
actual = @ec2.create_key_pair('fog_key_pair')
|
15
|
+
actual.body['keyFingerprint'].should be_a(String)
|
16
|
+
actual.body['keyMaterial'].should be_a(String)
|
17
|
+
actual.body['keyName'].should be_a(String)
|
18
|
+
actual.body['requestId'].should be_a(String)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should raise a BadRequest when the key pair already exists" do
|
22
|
+
lambda {
|
23
|
+
@ec2.create_key_pair('fog_key_pair')
|
24
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.create_security_group' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:all) do
|
10
|
+
@ec2.delete_security_group('fog_security_group')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return proper attributes" do
|
14
|
+
actual = @ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
15
|
+
actual.body['requestId'].should be_a(String)
|
16
|
+
[false, true].should include(actual.body['return'])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should raise a BadRequest error when the security group already exists" do
|
20
|
+
lambda {
|
21
|
+
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
22
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.create_snapshot' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
@ec2.delete_volume(@volume_id)
|
12
|
+
eventually do
|
13
|
+
@ec2.delete_snapshot(@snapshot_id)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return proper attributes" do
|
18
|
+
actual = @ec2.create_snapshot(@volume_id)
|
19
|
+
actual.body['progress'].should be_a(String)
|
20
|
+
@snapshot_id = actual.body['snapshotId']
|
21
|
+
actual.body['snapshotId'].should be_a(String)
|
22
|
+
actual.body['startTime'].should be_a(Time)
|
23
|
+
actual.body['status'].should be_a(String)
|
24
|
+
actual.body['volumeId'].should be_a(String)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.create_volume' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:all) do
|
10
|
+
@ec2.delete_volume(@volume_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return proper attributes" do
|
14
|
+
actual = @ec2.create_volume('us-east-1a', 1)
|
15
|
+
actual.body['availabilityZone'].should be_a(String)
|
16
|
+
actual.body['createTime'].should be_a(Time)
|
17
|
+
actual.body['requestId'].should be_a(String)
|
18
|
+
actual.body['size'].should == 1
|
19
|
+
actual.body['snapshotId'].should == ''
|
20
|
+
actual.body['status'].should be_a(String)
|
21
|
+
actual.body['volumeId'].should be_a(String)
|
22
|
+
@volume_id = actual.body['volumeId']
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.delete_key_pair' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@ec2.create_key_pair('fog_key_pair')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return proper attributes" do
|
11
|
+
actual = @ec2.delete_key_pair('fog_key_pair')
|
12
|
+
actual.body['requestId'].should be_a(String)
|
13
|
+
[false, true].should include(actual.body['return'])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not raise an error if the key pair does not exist" do
|
17
|
+
@ec2.delete_key_pair('not_a_key_pair')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.delete_security_group' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return proper attributes" do
|
11
|
+
actual = @ec2.delete_security_group('fog_security_group')
|
12
|
+
actual.body['requestId'].should be_a(String)
|
13
|
+
[false, true].should include(actual.body['return'])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should raise a BadRequest error if the security group does not exist" do
|
17
|
+
lambda {
|
18
|
+
@ec2.delete_security_group('fog_not_a_security_group')
|
19
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.delete_snapshot' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
8
|
+
@snapshot_id = @ec2.create_snapshot(@volume_id).body['snapshotId']
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
@ec2.delete_volume(@volume_id)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return proper attributes" do
|
16
|
+
eventually do
|
17
|
+
actual = @ec2.delete_snapshot(@snapshot_id)
|
18
|
+
unless actual.body.empty?
|
19
|
+
actual.body['requestId'].should be_a(String)
|
20
|
+
[false, true].should include(actual.body['return'])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.create_volume' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return proper attributes" do
|
11
|
+
actual = @ec2.delete_volume(@volume_id)
|
12
|
+
actual.body['requestId'].should be_a(String)
|
13
|
+
actual.body['return'].should == true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should raise a BadRequest error if volume does not exist" do
|
17
|
+
lambda {
|
18
|
+
@ec2.release_address('vol-00000000')
|
19
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_addresses' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@public_ip = @ec2.allocate_address.body['publicIp']
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
@ec2.release_address(@public_ip)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes with no params" do
|
15
|
+
actual = @ec2.describe_addresses
|
16
|
+
actual.body['requestId'].should be_a(String)
|
17
|
+
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
|
18
|
+
item.should_not be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return proper attributes for specific ip" do
|
22
|
+
actual = @ec2.describe_addresses(@public_ip)
|
23
|
+
actual.body['requestId'].should be_a(String)
|
24
|
+
item = actual.body['addressesSet'].select {|address| address['publicIp'] == @public_ip}
|
25
|
+
item.should_not be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should raise a BadRequest error if ip does not exist" do
|
29
|
+
lambda {
|
30
|
+
@ec2.describe_addresses('127.0.0.1')
|
31
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_availability_zones' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return proper attributes with no params" do
|
10
|
+
actual = @ec2.describe_availability_zones
|
11
|
+
zone = actual.body['availabilityZoneInfo'].first
|
12
|
+
zone['regionName'].should be_a(String)
|
13
|
+
zone['zoneName'].should be_a(String)
|
14
|
+
zone['zoneState'].should be_a(String)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return proper attribute with params" do
|
18
|
+
actual = @ec2.describe_availability_zones(['us-east-1a'])
|
19
|
+
zone = actual.body['availabilityZoneInfo'].first
|
20
|
+
zone['regionName'].should be_a(String)
|
21
|
+
zone['zoneName'].should be_a(String)
|
22
|
+
zone['zoneState'].should be_a(String)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_images' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return proper attributes with no params" do
|
10
|
+
actual = @ec2.describe_images
|
11
|
+
actual.body['requestId'].should be_a(String)
|
12
|
+
image = actual.body['imagesSet'].first
|
13
|
+
image['architecture'].should be_a(String)
|
14
|
+
image['imageId'].should be_a(String)
|
15
|
+
image['imageLocation'].should be_a(String)
|
16
|
+
image['imageOwnerId'].should be_a(String)
|
17
|
+
image['imageState'].should be_a(String)
|
18
|
+
image['imageType'].should be_a(String)
|
19
|
+
[false, true].should include(image['isPublic'])
|
20
|
+
image['kernelId'].should be_a(String) if image['kernelId']
|
21
|
+
image['platform'].should be_a(String) if image['platform']
|
22
|
+
image['ramdiskId'].should be_a(String) if image['ramdiskId']
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return proper attributes with params" do
|
26
|
+
actual = @ec2.describe_images('ImageId' => 'ami-5ee70037')
|
27
|
+
actual.body['requestId'].should be_a(String)
|
28
|
+
image = actual.body['imagesSet'].first
|
29
|
+
image['architecture'].should be_a(String)
|
30
|
+
image['imageId'].should be_a(String)
|
31
|
+
image['imageLocation'].should be_a(String)
|
32
|
+
image['imageOwnerId'].should be_a(String)
|
33
|
+
image['imageState'].should be_a(String)
|
34
|
+
image['imageType'].should be_a(String)
|
35
|
+
[false, true].should include(image['isPublic'])
|
36
|
+
image['kernelId'].should be_a(String) if image['kernelId']
|
37
|
+
image['platform'].should be_a(String) if image['platform']
|
38
|
+
image['ramdiskId'].should be_a(String) if image['ramdiskId']
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_instances' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
run_instances = @ec2.run_instances('ami-5ee70037', 1, 1).body
|
8
|
+
@instance_id = run_instances['instancesSet'].first['instanceId']
|
9
|
+
@reservation_id = run_instances['reservationId']
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:all) do
|
13
|
+
@ec2.terminate_instances([@instance_id])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return proper attributes with no params" do
|
17
|
+
actual = @ec2.describe_instances
|
18
|
+
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
|
19
|
+
reservation['groupSet'].should be_an(Array)
|
20
|
+
reservation['groupSet'].first.should be_a(String)
|
21
|
+
reservation['ownerId'].should be_a(String)
|
22
|
+
reservation['reservationId'].should be_a(String)
|
23
|
+
instance = reservation['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
|
24
|
+
instance['amiLaunchIndex'].should be_an(Integer)
|
25
|
+
instance['dnsName'].should be_a(String)
|
26
|
+
instance['imageId'].should be_a(String)
|
27
|
+
instance['instanceId'].should be_a(String)
|
28
|
+
instance['instanceState'].should be_a(Hash)
|
29
|
+
instance['instanceState']['code'].should be_a(String)
|
30
|
+
instance['instanceState']['name'].should be_a(String)
|
31
|
+
instance['instanceType'].should be_a(String)
|
32
|
+
instance['kernelId'].should be_a(String)
|
33
|
+
instance['keyName'].should be_a(String) if instance['keyName']
|
34
|
+
instance['launchTime'].should be_a(Time)
|
35
|
+
instance['monitoring'].should be_a(Hash)
|
36
|
+
[true, false].should include(instance['monitoring']['state'])
|
37
|
+
instance['placement'].should be_an(Array)
|
38
|
+
instance['placement'].first.should be_a(String)
|
39
|
+
instance['privateDnsName'].should be_a(String)
|
40
|
+
instance['productCodes'].should be_an(Array)
|
41
|
+
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
|
42
|
+
instance['ramdiskId'].should be_a(String)
|
43
|
+
instance['reason'].should be_a(String)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return proper attributes with params" do
|
47
|
+
actual = @ec2.describe_instances(@instance_id)
|
48
|
+
reservation = actual.body['reservationSet'].select {|reservation| reservation['reservationId'] == @reservation_id}.first
|
49
|
+
reservation['groupSet'].should be_an(Array)
|
50
|
+
reservation['groupSet'].first.should be_a(String)
|
51
|
+
reservation['ownerId'].should be_a(String)
|
52
|
+
reservation['reservationId'].should be_a(String)
|
53
|
+
instance = reservation['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
|
54
|
+
instance['amiLaunchIndex'].should be_an(Integer)
|
55
|
+
instance['dnsName'].should be_a(String)
|
56
|
+
instance['imageId'].should be_a(String)
|
57
|
+
instance['instanceId'].should be_a(String)
|
58
|
+
instance['instanceState'].should be_a(Hash)
|
59
|
+
instance['instanceState']['code'].should be_a(String)
|
60
|
+
instance['instanceState']['name'].should be_a(String)
|
61
|
+
instance['instanceType'].should be_a(String)
|
62
|
+
instance['kernelId'].should be_a(String)
|
63
|
+
instance['keyName'].should be_a(String) if instance['keyName']
|
64
|
+
instance['launchTime'].should be_a(Time)
|
65
|
+
instance['monitoring'].should be_a(Hash)
|
66
|
+
[true, false].should include(instance['monitoring']['state'])
|
67
|
+
instance['placement'].should be_an(Array)
|
68
|
+
instance['placement'].first.should be_a(String)
|
69
|
+
instance['privateDnsName'].should be_a(String)
|
70
|
+
instance['productCodes'].should be_an(Array)
|
71
|
+
instance['productCodes'].first.should be_a(String) if instance['productCodes'].first
|
72
|
+
instance['ramdiskId'].should be_a(String)
|
73
|
+
instance['reason'].should be_a(String)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_key_pairs' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@ec2.create_key_pair('key_name')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
@ec2.delete_key_pair('key_name')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes with no params" do
|
15
|
+
actual = @ec2.describe_key_pairs
|
16
|
+
actual.body['keySet'].should be_an(Array)
|
17
|
+
actual.body['requestId'].should be_a(String)
|
18
|
+
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'key_name' }.first
|
19
|
+
key_pair['keyFingerprint'].should be_a(String)
|
20
|
+
key_pair['keyName'].should be_a(String)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return proper attributes with params" do
|
24
|
+
actual = @ec2.describe_key_pairs('key_name')
|
25
|
+
actual.body['keySet'].should be_an(Array)
|
26
|
+
actual.body['requestId'].should be_a(String)
|
27
|
+
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'key_name' }.first
|
28
|
+
key_pair['keyFingerprint'].should be_a(String)
|
29
|
+
key_pair['keyName'].should be_a(String)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should raise a BadRequest error if the key does not exist" do
|
33
|
+
lambda {
|
34
|
+
@ec2.describe_key_pairs('not_a_key_name')
|
35
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_availability_zones' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return proper attributes with no params" do
|
10
|
+
actual = @ec2.describe_regions
|
11
|
+
zone = actual.body['regionInfo'].first
|
12
|
+
zone['regionEndpoint'].should be_a(String)
|
13
|
+
zone['regionName'].should be_a(String)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return proper attribute with params" do
|
17
|
+
actual = @ec2.describe_regions(['us-east-1'])
|
18
|
+
zone = actual.body['regionInfo'].first
|
19
|
+
zone['regionEndpoint'].should be_a(String)
|
20
|
+
zone['regionName'].should be_a(String)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_security_groups' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@ec2 = Fog::AWS::EC2.gen
|
7
|
+
@ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
@ec2.delete_security_group('fog_security_group')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes with no params" do
|
15
|
+
actual = @ec2.describe_security_groups
|
16
|
+
actual.body['requestId'].should be_a(String)
|
17
|
+
actual.body['securityGroupInfo'].should be_an(Array)
|
18
|
+
security_group = actual.body['securityGroupInfo'].select do |security_group|
|
19
|
+
security_group['groupName'] == 'default'
|
20
|
+
end.first
|
21
|
+
security_group['groupDescription'].should be_a(String)
|
22
|
+
security_group['groupName'].should be_a(String)
|
23
|
+
security_group['ownerId'].should be_a(String)
|
24
|
+
security_group['ipPermissions'].should be_an(Array)
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return proper attributes with params" do
|
29
|
+
actual = @ec2.describe_security_groups('fog_security_group')
|
30
|
+
actual.body['requestId'].should be_a(String)
|
31
|
+
actual.body['securityGroupInfo'].should be_an(Array)
|
32
|
+
security_group = actual.body['securityGroupInfo'].select do |security_group|
|
33
|
+
security_group['groupName'] == 'fog_security_group'
|
34
|
+
end.first
|
35
|
+
security_group['groupDescription'].should be_a(String)
|
36
|
+
security_group['groupName'].should be_a(String)
|
37
|
+
security_group['ownerId'].should be_a(String)
|
38
|
+
security_group['ipPermissions'].should be_an(Array)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should raise a BadRequest error if the security group does not exist" do
|
42
|
+
lambda {
|
43
|
+
@ec2.describe_security_groups('not_a_security_group')
|
44
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|