fog 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/fog.gemspec +13 -7
  2. data/lib/fog.rb +1 -1
  3. data/lib/fog/aws.rb +0 -4
  4. data/lib/fog/aws/parsers/ec2/get_console_output.rb +4 -2
  5. data/lib/fog/aws/requests/ec2/associate_address.rb +1 -1
  6. data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -2
  7. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +1 -1
  8. data/lib/fog/aws/requests/ec2/delete_security_group.rb +1 -1
  9. data/lib/fog/aws/requests/ec2/delete_snapshot.rb +1 -1
  10. data/lib/fog/aws/requests/ec2/delete_volume.rb +1 -1
  11. data/lib/fog/aws/requests/ec2/describe_addresses.rb +1 -1
  12. data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -2
  13. data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +1 -1
  14. data/lib/fog/aws/requests/ec2/describe_security_groups.rb +1 -1
  15. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +1 -1
  16. data/lib/fog/aws/requests/ec2/describe_volumes.rb +1 -1
  17. data/lib/fog/aws/requests/ec2/detach_volume.rb +1 -1
  18. data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -2
  19. data/lib/fog/aws/requests/ec2/reboot_instances.rb +1 -1
  20. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +1 -1
  21. data/lib/fog/aws/requests/ec2/run_instances.rb +2 -1
  22. data/lib/fog/aws/requests/ec2/terminate_instances.rb +1 -1
  23. data/lib/fog/collection.rb +7 -3
  24. data/lib/fog/terremark/shared.rb +4 -2
  25. data/lib/fog/vcloud.rb +25 -3
  26. data/lib/fog/vcloud/collection.rb +66 -0
  27. data/lib/fog/vcloud/model.rb +49 -0
  28. data/lib/fog/vcloud/models/vdc.rb +36 -0
  29. data/lib/fog/vcloud/models/vdcs.rb +36 -0
  30. data/lib/fog/vcloud/parser.rb +4 -1
  31. data/lib/fog/vcloud/parsers/get_vdc.rb +26 -1
  32. data/lib/fog/vcloud/parsers/login.rb +2 -6
  33. data/lib/fog/vcloud/requests/get_organization.rb +1 -1
  34. data/lib/fog/vcloud/requests/get_vdc.rb +32 -1
  35. data/lib/fog/vcloud/terremark/ecloud.rb +2 -1
  36. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +20 -0
  37. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +29 -0
  38. data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +3 -3
  39. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +1 -1
  40. data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +1 -1
  41. data/spec/aws/models/ec2/snapshots_spec.rb +1 -1
  42. data/spec/shared_examples/servers_examples.rb +1 -1
  43. data/spec/vcloud/models/vdc_spec.rb +46 -0
  44. data/spec/vcloud/models/vdcs_spec.rb +1 -0
  45. data/spec/vcloud/requests/get_organization_spec.rb +2 -2
  46. data/spec/vcloud/requests/get_vdc_spec.rb +6 -3
  47. data/spec/vcloud/spec_helper.rb +44 -8
  48. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +43 -0
  49. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +25 -0
  50. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +8 -8
  51. data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +4 -4
  52. data/tests/aws/helper.rb +0 -8
  53. data/tests/aws/requests/ec2/address_tests.rb +3 -3
  54. data/tests/aws/requests/ec2/availability_zone_tests.rb +2 -2
  55. data/tests/aws/requests/ec2/instance_tests.rb +122 -0
  56. data/tests/aws/requests/ec2/key_pair_tests.rb +1 -1
  57. data/tests/aws/requests/ec2/region_tests.rb +2 -2
  58. data/tests/aws/requests/ec2/security_group_tests.rb +6 -6
  59. data/tests/aws/requests/ec2/snapshot_tests.rb +2 -2
  60. data/tests/aws/requests/ec2/volume_tests.rb +5 -5
  61. data/tests/helper.rb +19 -6
  62. data/tests/rackspace/requests/servers/list_images_detail_tests.rb +1 -1
  63. metadata +14 -8
  64. data/spec/aws/requests/ec2/describe_instances_spec.rb +0 -104
  65. data/spec/aws/requests/ec2/get_console_output_spec.rb +0 -35
  66. data/spec/aws/requests/ec2/reboot_instances_spec.rb +0 -30
  67. data/spec/aws/requests/ec2/run_instances_spec.rb +0 -48
  68. data/spec/aws/requests/ec2/terminate_instances_spec.rb +0 -35
