fog 0.0.9 → 0.0.10
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/README.rdoc +79 -2
- data/VERSION +1 -1
- data/fog.gemspec +28 -6
- data/lib/fog.rb +10 -7
- data/lib/fog/aws.rb +35 -9
- data/lib/fog/aws/ec2.rb +82 -69
- data/lib/fog/aws/models/ec2/address.rb +23 -1
- data/lib/fog/aws/models/ec2/addresses.rb +26 -2
- data/lib/fog/aws/models/ec2/instance.rb +135 -0
- data/lib/fog/aws/models/ec2/instances.rb +56 -0
- data/lib/fog/aws/models/ec2/key_pair.rb +17 -2
- data/lib/fog/aws/models/ec2/key_pairs.rb +29 -3
- data/lib/fog/aws/models/ec2/security_group.rb +41 -0
- data/lib/fog/aws/models/ec2/security_groups.rb +62 -0
- data/lib/fog/aws/models/ec2/snapshot.rb +12 -12
- data/lib/fog/aws/models/ec2/snapshots.rb +43 -21
- data/lib/fog/aws/models/ec2/volume.rb +21 -10
- data/lib/fog/aws/models/ec2/volumes.rb +30 -4
- data/lib/fog/aws/models/s3/buckets.rb +5 -8
- data/lib/fog/aws/models/s3/objects.rb +4 -7
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +63 -27
- data/lib/fog/aws/requests/ec2/create_security_group.rb +3 -3
- data/lib/fog/aws/requests/ec2/describe_images.rb +65 -35
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +52 -21
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +52 -19
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +63 -27
- data/lib/fog/aws/requests/ec2/run_instances.rb +1 -1
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +14 -10
- data/lib/fog/aws/s3.rb +31 -35
- data/lib/fog/aws/simpledb.rb +19 -22
- data/lib/fog/collection.rb +3 -3
- data/lib/fog/connection.rb +2 -2
- data/lib/fog/errors.rb +1 -1
- data/lib/fog/model.rb +3 -3
- data/spec/aws/models/ec2/address_spec.rb +84 -0
- data/spec/aws/models/ec2/addresses_spec.rb +70 -0
- data/spec/aws/models/ec2/key_pair_spec.rb +84 -0
- data/spec/aws/models/ec2/key_pairs_spec.rb +71 -0
- data/spec/aws/models/ec2/security_group_spec.rb +84 -0
- data/spec/aws/models/ec2/security_groups_spec.rb +71 -0
- data/spec/aws/models/ec2/snapshot_spec.rb +93 -0
- data/spec/aws/models/ec2/snapshots_spec.rb +74 -0
- data/spec/aws/models/ec2/volume_spec.rb +84 -0
- data/spec/aws/models/ec2/volumes_spec.rb +70 -0
- data/spec/aws/models/s3/bucket_spec.rb +0 -1
- data/spec/aws/models/s3/buckets_spec.rb +2 -11
- data/spec/aws/requests/ec2/describe_security_groups_spec.rb +1 -1
- data/spec/aws/requests/ec2/get_console_output_spec.rb +9 -0
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +11 -2
- data/spec/aws/requests/ec2/run_instances_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +26 -4
- data/LICENSE +0 -20
data/lib/fog/collection.rb
CHANGED
@@ -39,7 +39,7 @@ module Fog
|
|
39
39
|
def attributes
|
40
40
|
attributes = {}
|
41
41
|
for attribute in self.class.attributes
|
42
|
-
attributes[attribute] = send(
|
42
|
+
attributes[attribute] = send("#{attribute}")
|
43
43
|
end
|
44
44
|
attributes
|
45
45
|
end
|
@@ -47,9 +47,9 @@ module Fog
|
|
47
47
|
def merge_attributes(new_attributes = {})
|
48
48
|
for key, value in new_attributes
|
49
49
|
if aliased_key = self.class.aliases[key]
|
50
|
-
send(
|
50
|
+
send("#{aliased_key}=", value)
|
51
51
|
else
|
52
|
-
send(
|
52
|
+
send("#{key}=", value)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
self
|
data/lib/fog/connection.rb
CHANGED
data/lib/fog/errors.rb
CHANGED
data/lib/fog/model.rb
CHANGED
@@ -34,7 +34,7 @@ module Fog
|
|
34
34
|
def attributes
|
35
35
|
attributes = {}
|
36
36
|
for attribute in self.class.attributes
|
37
|
-
attributes[attribute] = send(
|
37
|
+
attributes[attribute] = send("#{attribute}")
|
38
38
|
end
|
39
39
|
attributes
|
40
40
|
end
|
@@ -42,9 +42,9 @@ module Fog
|
|
42
42
|
def merge_attributes(new_attributes = {})
|
43
43
|
for key, value in new_attributes
|
44
44
|
if aliased_key = self.class.aliases[key]
|
45
|
-
send(
|
45
|
+
send("#{aliased_key}=", value)
|
46
46
|
else
|
47
|
-
send(
|
47
|
+
send("#{key}=", value)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
self
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'Fog::AWS::EC2::Address' do
|
4
|
+
|
5
|
+
describe "#initialize" do
|
6
|
+
|
7
|
+
it "should remap attributes from parser" do
|
8
|
+
address = Fog::AWS::EC2::Address.new(
|
9
|
+
'instanceId' => 'i-00000000',
|
10
|
+
'publicIp' => '0.0.0.0'
|
11
|
+
)
|
12
|
+
address.instance_id.should == 'i-00000000'
|
13
|
+
address.public_ip.should == '0.0.0.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#addresses" do
|
19
|
+
|
20
|
+
it "should return a Fog::AWS::EC2::Addresses" do
|
21
|
+
ec2.addresses.new.addresses.should be_a(Fog::AWS::EC2::Addresses)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be the addresses the address is related to" do
|
25
|
+
addresses = ec2.addresses
|
26
|
+
addresses.new.addresses.should == addresses
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#destroy" do
|
32
|
+
|
33
|
+
it "should return true if the address is deleted" do
|
34
|
+
address = ec2.addresses.create
|
35
|
+
address.destroy.should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#reload" do
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
@address = ec2.addresses.create
|
44
|
+
@reloaded = @address.reload
|
45
|
+
end
|
46
|
+
|
47
|
+
after(:each) do
|
48
|
+
@address.destroy
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return a Fog::AWS::EC2::Address" do
|
52
|
+
@reloaded.should be_a(Fog::AWS::EC2::Address)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should reset attributes to remote state" do
|
56
|
+
@address.attributes.should == @reloaded.attributes
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#save" do
|
62
|
+
|
63
|
+
before(:each) do
|
64
|
+
@address = ec2.addresses.new
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return true when it succeeds" do
|
68
|
+
@address.save.should be_true
|
69
|
+
@address.destroy
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should not exist in addresses before save" do
|
73
|
+
@address.addresses.get(@address.public_ip).should be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should exist in buckets after save" do
|
77
|
+
@address.save
|
78
|
+
@address.addresses.get(@address.public_ip).should_not be_nil
|
79
|
+
@address.destroy
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'Fog::AWS::EC2::Addresses' do
|
4
|
+
|
5
|
+
describe "#all" do
|
6
|
+
|
7
|
+
it "should return a Fog::AWS::EC2::Addresses" do
|
8
|
+
ec2.addresses.all.should be_a(Fog::AWS::EC2::Addresses)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should include persisted addresses" do
|
12
|
+
address = ec2.addresses.create
|
13
|
+
ec2.addresses.get(address.public_ip).should_not be_nil
|
14
|
+
address.destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#create" do
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
@address = ec2.addresses.create
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:each) do
|
26
|
+
@address.destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return a Fog::AWS::EC2::Address" do
|
30
|
+
@address.should be_a(Fog::AWS::EC2::Address)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should exist on ec2" do
|
34
|
+
ec2.addresses.get(@address.public_ip).should_not be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#get" do
|
40
|
+
|
41
|
+
it "should return a Fog::AWS::EC2::Address if a matching address exists" do
|
42
|
+
address = ec2.addresses.create
|
43
|
+
get = ec2.addresses.get(address.public_ip)
|
44
|
+
address.attributes.should == get.attributes
|
45
|
+
address.destroy
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return nil if no matching address exists" do
|
49
|
+
ec2.addresses.get('0.0.0.0').should be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#new" do
|
55
|
+
|
56
|
+
it "should return a Fog::AWS::EC2::Address" do
|
57
|
+
ec2.addresses.new.should be_a(Fog::AWS::EC2::Address)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#reload" do
|
63
|
+
|
64
|
+
it "should return a Fog::AWS::EC2::Addresses" do
|
65
|
+
ec2.addresses.all.reload.should be_a(Fog::AWS::EC2::Addresses)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'Fog::AWS::EC2::KeyPair' do
|
4
|
+
|
5
|
+
describe "#initialize" do
|
6
|
+
|
7
|
+
it "should remap attributes from parser" #do
|
8
|
+
# address = Fog::AWS::EC2::KeyPair.new(
|
9
|
+
# 'instanceId' => 'i-00000000',
|
10
|
+
# 'publicIp' => '0.0.0.0'
|
11
|
+
# )
|
12
|
+
# address.instance_id.should == 'i-00000000'
|
13
|
+
# address.public_ip.should == '0.0.0.0'
|
14
|
+
# end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#key_pairs" do
|
19
|
+
|
20
|
+
it "should return a Fog::AWS::EC2::KeyPairs" do
|
21
|
+
ec2.key_pairs.new.key_pairs.should be_a(Fog::AWS::EC2::KeyPairs)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be the key_pairs the keypair is related to" do
|
25
|
+
key_pairs = ec2.key_pairs
|
26
|
+
key_pairs.new.key_pairs.should == key_pairs
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#destroy" do
|
32
|
+
|
33
|
+
it "should return true if the key_pair is deleted" do
|
34
|
+
address = ec2.key_pairs.create(:name => 'keyname')
|
35
|
+
address.destroy.should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#reload" do
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
@key_pair = ec2.key_pairs.create(:name => 'keyname')
|
44
|
+
@reloaded = @key_pair.reload
|
45
|
+
end
|
46
|
+
|
47
|
+
after(:each) do
|
48
|
+
@key_pair.destroy
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return a Fog::AWS::EC2::KeyPair" do
|
52
|
+
@reloaded.should be_a(Fog::AWS::EC2::KeyPair)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should reset attributes to remote state" do
|
56
|
+
@key_pair.attributes.should == @reloaded.attributes
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#save" do
|
62
|
+
|
63
|
+
before(:each) do
|
64
|
+
@key_pair = ec2.key_pairs.new(:name => 'keyname')
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return true when it succeeds" do
|
68
|
+
@key_pair.save.should be_true
|
69
|
+
@key_pair.destroy
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should not exist in key_pairs before save" do
|
73
|
+
@key_pair.key_pairs.get(@key_pair.name).should be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should exist in buckets after save" do
|
77
|
+
@key_pair.save
|
78
|
+
@key_pair.key_pairs.get(@key_pair.name).should_not be_nil
|
79
|
+
@key_pair.destroy
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'Fog::AWS::EC2::KeyPairs' do
|
4
|
+
|
5
|
+
describe "#all" do
|
6
|
+
|
7
|
+
it "should return a Fog::AWS::EC2::KeyPairs" do
|
8
|
+
ec2.key_pairs.all.should be_a(Fog::AWS::EC2::KeyPairs)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should include persisted key_pairs" do
|
12
|
+
key_pair = ec2.key_pairs.create(:name => 'keyname')
|
13
|
+
ec2.key_pairs.get(key_pair.name).should_not be_nil
|
14
|
+
key_pair.destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#create" do
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
@key_pair = ec2.key_pairs.create(:name => 'keyname')
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:each) do
|
26
|
+
@key_pair.destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return a Fog::AWS::EC2::KeyPair" do
|
30
|
+
@key_pair.should be_a(Fog::AWS::EC2::KeyPair)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should exist on ec2" do
|
34
|
+
ec2.key_pairs.get(@key_pair.name).should_not be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#get" do
|
40
|
+
|
41
|
+
it "should return a Fog::AWS::EC2::KeyPair if a matching key_pair exists" do
|
42
|
+
key_pair = ec2.key_pairs.create(:name => 'keyname')
|
43
|
+
get = ec2.key_pairs.get(key_pair.name)
|
44
|
+
key_pair.attributes[:fingerprint].should == get.attributes[:fingerprint]
|
45
|
+
key_pair.attributes[:name].should == get.attributes[:name]
|
46
|
+
key_pair.destroy
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return nil if no matching key_pair exists" do
|
50
|
+
ec2.key_pairs.get('notakeyname').should be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#new" do
|
56
|
+
|
57
|
+
it "should return a Fog::AWS::EC2::KeyPair" do
|
58
|
+
ec2.key_pairs.new(:name => 'keyname').should be_a(Fog::AWS::EC2::KeyPair)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#reload" do
|
64
|
+
|
65
|
+
it "should return a Fog::AWS::EC2::KeyPairs" do
|
66
|
+
ec2.key_pairs.all.reload.should be_a(Fog::AWS::EC2::KeyPairs)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'Fog::AWS::EC2::SecurityGroup' do
|
4
|
+
|
5
|
+
describe "#initialize" do
|
6
|
+
|
7
|
+
it "should remap attributes from parser" #do
|
8
|
+
# address = Fog::AWS::EC2::SecurityGroup.new(
|
9
|
+
# 'instanceId' => 'i-00000000',
|
10
|
+
# 'publicIp' => '0.0.0.0'
|
11
|
+
# )
|
12
|
+
# address.instance_id.should == 'i-00000000'
|
13
|
+
# address.public_ip.should == '0.0.0.0'
|
14
|
+
# end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#security_groups" do
|
19
|
+
|
20
|
+
it "should return a Fog::AWS::EC2::SecurityGroups" do
|
21
|
+
ec2.security_groups.new.security_groups.should be_a(Fog::AWS::EC2::SecurityGroups)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be the security_groups the keypair is related to" do
|
25
|
+
security_groups = ec2.security_groups
|
26
|
+
security_groups.new.security_groups.should == security_groups
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#destroy" do
|
32
|
+
|
33
|
+
it "should return true if the security_group is deleted" do
|
34
|
+
address = ec2.security_groups.create(:group_description => 'groupdescription', :group_name => 'keyname')
|
35
|
+
address.destroy.should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#reload" do
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
@security_group = ec2.security_groups.create(:group_description => 'groupdescription', :group_name => 'keyname')
|
44
|
+
@reloaded = @security_group.reload
|
45
|
+
end
|
46
|
+
|
47
|
+
after(:each) do
|
48
|
+
@security_group.destroy
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return a Fog::AWS::EC2::SecurityGroup" do
|
52
|
+
@reloaded.should be_a(Fog::AWS::EC2::SecurityGroup)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should reset attributes to remote state" do
|
56
|
+
@security_group.attributes.should == @reloaded.attributes
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#save" do
|
62
|
+
|
63
|
+
before(:each) do
|
64
|
+
@security_group = ec2.security_groups.new(:group_description => 'groupdescription', :group_name => 'keyname')
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return true when it succeeds" do
|
68
|
+
@security_group.save.should be_true
|
69
|
+
@security_group.destroy
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should not exist in security_groups before save" do
|
73
|
+
@security_group.security_groups.get(@security_group.group_name).should be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should exist in buckets after save" do
|
77
|
+
@security_group.save
|
78
|
+
@security_group.security_groups.get(@security_group.group_name).should_not be_nil
|
79
|
+
@security_group.destroy
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|