fog 0.0.24 → 0.0.25

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.24
1
+ 0.0.25
data/fog.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fog}
8
- s.version = "0.0.24"
8
+ s.version = "0.0.25"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["geemus (Wesley Beary)"]
12
- s.date = %q{2009-10-21}
12
+ s.date = %q{2009-10-22}
13
13
  s.default_executable = %q{fog}
14
14
  s.description = %q{brings clouds to you}
15
15
  s.email = %q{me@geemus.com}
@@ -42,7 +42,7 @@ module Fog
42
42
  data = connection.allocate_address
43
43
  @public_ip = data.body['publicIp']
44
44
  if @instance
45
- instance = @instance
45
+ self.instance = @instance
46
46
  end
47
47
  true
48
48
  end
@@ -46,7 +46,7 @@ module Fog
46
46
  new_attributes = data.reject {|key,value| key == 'requestId'}
47
47
  merge_attributes(new_attributes)
48
48
  if @instance
49
- instance = @instance
49
+ self.instance = @instance
50
50
  end
51
51
  true
52
52
  end
@@ -37,6 +37,37 @@ describe 'Fog::AWS::EC2::Address' do
37
37
 
38
38
  end
39
39
 
40
+ describe "#instance=" do
41
+ before(:each) do
42
+ @address = ec2.addresses.new
43
+ @instance = ec2.instances.create(:image_id => GENTOO_AMI)
44
+ end
45
+
46
+ after(:each) do
47
+ if @address.public_ip
48
+ @address.destroy
49
+ end
50
+ @instance.destroy
51
+ end
52
+
53
+ it "should not associate with instance if the address has not been saved" do
54
+ @address.instance = @instance
55
+ @address.instance_id.should_not == @instance.instance_id
56
+ end
57
+
58
+ it "should associate with instance when the address is saved" do
59
+ @address.instance = @instance
60
+ @address.save.should be_true
61
+ @address.instance_id.should == @instance.instance_id
62
+ end
63
+
64
+ it "should associate with instance to an already saved address" do
65
+ @address.save.should be_true
66
+ @address.instance = @instance
67
+ @address.instance_id.should == @instance.instance_id
68
+ end
69
+ end
70
+
40
71
  describe "#reload" do
41
72
 
42
73
  before(:each) do
@@ -11,23 +11,19 @@ describe 'Fog::AWS::EC2::Instance' do
11
11
  'groupId' => 'group_id',
12
12
  'imageId' => 'image_id',
13
13
  'instanceId' => 'instance_id',
14
- 'instanceState' => { 'name' => 'instance_state' },
15
14
  'instanceType' => 'instance_type',
16
15
  'kernelId' => 'kernel_id',
17
16
  'keyName' => 'key_name',
18
17
  'launchTime' => 'launch_time',
19
- 'placement' => { 'availabilityZone' => 'availability_zone'},
20
18
  'productCodes' => 'product_codes',
21
19
  'privateDnsName' => 'private_dns_name',
22
20
  'ramdiskId' => 'ramdisk_id'
23
21
  })
24
22
  instance.ami_launch_index.should == 'ami_launch_index'
25
- instance.availability_zone.should == 'availability_zone'
26
23
  instance.dns_name.should == 'dns_name'
27
24
  instance.group_id.should == 'group_id'
28
25
  instance.image_id.should == 'image_id'
29
26
  instance.instance_id.should == 'instance_id'
30
- instance.instance_state.should == 'instance_state'
31
27
  instance.instance_type.should == 'instance_type'
32
28
  instance.kernel_id.should == 'kernel_id'
33
29
  instance.key_name.should == 'key_name'
@@ -46,21 +42,26 @@ describe 'Fog::AWS::EC2::Instance' do
46
42
  instance.addresses.should be_a(Fog::AWS::EC2::Addresses)
47
43
  end
48
44
 
49
- it "should not associate the address to a not yet saved instance"
50
- it "should associate the address after saving a new instance"
51
- it "should associate the address to an existing instance"
52
-
53
45
  end
54
46
 
55
47
  describe "#destroy" do
56
48
 
57
49
  it "should return true if the instance is deleted" do
58
- instance = ec2.instances.create(:image_id => 'ami-5ee70037')
50
+ instance = ec2.instances.create(:image_id => GENTOO_AMI)
59
51
  instance.destroy.should be_true
60
52
  end
61
53
 
62
54
  end
63
55
 
56
+ describe "#instance_state" do
57
+ it "should remap values out of hash" do
58
+ instance = Fog::AWS::EC2::Instance.new({
59
+ 'instanceState' => { 'name' => 'instance_state' },
60
+ })
61
+ instance.instance_state.should == 'instance_state'
62
+ end
63
+ end
64
+
64
65
  describe "#instances" do