@@ -27,12 +27,12 @@ describe Fog::Vcloud, :type => :vcloud_request do
27
27
 
28
28
  its(:links) { should have(@mock_organization[:vdcs].length * 3).links }
29
29
  its(:name) { should == @mock_organization[:info][:name] }
30
- its(:href) { should == @mock_organization[:info][:href] }
30
+ its(:href) { should == URI.parse(@mock_organization[:info][:href]) }
31
31
 
32
32
  let(:link) { subject.links[0] }
33
33
  specify { link.should be_an_instance_of Struct::VcloudLink }
34
34
  specify { link.rel.should == "down" }
35
- specify { link.href.should == @mock_vdc[:href] }
35
+ specify { link.href.should == URI.parse(@mock_vdc[:href]) }
36
36
  specify { link.type.should == "application/vnd.vmware.vcloud.vdc+xml" }
37
37
  specify { link.name.should == @mock_vdc[:name] }
38
38
  end
@@ -11,7 +11,7 @@ describe Fog::Vcloud, :type => :vcloud_request do
11
11
 
12
12
  describe :get_vdc, :type => :vcloud_request do
13
13
  context "with a valid vdc uri" do
14
- before { @vdc = @vcloud.get_vdc(@mock_vdc[:href]) }
14
+ before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc[:href])) }
15
15
  subject { @vdc }
16
16
 
17
17
  it_should_behave_like "all requests"
@@ -30,13 +30,16 @@ describe Fog::Vcloud, :type => :vcloud_request do
30
30
  it_should_behave_like "it has a vcloud v0.8 xmlns"
31
31
 
32
32
  its(:links) { should have(7).links }
33
+ its(:resource_entities) { should have(3).links }
34
+ its(:networks) { should have(2).networks }
35
+
33
36
  its(:name) { should == @mock_vdc[:name] }
34
- its(:href) { should == @mock_vdc[:href] }
37
+ its(:href) { should == URI.parse(@mock_vdc[:href]) }
35
38
 
36
39
  let(:link) { subject.links[0] }
37
40
  specify { link.should be_an_instance_of Struct::VcloudLink }
38
41
  specify { link.rel.should == "up" }
39
- specify { link.href.should == @mock_organization[:info][:href] }
42
+ specify { link.href.should == URI.parse(@mock_organization[:info][:href]) }
40
43
  specify { link.type.should == "application/vnd.vmware.vcloud.org+xml" }
41
44
  end
42
45
  end
@@ -80,9 +80,9 @@ shared_examples_for "all login requests" do
80
80
  before { @org = @orglist.organizations.first }
81
81
  subject { @org }
82
82
 
83
- it { should be_an_instance_of Struct::VcloudOrgLink }
83
+ it { should be_an_instance_of Struct::VcloudLink }
84
84
 
85
- its(:href) { should == @mock_organization[:info][:href] }
85
+ its(:href) { should == URI.parse(@mock_organization[:info][:href]) }
86
86
  its(:name) { should == @mock_organization[:info][:name] }
87
87
  its(:type) { should == "application/vnd.vmware.vcloud.org+xml" }
88
88
 
@@ -102,7 +102,7 @@ end
102
102
  shared_examples_for "a vdc catalog link" do
103
103
  it_should_behave_like "all rel=down vcloud links"
104
104
  it_should_behave_like "all vcloud catalog links"
105
- its(:href) { should == @mock_vdc[:href] + "/catalog" }
105
+ its(:href) { should == URI.parse(@mock_vdc[:href] + "/catalog") }
106
106
  end
107
107
 
108
108
  shared_examples_for "a tmrk vdc" do
@@ -122,14 +122,14 @@ shared_examples_for "the mocked tmrk network links" do
122
122
  describe "[0]" do
123
123
  subject { @vdc.body.networks[0] }
124
124
  it_should_behave_like "a tmrk network link"
125
- its(:href) { should == @mock_vdc[:networks][0][:href] }
125
+ its(:href) { should == URI.parse(@mock_vdc[:networks][0][:href]) }
126
126
  its(:name) { should == @mock_vdc[:networks][0][:name] }
