fog 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/README.rdoc +79 -2
  2. data/VERSION +1 -1
  3. data/fog.gemspec +28 -6
  4. data/lib/fog.rb +10 -7
  5. data/lib/fog/aws.rb +35 -9
  6. data/lib/fog/aws/ec2.rb +82 -69
  7. data/lib/fog/aws/models/ec2/address.rb +23 -1
  8. data/lib/fog/aws/models/ec2/addresses.rb +26 -2
  9. data/lib/fog/aws/models/ec2/instance.rb +135 -0
  10. data/lib/fog/aws/models/ec2/instances.rb +56 -0
  11. data/lib/fog/aws/models/ec2/key_pair.rb +17 -2
  12. data/lib/fog/aws/models/ec2/key_pairs.rb +29 -3
  13. data/lib/fog/aws/models/ec2/security_group.rb +41 -0
  14. data/lib/fog/aws/models/ec2/security_groups.rb +62 -0
  15. data/lib/fog/aws/models/ec2/snapshot.rb +12 -12
  16. data/lib/fog/aws/models/ec2/snapshots.rb +43 -21
  17. data/lib/fog/aws/models/ec2/volume.rb +21 -10
  18. data/lib/fog/aws/models/ec2/volumes.rb +30 -4
  19. data/lib/fog/aws/models/s3/buckets.rb +5 -8
  20. data/lib/fog/aws/models/s3/objects.rb +4 -7
  21. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +63 -27
  22. data/lib/fog/aws/requests/ec2/create_security_group.rb +3 -3
  23. data/lib/fog/aws/requests/ec2/describe_images.rb +65 -35
  24. data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
  25. data/lib/fog/aws/requests/ec2/get_console_output.rb +52 -21
  26. data/lib/fog/aws/requests/ec2/reboot_instances.rb +52 -19
  27. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +63 -27
  28. data/lib/fog/aws/requests/ec2/run_instances.rb +1 -1
  29. data/lib/fog/aws/requests/ec2/terminate_instances.rb +14 -10
  30. data/lib/fog/aws/s3.rb +31 -35
  31. data/lib/fog/aws/simpledb.rb +19 -22
  32. data/lib/fog/collection.rb +3 -3
  33. data/lib/fog/connection.rb +2 -2
  34. data/lib/fog/errors.rb +1 -1
  35. data/lib/fog/model.rb +3 -3
  36. data/spec/aws/models/ec2/address_spec.rb +84 -0
  37. data/spec/aws/models/ec2/addresses_spec.rb +70 -0
  38. data/spec/aws/models/ec2/key_pair_spec.rb +84 -0
  39. data/spec/aws/models/ec2/key_pairs_spec.rb +71 -0
  40. data/spec/aws/models/ec2/security_group_spec.rb +84 -0
  41. data/spec/aws/models/ec2/security_groups_spec.rb +71 -0
  42. data/spec/aws/models/ec2/snapshot_spec.rb +93 -0
  43. data/spec/aws/models/ec2/snapshots_spec.rb +74 -0
  44. data/spec/aws/models/ec2/volume_spec.rb +84 -0
  45. data/spec/aws/models/ec2/volumes_spec.rb +70 -0
  46. data/spec/aws/models/s3/bucket_spec.rb +0 -1
  47. data/spec/aws/models/s3/buckets_spec.rb +2 -11
  48. data/spec/aws/requests/ec2/describe_security_groups_spec.rb +1 -1
  49. data/spec/aws/requests/ec2/get_console_output_spec.rb +9 -0
  50. data/spec/aws/requests/ec2/reboot_instances_spec.rb +11 -2
  51. data/spec/aws/requests/ec2/run_instances_spec.rb +1 -1
  52. data/spec/spec_helper.rb +1 -1
  53. metadata +26 -4
  54. data/LICENSE +0 -20