65
66
 
66
67
  it "should return a Fog::AWS::EC2::Instances" do
@@ -83,17 +84,29 @@ describe 'Fog::AWS::EC2::Instance' do
83
84
  end
84
85
 
85
86
  describe "#monitoring=" do
86
- it "should have tests"
87
+ it "should remap values out of hash" do
88
+ instance = Fog::AWS::EC2::Instance.new({
89
+ 'monitoring' => { 'state' => true }
90
+ })
91
+ instance.monitoring.should == true
92
+ end
87
93
  end
88
94
 
89
95
  describe "#placement=" do
90
- it "should have tests"
96
+
97
+ it "should remap values into availability_zone" do
98
+ instance = Fog::AWS::EC2::Instance.new({
99
+ 'placement' => { 'availabilityZone' => 'availability_zone' }
100
+ })
101
+ instance.availability_zone.should == 'availability_zone'
102
+ end
103
+
91
104
  end
92
105
 
93
106
  describe "#reload" do
94
107
 
95
108
  before(:each) do
96
- @instance = ec2.instances.create(:image_id => 'ami-5ee70037')
109
+ @instance = ec2.instances.create(:image_id => GENTOO_AMI)
97
110
  @reloaded = @instance.reload
98
111
  end
99
112
 
@@ -141,10 +154,6 @@ describe 'Fog::AWS::EC2::Instance' do
141
154
  instance.volumes.should be_a(Fog::AWS::EC2::Volumes)
142
155
  end
143
156
 
144
- it "should not attach the volume to a not yet saved instance"
145
- it "should attach the volume after saving a new instance"
146
- it "should attach the volume to an existing instance"
147
-
148
157
  end
149
158
 
150
159
  end
@@ -9,7 +9,7 @@ describe 'Fog::AWS::EC2::Instances' do
9
9
  end
10
10
 
11
11
  it "should include persisted instances" do
12
- instance = ec2.instances.create(:image_id => 'ami-5ee70037')
12
+ instance = ec2.instances.create(:image_id => GENTOO_AMI)
13
13
  ec2.instances.get(instance.instance_id).should_not be_nil
14
14
  instance.destroy
15
15
  end
@@ -19,7 +19,7 @@ describe 'Fog::AWS::EC2::Instances' do
19
19
  describe "#create" do
20
20
 
21
21
  before(:each) do
22
- @instance = ec2.instances.create(:image_id => 'ami-5ee70037')
22
+ @instance = ec2.instances.create(:image_id => GENTOO_AMI)
23
23
  end
24
24
 
25
25
  after(:each) do
@@ -39,7 +39,7 @@ describe 'Fog::AWS::EC2::Instances' do
39
39
  describe "#get" do
40
40
 
41
41
  it "should return a Fog::AWS::EC2::Instance if a matching instance exists" do
42
- instance = ec2.instances.create(:image_id => 'ami-5ee70037')
42
+ instance = ec2.instances.create(:image_id => GENTOO_AMI)
43
43
  get = ec2.instances.get(instance.instance_id)
44
44
  instance.attributes.should == get.attributes
45
45
  instance.destroy
@@ -54,7 +54,7 @@ describe 'Fog::AWS::EC2::Instances' do
54
54
  describe "#new" do
55
55
 
56
56
  it "should return a Fog::AWS::EC2::Instance" do
57
- ec2.instances.new(:image_id => 'ami-5ee70037').should be_a(Fog::AWS::EC2::Instance)
57
+ ec2.instances.new(:image_id => GENTOO_AMI).should be_a(Fog::AWS::EC2::Instance)
58
58
  end
59
59
 
60
60
  end
@@ -45,6 +45,37 @@ describe 'Fog::AWS::EC2::Volume' do
45
45
 
46
46
  end
47
47
 
48
+ describe "#instance=" do
49
+ before(:each) do
50
+ @volume = ec2.volumes.new
51
+ @instance = ec2.instances.create(:image_id => GENTOO_AMI)
52
+ end
53
+
54
+ after(:each) do
55
+ if @volume.volume_id
56
+ @volume.destroy
57
+ end
58
+ @instance.destroy
59
+ end
60
+
61
+ it "should not attach to instance if the address has not been saved" do
62
+ @volume.instance = @instance
63
+ @volume.instance_id.should_not == @instance.instance_id
64
+ end
65
+
66
+ it "should attach to instance when the address is saved" do
67
+ @volume.instance = @instance
68
+ @volume.save.should be_true
69
+ @volume.instance_id.should == @instance.instance_id
70
+ end
71
+
72
+ it "should attach to instance to an already saved address" do
73
+ @volume.save.should be_true
74
+ @volume.instance = @instance
75
+ @volume.instance_id.should == @instance.instance_id
76
+ end
77
+ end
78
+
48
79
  describe "#reload" do