127
127
  end
128
128
 
129
129
  describe "[1]" do
130
130
  subject { @vdc.body.networks[1] }
131
131
  it_should_behave_like "a tmrk network link"
132
- its(:href) { should == @mock_vdc[:networks][1][:href] }
132
+ its(:href) { should == URI.parse(@mock_vdc[:networks][1][:href]) }
133
133
  its(:name) { should == @mock_vdc[:networks][1][:name] }
134
134
  end
135
135
  end
@@ -141,27 +141,29 @@ shared_examples_for "the mocked tmrk resource entity links" do
141
141
  subject { @vdc.body.resource_entities[0] }
142
142
  it_should_behave_like "a vapp type"
143
143
  it_should_behave_like "all vcloud links w/o a rel"
144
- its(:href) { should == @mock_vdc[:vms][0][:href] }
144
+ its(:href) { should == URI.parse(@mock_vdc[:vms][0][:href]) }
145
145
  its(:name) { should == @mock_vdc[:vms][0][:name] }
146
146
  end
147
147
  describe "[1]" do
148
148
  subject { @vdc.body.resource_entities[1] }
149
149
  it_should_behave_like "a vapp type"
150
150
  it_should_behave_like "all vcloud links w/o a rel"
151
- its(:href) { should == @mock_vdc[:vms][1][:href] }
151
+ its(:href) { should == URI.parse(@mock_vdc[:vms][1][:href]) }
152
152
  its(:name) { should == @mock_vdc[:vms][1][:name] }
153
153
  end
154
154
  describe "[2]" do
155
155
  subject { @vdc.body.resource_entities[2] }
156
156
  it_should_behave_like "a vapp type"
157
157
  it_should_behave_like "all vcloud links w/o a rel"
158
- its(:href) { should == @mock_vdc[:vms][2][:href] }
158
+ its(:href) { should == URI.parse(@mock_vdc[:vms][2][:href]) }
159
159
  its(:name) { should == @mock_vdc[:vms][2][:name] }
160
160
  end
161
161
  end
162
162
 
163
163
  Spec::Example::ExampleGroupFactory.register(:vcloud_request, Class.new(Spec::Example::ExampleGroup))
164
+ Spec::Example::ExampleGroupFactory.register(:vcloud_model, Class.new(Spec::Example::ExampleGroup))
164
165
  Spec::Example::ExampleGroupFactory.register(:tmrk_ecloud_request, Class.new(Spec::Example::ExampleGroup))
166
+ Spec::Example::ExampleGroupFactory.register(:tmrk_ecloud_model, Class.new(Spec::Example::ExampleGroup))
165
167
  Spec::Example::ExampleGroupFactory.register(:tmrk_vcloud_request, Class.new(Spec::Example::ExampleGroup))
166
168
 
167
169
  Spec::Runner.configure do |config|
@@ -171,14 +173,48 @@ Spec::Runner.configure do |config|
171
173
  @mock_organization = @mock_data[:organizations][0]
172
174
  @mock_vdc = @mock_organization[:vdcs][0]
173
175
  end
176
+ config.before(:each, :type => :vcloud_model) do
177
+ @vcloud = Fog::Vcloud.new
178
+ end
174
179
  config.before(:each, :type => :vcloud_request) do
175
180
  @vcloud = Fog::Vcloud.new
176
181
  end
177
182
  config.before(:each, :type => :tmrk_ecloud_request) do
178
183
  @vcloud = Fog::Vcloud.new(:module => "Fog::Vcloud::Terremark::Ecloud")
179
184
  end
185
+ config.before(:each, :type => :tmrk_ecloud_model) do
186
+ @vcloud = Fog::Vcloud.new(:module => "Fog::Vcloud::Terremark::Ecloud")
187
+ end
180
188
  config.before(:each, :type => :tmrk_vcloud_request) do
181
189
  @vcloud = Fog::Vcloud.new(:module => "Fog::Vcloud::Terremark::Vcloud")
182
190
  end
183
191
  end
184
192
 
193
+ Spec::Matchers.define :have_only_these_attributes do |expected|
194
+ match do |actual|
195
+ attributes = actual.instance_variable_get('@attributes')
196
+ attributes.all? { |attribute| expected.include?(attribute) } && ( expected.length == attributes.length )
197
+ end
198
+
199
+ failure_message_for_should do |actual|
200
+ msg = "Expected: [#{expected.map{|e| ":#{e}"}.join(", ")}]\n"
201
+ msg += "Got: [#{actual.instance_variable_get('@attributes').map{|a| ":#{a}"}.join(", ")}]"
202
+ msg
203
+ end
204
+ end
205
+
206
+ Spec::Matchers.define :have_identity do |expected|
207
+ match do |actual|
208
+ actual.instance_variable_get('@identity').should == expected
209
+ end
210
+
211
+ failure_message_for_should do |actual|
212
+ "Expected: '#{expected}', but got: '#{actual.instance_variable_get('@identity')}'"
213
+ end
214
+ end
215
+
216
+ Spec::Matchers.define :have_members_of_the_right_model do
217
+ match do |actual|
218
+ actual.all? { |member| member.is_a?(actual.model) }
219
+ end
220
+ end
@@ -0,0 +1,43 @@
1
+ require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
+
3
+ describe "Fog::Vcloud::Terremark::Ecloud::Vdc", :type => :tmrk_ecloud_model do
4
+ subject { @vcloud }
5
+
6
+ it { should respond_to :get_vdc }
7
+
8
+ describe :class do
9
+ subject { Fog::Vcloud::Terremark::Ecloud::Vdc }
10
+
11
+ it { should have_identity :href }
12
+ it { should have_only_these_attributes [:href, :name, :other_links, :resource_entity_links, :network_links, :cpu_capacity,
13
+ :storage_capacity, :memory_capacity, :vcloud_type, :xmlns, :description,
14
+ :deployed_vm_quota, :instantiated_vm_quota] }
15
+ end
16
+
17
+ context "with no uri" do
18
+
19
+ subject { Fog::Vcloud::Terremark::Ecloud::Vdc.new() }
20
+
21
+ its(:href) { should be_nil }
22
+ its(:identity) { should be_nil }
23
+ end
24
+
25
+ context "as a collection member" do
26
+ subject { @vcloud.vdcs[0] }
27
+
28
+ its(:href) { should == URI.parse(@mock_vdc[:href]) }
29
+ its(:identity) { should == URI.parse(@mock_vdc[:href]) }
30
+ its(:name) { should == @mock_vdc[:name] }
31
+ its(:other_links) { should have(4).items }
32
+ its(:resource_entity_links) { should have(3).items }
33
+ its(:network_links) { should have(2).items }
34
+
35
+ its(:cpu_capacity) { should == Struct::VcloudXCapacity.new('hz * 10^6',@mock_vdc[:cpu][:allocated]) }
36
+ its(:memory_capacity) { should == Struct::VcloudXCapacity.new('bytes * 2^20',@mock_vdc[:memory][:allocated]) }
37
+ its(:storage_capacity) { should == Struct::VcloudXCapacity.new('bytes * 10^9',@mock_vdc[:storage][:allocated], @mock_vdc[:storage][:used]) }
38
+
39
+ its(:deployed_vm_quota) { should == Struct::VcloudXCapacity.new(nil,nil,-1,-1) }
40
+ its(:instantiated_vm_quota) { should == Struct::VcloudXCapacity.new(nil,nil,-1,-1) }
41
+
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
+
3
+ describe "Fog::Vcloud::Terremark::Ecloud::Vdcs", :type => :tmrk_ecloud_model do
4
+ subject { @vcloud }
5
+
6
+ it { should respond_to :vdcs }
7
+
8
+ describe :class do
9
+ subject { @vcloud.vdcs.class }
10
+ its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Vdc }
11
+ its(:get_request) { should == :get_vdc }
12
+ its(:all_request) { should be_an_instance_of Proc }
13
+ its(:vcloud_type) { should == "application/vnd.vmware.vcloud.vdc+xml" }
14
+ end
15
+
16
+ describe :vdcs do
17
+ subject { @vcloud.vdcs }
18
+
19
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Vdcs }
20
+
21
+ its(:length) { should == 2 }
22
+
23
+ it { should have_members_of_the_right_model }
24
+ end
25
+ end
@@ -7,7 +7,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
7
7
 
8
8
  describe "#get_vdc" do
9
9
  context "with a valid vdc uri" do
10
- before { @vdc = @vcloud.get_vdc(@mock_vdc[:href]) }
10
+ before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc[:href])) }
11
11
  subject { @vdc }
12
12
 
13
13
  it_should_behave_like "all requests"
@@ -33,7 +33,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
33
33
  it { should respond_to :instantiated_vm_quota }
34
34
 
35
35
  its(:name) { should == @mock_vdc[:name] }
36
- its(:href) { should == @mock_vdc[:href] }
36
+ its(:href) { should == URI.parse(@mock_vdc[:href]) }
37
37
  its(:description) { should == '' }
38
38
 
39
39
  describe "#links" do
@@ -51,7 +51,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
51
51
  it_should_behave_like "all rel=down vcloud links"
52
52
  it_should_behave_like "all tmrk ecloud publicIpList links"
53
53
 
54
- specify { subject.href.should == @mock_vdc[:href].sub('/vdc','/extensions/vdc') + "/publicIps" }
54
+ specify { subject.href.should == URI.parse(@mock_vdc[:href].sub('/vdc','/extensions/vdc') + "/publicIps") }
55
55
  end
56
56
 
57
57
  describe "[2]" do
@@ -60,7 +60,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
60
60
  it_should_behave_like "all rel=down vcloud links"
61
61
  it_should_behave_like "all tmrk ecloud internetServicesList links"
62
62
 
63
- specify { subject.href.should == @mock_vdc[:href] + "/internetServices" }
63
+ specify { subject.href.should == URI.parse(@mock_vdc[:href] + "/internetServices") }
64
64
  end
65
65
 
66
66
  describe "[3]" do
@@ -69,7 +69,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
69
69
  it_should_behave_like "all rel=down vcloud links"
70
70
  it_should_behave_like "all tmrk ecloud firewallAclList links"
71
71
 
72
- specify { subject.href.should == @mock_vdc[:href].sub('/vdc','/extensions/vdc') + "/firewallAcls" }
72
+ specify { subject.href.should == URI.parse(@mock_vdc[:href].sub('/vdc','/extensions/vdc') + "/firewallAcls") }
73
73
  end
74
74
  end
75
75
 
@@ -96,7 +96,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
96
96
 
97
97
  describe "#memory_capacity" do
98
98
  subject { @vdc.body.memory_capacity }
99
- it { should be_an_instance_of Struct::TmrkEcloudXCapacity }
99
+ it { should be_an_instance_of Struct::VcloudXCapacity }
100
100
  its(:units) { should == "bytes * 2^20" }
101
101
  its(:allocated) { should == @mock_vdc[:memory][:allocated] }
102
102
  its(:used) { should == nil }
@@ -105,7 +105,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
105
105
 
106
106
  describe "#deployed_vm_quota" do
107
107
  subject { @vdc.body.deployed_vm_quota }
108
- it { should be_an_instance_of Struct::TmrkEcloudXCapacity }
108
+ it { should be_an_instance_of Struct::VcloudXCapacity }
109
109
  its(:limit) { should == -1 }
110
110
  its(:used) { should == -1 }
111
111
  its(:units) { should == nil }
@@ -113,7 +113,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ec
113
113
  end
114
114
  describe "#instantiated_vm_quota" do
115
115
  subject { @vdc.body.instantiated_vm_quota }
116
- it { should be_an_instance_of Struct::TmrkEcloudXCapacity }
116
+ it { should be_an_instance_of Struct::VcloudXCapacity }
117
117
  its(:limit) { should == -1 }
118
118
  its(:used) { should == -1 }
119
119
  its(:units) { should == nil }
@@ -7,7 +7,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Vcloud module", :type => :tmrk_vc
7
7
 
8
8
  describe :get_vdc do
9
9
  context "with a valid vdc uri" do
10
- before { @vdc = @vcloud.get_vdc(@mock_vdc[:href]) }
10
+ before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc[:href])) }
11
11
  subject { @vdc }
12
12
 
13
13
  it_should_behave_like "all requests"
@@ -27,7 +27,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Vcloud module", :type => :tmrk_vc
27
27
  it_should_behave_like "a tmrk vdc"
28
28
 
29
29
  its(:name) { should == @mock_vdc[:name] }
30
- its(:href) { should == @mock_vdc[:href] }
30
+ its(:href) { should == URI.parse(@mock_vdc[:href]) }
31
31
 
32
32
  describe "#links" do
33
33
  subject { @vdc.body.links }
@@ -43,7 +43,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Vcloud module", :type => :tmrk_vc
43
43
 
44
44
  it_should_behave_like "all rel=down vcloud links"
45
45
  it_should_behave_like "all vcloud application/xml types"
46
- specify { subject.href.should == @mock_vdc[:href] + "/publicIps" }
46
+ specify { subject.href.should == URI.parse(@mock_vdc[:href] + "/publicIps") }
47
47
  end
48
48
 
49
49
  describe "#link[2]" do
@@ -51,7 +51,7 @@ describe "Fog::Vcloud, initialized w/ the TMRK Vcloud module", :type => :tmrk_vc
51
51
 
52
52
  it_should_behave_like "all rel=down vcloud links"
53
53
  it_should_behave_like "all vcloud application/xml types"
54
- specify { subject.href.should == @mock_vdc[:href] + "/internetServices" }
54
+ specify { subject.href.should == URI.parse(@mock_vdc[:href] + "/internetServices") }
55
55
  end
56
56
  end
57
57
  describe :networks do
@@ -1,11 +1,3 @@
1
- # Boolean hax
2
- module Fog
3
- module Boolean
4
- end
5
- end
6
- FalseClass.send(:include, Fog::Boolean)
7
- TrueClass.send(:include, Fog::Boolean)
8
-
9
1
  module AWS
10
2
 
11
3
  class << self
@@ -47,11 +47,11 @@ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
47
47
 
48
48
  @address = AWS[:ec2].addresses.create
49
49
 
50
- tests("#describe_addresses('127.0.0.1')").raises(Fog::AWS::EC2::Error) do
50
+ tests("#describe_addresses('127.0.0.1')").raises(Fog::AWS::EC2::NotFound) do
51
51
  AWS[:ec2].describe_addresses('127.0.0.1')
52
52
  end
53
53
 
54
- tests("#associate_addresses('i-00000000', '#{@address.identity}')").raises(Fog::AWS::EC2::Error) do
54
+ tests("#associate_addresses('i-00000000', '#{@address.identity}')").raises(Fog::AWS::EC2::NotFound) do
55
55
  AWS[:ec2].associate_address('i-00000000', @address.identity)
56
56
  end
57
57
 
@@ -59,7 +59,7 @@ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
59
59
  AWS[:ec2].associate_address(@server.identity, '127.0.0.1')
60
60
  end
61
61
 
62
- tests("#associate_addresses('i-00000000', '127.0.0.1')").raises(Fog::AWS::EC2::Error) do
62
+ tests("#associate_addresses('i-00000000', '127.0.0.1')").raises(Fog::AWS::EC2::NotFound) do
63
63
  AWS[:ec2].associate_address('i-00000000', '127.0.0.1')
64
64
  end
65
65
 
@@ -23,8 +23,8 @@ Shindo.tests('AWS::EC2 | availability zone requests', ['aws']) do
23
23
 
24
24
  tests('failure') do
25
25
 
26
- tests("#describe_availability_zones('not-a-zone')").raises(Fog::AWS::EC2::Error) do
27
- AWS[:ec2].describe_availability_zones('not-a-zone')
26
+ tests("#describe_availability_zones('us-east-1e')").raises(Fog::AWS::EC2::Error) do
27
+ AWS[:ec2].describe_availability_zones('us-east-1e')
28
28
  end
29
29
 
30
30
  end
@@ -0,0 +1,122 @@
1
+ Shindo.tests('AWS::EC2 | instance requests', ['aws']) do
2
+
3
+ @instance_format = {
4
+ # 'architecture' => String,
5
+ 'amiLaunchIndex' => Integer,
6
+ 'blockDeviceMapping' => [],
7
+ 'dnsName' => NilClass,
8
+ 'imageId' => String,
9
+ 'instanceId' => String,
10
+ 'instanceState' => {'code' => Integer, 'name' => String},
11
+ 'instanceType' => String,
12
+ # 'ipAddress' => String,
13
+ 'kernelId' => String,
14
+ # 'keyName' => String,
15
+ 'launchTime' => Time,
16
+ 'monitoring' => {'state' => Fog::Boolean},
17
+ 'placement' => {'availabilityZone' => String},
18
+ 'privateDnsName' => NilClass,
19
+ # 'privateIpAddress' => String,
20
+ 'productCodes' => [],
21
+ 'ramdiskId' => String,
22
+ 'reason' => NilClass,
23
+ # 'rootDeviceName' => String,
24
+ 'rootDeviceType' => String
25
+ }
26
+
27
+ @run_instances_format = {
28
+ 'groupSet' => [String],
29
+ 'instancesSet' => [@instance_format],
30
+ 'ownerId' => String,
31
+ 'requestId' => String,
32
+ 'reservationId' => String
33
+ }
34
+
35
+ @describe_instances_format = {
36
+ 'reservationSet' => [{
37
+ 'groupSet' => [String],
38
+ 'instancesSet' => [@instance_format.merge(
39
+ 'architecture' => String,
40
+ 'dnsName' => String,
41
+ 'ipAddress' => String,
42
+ 'privateDnsName' => String,
43
+ 'privateIpAddress' => String
44
+ )],
45
+ 'ownerId' => String,
46
+ 'reservationId' => String
47
+ }],
48
+ 'requestId' => String
49
+ }
50
+
51
+ @get_console_output_format = {
52
+ 'instanceId' => String,
53
+ 'output' => NilClass,
54
+ 'requestId' => String,
55
+ 'timestamp' => Time
56
+ }
57
+
58
+ @terminate_instances_format = {
59
+ 'instancesSet' => [{
60
+ 'currentState' => {'code' => Integer, 'name' => String},
61
+ 'instanceId' => String,
62
+ 'previousState' => {'code' => Integer, 'name' => String},
63
+ }],
64
+ 'requestId' => String
65
+ }
66
+
67
+ tests('success') do
68
+
69
+ @instance_id = nil
70
+
71
+ tests("#run_instances('#{GENTOO_AMI}', 1, 1)").formats(@run_instances_format) do
72
+ data = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body
73
+ @instance_id = data['instancesSet'].first['instanceId']
74
+ data
75
+ end
76
+
77
+ AWS[:ec2].servers.get(@instance_id).wait_for { ready? }
78
+
79
+ # The format changes depending on state of instance, so this would be brittle
80
+ # tests("#describe_instances").formats(@describe_instances_format) do
81
+ # AWS[:ec2].describe_instances.body
82
+ # end
83
+
84
+ tests("#describe_instances('#{@instance_id}')").formats(@describe_instances_format) do
85
+ AWS[:ec2].describe_instances(@instance_id).body
86
+ end
87
+
88
+ tests("#get_console_output('#{@instance_id}')").formats(@get_console_output_format) do
89
+ AWS[:ec2].get_console_output(@instance_id).body
90
+ end
91
+
92
+ tests("#reboot_instances('#{@instance_id}')").formats(AWS::EC2::Formats::BASIC) do
93
+ AWS[:ec2].reboot_instances(@instance_id).body
94
+ end
95
+
96
+ tests("#terminate_instances('#{@instance_id}')").formats(@terminate_instances_format) do
97
+ AWS[:ec2].terminate_instances(@instance_id).body
98
+ end
99
+
100
+ end
101
+
102
+ tests('failure') do
103
+
104
+ tests("#describe_instances('i-00000000')").raises(Fog::AWS::EC2::NotFound) do
105
+ AWS[:ec2].describe_instances('i-00000000')
106
+ end
107
+
108
+ tests("#get_console_output('i-00000000')").raises(Fog::AWS::EC2::NotFound) do
109
+ AWS[:ec2].get_console_output('i-00000000')
110
+ end
111
+
112
+ tests("#reboot_instances('i-00000000')").raises(Fog::AWS::EC2::NotFound) do
113
+ AWS[:ec2].reboot_instances('i-00000000')
114
+ end
115
+
116
+ tests("#terminate_instances('i-00000000')").raises(Fog::AWS::EC2::NotFound) do
117
+ AWS[:ec2].terminate_instances('i-00000000')
118
+ end
119
+
120
+ end
121
+
122
+ end