@@ -0,0 +1,71 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Fog::AWS::EC2::SecurityGroups' do
4
+
5
+ describe "#all" do
6
+
7
+ it "should return a Fog::AWS::EC2::SecurityGroups" do
8
+ ec2.security_groups.all.should be_a(Fog::AWS::EC2::SecurityGroups)
9
+ end
10
+
11
+ it "should include persisted security_groups" do
12
+ security_group = ec2.security_groups.create(:group_description => 'groupdescription', :group_name => 'keyname')
13
+ ec2.security_groups.get(security_group.group_name).should_not be_nil
14
+ security_group.destroy
15
+ end
16
+
17
+ end
18
+
19
+ describe "#create" do
20
+
21
+ before(:each) do
22
+ @security_group = ec2.security_groups.create(:group_description => 'groupdescription', :group_name => 'keyname')
23
+ end
24
+
25
+ after(:each) do
26
+ @security_group.destroy
27
+ end
28
+
29
+ it "should return a Fog::AWS::EC2::SecurityGroup" do
30
+ @security_group.should be_a(Fog::AWS::EC2::SecurityGroup)
31
+ end
32
+
33
+ it "should exist on ec2" do
34
+ ec2.security_groups.get(@security_group.group_name).should_not be_nil
35
+ end
36
+
37
+ end
38
+
39
+ describe "#get" do
40
+
41
+ it "should return a Fog::AWS::EC2::SecurityGroup if a matching security_group exists" do
42
+ security_group = ec2.security_groups.create(:group_description => 'groupdescription', :group_name => 'keyname')
43
+ get = ec2.security_groups.get(security_group.group_name)
44
+ security_group.attributes[:fingerprint].should == get.attributes[:fingerprint]
45
+ security_group.attributes[:group_name].should == get.attributes[:group_name]
46
+ security_group.destroy
47
+ end
48
+
49
+ it "should return nil if no matching security_group exists" do
50
+ ec2.security_groups.get('notasecuritygroupname').should be_nil
51
+ end
52
+
53
+ end
54
+
55
+ describe "#new" do
56
+
57
+ it "should return a Fog::AWS::EC2::SecurityGroup" do
58
+ ec2.security_groups.new(:group_description => 'groupdescription', :group_name => 'keyname').should be_a(Fog::AWS::EC2::SecurityGroup)
59
+ end
60
+
61
+ end
62
+
63
+ describe "#reload" do
64
+
65
+ it "should return a Fog::AWS::EC2::SecurityGroups" do
66
+ ec2.security_groups.all.reload.should be_a(Fog::AWS::EC2::SecurityGroups)
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,93 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Fog::AWS::EC2::Snapshots' do
4
+
5
+ describe "#initialize" do
6
+
7
+ it "should remap attributes from parser" # do
8
+ # snapshot = 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 "#snapshots" do
19
+
20
+ it "should return a Fog::AWS::EC2::Snapshots" do
21
+ ec2.snapshots.new.snapshots.should be_a(Fog::AWS::EC2::Snapshots)
22
+ end
23
+
24
+ it "should be the snapshots the snapshot is related to" do
25
+ snapshots = ec2.snapshots
26
+ snapshots.new.snapshots.should == snapshots
27
+ end
28
+
29
+ end
30
+
31
+ describe "#destroy" do
32
+
33
+ it "should return true if the snapshot is deleted" do
34
+ volume = ec2.volumes.create
35
+ snapshot = volume.snapshots.create
36
+ snapshot.destroy.should be_true
37
+ volume.destroy
38
+ end
39
+
40
+ end
41
+
42
+ describe "#reload" do
43
+
44
+ before(:each) do
45
+ @volume = ec2.volumes.create
46
+ @snapshot = @volume.snapshots.create
47
+ @reloaded = @snapshot.reload
48
+ end
49
+
50
+ after(:each) do
51
+ @snapshot.destroy
52
+ @volume.destroy
53
+ end
54
+
55
+ it "should return a Fog::AWS::EC2::Snapshot" do
56
+ @reloaded.should be_a(Fog::AWS::EC2::Snapshot)
57
+ end
58
+
59
+ it "should reset attributes to remote state" do
60
+ @snapshot.attributes.should == @reloaded.attributes
61
+ end
62
+
63
+ end
64
+
65
+ describe "#save" do
66
+
67
+ before(:each) do
68
+ @volume = ec2.volumes.create
69
+ @snapshot = @volume.snapshots.new
70
+ end
71
+
72
+ after(:each) do
73
+ @volume.destroy
74
+ end
75
+
76
+ it "should return true when it succeeds" do
77
+ @snapshot.save.should be_true
78
+ @snapshot.destroy
79
+ end
80
+
81
+ it "should not exist in addresses before save" do
82
+ @snapshot.snapshots.get(@snapshot.snapshot_id).should be_nil
83
+ end
84
+
85
+ it "should exist in buckets after save" do
86
+ @snapshot.save
87
+ @snapshot.snapshots.get(@snapshot.snapshot_id).should_not be_nil
88
+ @snapshot.destroy
89
+ end
90
+
91
+ end
92
+
93
+ end
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Fog::AWS::EC2::Snapshots' do
4
+
5
+ describe "#all" do
6
+
7
+ it "should return a Fog::AWS::EC2::Snapshots" do
8
+ ec2.snapshots.all.should be_a(Fog::AWS::EC2::Snapshots)
9
+ end
10
+
11
+ it "should include persisted snapshots" do
12
+ volume = ec2.volumes.create
13
+ snapshot = volume.snapshots.create
14
+ ec2.snapshots.get(snapshot.snapshot_id).should_not be_nil
15
+ snapshot.destroy
16
+ end
17
+
18
+ end
19
+
20
+ describe "#create" do
21
+
22
+ before(:each) do
23
+ @volume = ec2.volumes.create
24
+ @snapshot = @volume.snapshots.create
25
+ end
26
+
27
+ after(:each) do
28
+ @snapshot.destroy
29
+ @volume.destroy
30
+ end
31
+
32
+ it "should return a Fog::AWS::EC2::Snapshot" do
33
+ @snapshot.should be_a(Fog::AWS::EC2::Snapshot)
34
+ end
35
+
36
+ it "should exist on ec2" do
37
+ ec2.snapshots.get(@snapshot.snapshot_id).should_not be_nil
38
+ end
39
+
40
+ end
41
+
42
+ describe "#get" do
43
+
44
+ it "should return a Fog::AWS::EC2::Snapshot if a matching snapshot exists" do
45
+ volume = ec2.volumes.create
46
+ snapshot = volume.snapshots.create
47
+ get = ec2.snapshots.get(snapshot.snapshot_id)
48
+ snapshot.attributes.should == get.attributes
49
+ snapshot.destroy
50
+ end
51
+
52
+ it "should return nil if no matching address exists" do
53
+ ec2.snapshots.get('vol-00000000').should be_nil
54
+ end
55
+
56
+ end
57
+
58
+ describe "#new" do
59
+
60
+ it "should return a Fog::AWS::EC2::Snapshot" do
61
+ ec2.snapshots.new.should be_a(Fog::AWS::EC2::Snapshot)
62
+ end
63
+
64
+ end
65
+
66
+ describe "#reload" do
67
+
68
+ it "should return a Fog::AWS::EC2::Snapshots" do
69
+ ec2.snapshots.all.reload.should be_a(Fog::AWS::EC2::Snapshots)
70
+ end
71
+
72
+ end
73
+
74
+ end
@@ -0,0 +1,84 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Fog::AWS::EC2::Volume' do
4
+
5
+ describe "#initialize" do
6
+
7
+ it "should remap attributes from parser" # do
8
+ # volume = 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 "#volumes" do
19
+
20
+ it "should return a Fog::AWS::EC2::Volumes" do
21
+ ec2.volumes.new.volumes.should be_a(Fog::AWS::EC2::Volumes)
22
+ end
23
+
24
+ it "should be the volumes the volume is related to" do
25
+ volumes = ec2.volumes
26
+ volumes.new.volumes.should == volumes
27
+ end
28
+
29
+ end
30
+
31
+ describe "#destroy" do
32
+
33
+ it "should return true if the volume is deleted" do
34
+ volume = ec2.volumes.create
35
+ volume.destroy.should be_true
36
+ end
37
+
38
+ end
39
+
40
+ describe "#reload" do
41
+
42
+ before(:each) do
43
+ @volume = ec2.volumes.create
44
+ @reloaded = @volume.reload
45
+ end
46
+
47
+ after(:each) do
48
+ @volume.destroy
49
+ end
50
+
51
+ it "should return a Fog::AWS::EC2::Volume" do
52
+ @reloaded.should be_a(Fog::AWS::EC2::Volume)
53
+ end
54
+
55
+ it "should reset attributes to remote state" do
56
+ @volume.attributes.should == @reloaded.attributes
57
+ end
58
+
59
+ end
60
+
61
+ describe "#save" do
62
+
63
+ before(:each) do
64
+ @volume = ec2.volumes.new
65
+ end
66
+
67
+ it "should return true when it succeeds" do
68
+ @volume.save.should be_true
69
+ @volume.destroy
70
+ end
71
+
72
+ it "should not exist in addresses before save" do
73
+ @volume.volumes.get(@volume.volume_id).should be_nil
74
+ end
75
+
76
+ it "should exist in buckets after save" do
77
+ @volume.save
78
+ @volume.volumes.get(@volume.volume_id).should_not be_nil
79
+ @volume.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::Volumes' do
4
+
5
+ describe "#all" do
6
+
7
+ it "should return a Fog::AWS::EC2::Volumes" do
8
+ ec2.volumes.all.should be_a(Fog::AWS::EC2::Volumes)
9
+ end
10
+
11
+ it "should include persisted volumes" do
12
+ volume = ec2.volumes.create
13
+ ec2.volumes.get(volume.volume_id).should_not be_nil
14
+ volume.destroy
15
+ end
16
+
17
+ end
18
+
19
+ describe "#create" do
20
+
21
+ before(:each) do
22
+ @volume = ec2.volumes.create
23
+ end
24
+
25
+ after(:each) do
26
+ @volume.destroy
27
+ end
28
+
29
+ it "should return a Fog::AWS::EC2::Volume" do
30
+ @volume.should be_a(Fog::AWS::EC2::Volume)
31
+ end
32
+
33
+ it "should exist on ec2" do
34
+ ec2.volumes.get(@volume.volume_id).should_not be_nil
35
+ end
36
+
37
+ end
38
+
39
+ describe "#get" do
40
+
41
+ it "should return a Fog::AWS::EC2::Volume if a matching volume exists" do
42
+ volume = ec2.volumes.create
43
+ get = ec2.volumes.get(volume.volume_id)
44
+ volume.attributes.should == get.attributes
45
+ volume.destroy
46
+ end
47
+
48
+ it "should return nil if no matching address exists" do
49
+ ec2.volumes.get('vol-00000000').should be_nil
50
+ end
51
+
52
+ end
53
+
54
+ describe "#new" do
55
+
56
+ it "should return a Fog::AWS::EC2::Volume" do
57
+ ec2.volumes.new.should be_a(Fog::AWS::EC2::Volume)
58
+ end
59
+
60
+ end
61
+
62
+ describe "#reload" do
63
+
64
+ it "should return a Fog::AWS::EC2::Volumes" do
65
+ ec2.volumes.all.reload.should be_a(Fog::AWS::EC2::Volumes)
66
+ end
67
+
68
+ end
69
+
70
+ end
@@ -98,7 +98,6 @@ describe 'Fog::AWS::S3::Bucket' do
98
98
  end
99
99
 
100
100
  it "should reset attributes to remote state" do
101
- @bucket.creation_date = Time.now
102
101
  @bucket.attributes.should == @reloaded.attributes
103
102
  end
104
103
 
@@ -9,9 +9,9 @@ describe 'Fog::AWS::S3::Buckets' do
9
9
  end
10
10
 
11
11
  it "should include persisted buckets" do
12
- @bucket = s3.buckets.create(:name => 'fogbucketname')
12
+ bucket = s3.buckets.create(:name => 'fogbucketname')
13
13
  s3.buckets.all.map {|bucket| bucket.name}.should include('fogbucketname')
14
- @bucket.destroy
14
+ bucket.destroy
15
15
  end
16
16
 
17
17
  end
@@ -45,15 +45,6 @@ describe 'Fog::AWS::S3::Buckets' do
45
45
  bucket.destroy
46
46
  end
47
47
 
48
- it "should return memoized bucket on subsequent gets" do
49
- bucket = s3.buckets.create(:name => 'fogbucketname')
50
- get1 = s3.buckets.get('fogbucketname')
51
- s3.should_not_receive(:get_bucket)
52
- get2 = s3.buckets.get('fogbucketname')
53
- get1.attributes.should == get2.attributes
54
- bucket.destroy
55
- end
56
-
57
48
  it "should return nil if no matching bucket exists" do
58
49
  s3.buckets.get('fogbucketname').should be_nil
59
50
  end
@@ -16,7 +16,7 @@ describe 'EC2.describe_security_groups' do
16
16
  actual.body['requestId'].should be_a(String)
17
17
  actual.body['securityGroupInfo'].should be_an(Array)
18
18
  security_group = actual.body['securityGroupInfo'].select do |security_group|
19
- security_group['groupName'] == 'default'
19
+ security_group['groupName'] == 'fog_security_group'
20
20
  end.first
21
21
  security_group['groupDescription'].should be_a(String)
22
22
  security_group['groupName'].should be_a(String)
@@ -20,4 +20,13 @@ describe 'EC2.get_console_output' do
20
20
  end
21
21
 
22
22
  end
23
+ describe 'failure' do
24
+
25
+ it "should raise a BadRequest error if the instance does not exist" do
26
+ lambda {
27
+ ec2.get_console_output('i-00000000')
28
+ }.should raise_error(Fog::Errors::BadRequest)
29
+ end
30
+
31
+ end
23
32
  end