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.
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
@@ -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(:"#{attribute}")
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(:"#{aliased_key}=", value)
50
+ send("#{aliased_key}=", value)
51
51
  else
52
- send(:"#{key}=", value)
52
+ send("#{key}=", value)
53
53
  end
54
54
  end
55
55
  self
@@ -3,8 +3,8 @@ require 'openssl'
3
3
  require 'socket'
4
4
  require 'uri'
5
5
 
6
- require "#{File.dirname(__FILE__)}/errors"
7
- require "#{File.dirname(__FILE__)}/response"
6
+ require "fog/errors"
7
+ require "fog/response"
8
8
 
9
9
  unless Fog.mocking?
10
10
 
data/lib/fog/errors.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "#{File.dirname(__FILE__)}/parser"
1
+ require "fog/parser"
2
2
 
3
3
  module Fog
4
4
  module Errors
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(:"#{attribute}")
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(:"#{aliased_key}=", value)
45
+ send("#{aliased_key}=", value)
46
46
  else
47
- send(:"#{key}=", value)
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