49
80
 
50
81
  before(:each) do
@@ -4,7 +4,7 @@ describe 'EC2.associate_address' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
7
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
8
8
  @public_ip = ec2.allocate_address.body['publicIp']
9
9
  end
10
10
 
@@ -31,7 +31,7 @@ describe 'EC2.associate_address' do
31
31
  end
32
32
 
33
33
  it "should raise a BadRequest error if the address does not exist" do
34
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
34
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
35
35
  lambda {
36
36
  ec2.associate_address(@instance_id, '127.0.0.1')
37
37
  }.should raise_error(Fog::Errors::BadRequest)
@@ -4,7 +4,7 @@ describe 'EC2.attach_volume' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
7
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
8
8
  @volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
9
9
  end
10
10
 
@@ -42,7 +42,7 @@ describe 'EC2.attach_volume' do
42
42
  end
43
43
 
44
44
  it "should raise a BadRequest error if the address does not exist" do
45
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
45
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
46
46
  lambda {
47
47
  ec2.attach_volume(@instance_id, 'vol-00000000', '/dev/sdh')
48
48
  }.should raise_error(Fog::Errors::BadRequest)
@@ -20,7 +20,7 @@ describe 'EC2.describe_images' do
20
20
  end
21
21
 
22
22
  it "should return proper attributes with params" do
23
- actual = ec2.describe_images('ImageId' => 'ami-5ee70037')
23
+ actual = ec2.describe_images('ImageId' => GENTOO_AMI)
24
24
  actual.body['requestId'].should be_a(String)
25
25
  image = actual.body['imagesSet'].first
26
26
  image['architecture'].should be_a(String)
@@ -4,7 +4,7 @@ describe 'EC2.describe_instances' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- run_instances = ec2.run_instances('ami-5ee70037', 1, 1).body
7
+ run_instances = ec2.run_instances(GENTOO_AMI, 1, 1).body
8
8
  @instance_id = run_instances['instancesSet'].first['instanceId']
9
9
  @reservation_id = run_instances['reservationId']
10
10
  end
@@ -4,7 +4,7 @@ describe 'EC2.detach_volume' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
7
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
8
8
  @volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
9
9
  eventually(128) do
10
10
  ec2.attach_volume(@instance_id, @volume_id, '/dev/sdh')
@@ -4,7 +4,7 @@ describe 'EC2.disassociate_address' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
7
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
8
8
  @public_ip = ec2.allocate_address.body['publicIp']
9
9
  ec2.associate_address(@instance_id, @public_ip)
10
10
  end
@@ -4,7 +4,7 @@ describe 'EC2.get_console_output' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
7
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
8
8
  end
9
9
 
10
10
  after(:each) do
@@ -4,7 +4,7 @@ describe 'EC2.reboot_instances' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
7
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
8
8
  end
9
9
 
10
10
  after(:each) do
@@ -9,7 +9,7 @@ describe 'EC2.run_instances' do
9
9
 
10
10
  it "should return proper attributes" do
11
11
  # ami-5ee70037 = gentoo
12
- actual = ec2.run_instances('ami-5ee70037', 1, 1)
12
+ actual = ec2.run_instances(GENTOO_AMI, 1, 1)
13
13
  @instance_id = actual.body['instancesSet'].first['instanceId']
14
14
  actual.body['groupSet'].should be_an(Array)
15
15
  actual.body['groupSet'].first.should be_a(String)
@@ -4,7 +4,7 @@ describe 'EC2.terminate_instances' do
4
4
  describe 'success' do
5
5
 
6
6
  before(:each) do
7
- @instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
7
+ @instance_id = ec2.run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
8
8
  end
9
9
 
10
10
  it "should return proper attributes" do
data/spec/spec_helper.rb CHANGED
@@ -78,4 +78,6 @@ def eventually(max_delay = 16, &block)
78
78
  raise error if delay >= max_delay
79
79
  end
80
80
  end
81
- end
81
+ end
82
+
83
+ GENTOO_AMI = 'ami-5ee70037'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus (Wesley Beary)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-21 00:00:00 -07:00
12
+ date: 2009-10-22 00:00:00 -07:00
13
13
  default_executable: fog
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency