fog 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/Gemfile +8 -8
  2. data/Gemfile.lock +3 -3
  3. data/bin/fog +2 -10
  4. data/fog.gemspec +45 -20
  5. data/lib/fog.rb +2 -1
  6. data/lib/fog/attributes.rb +48 -8
  7. data/lib/fog/aws/ec2.rb +5 -2
  8. data/lib/fog/aws/elb.rb +5 -2
  9. data/lib/fog/aws/models/ec2/server.rb +1 -1
  10. data/lib/fog/aws/requests/simpledb/put_attributes.rb +43 -12
  11. data/lib/fog/aws/s3.rb +2 -2
  12. data/lib/fog/aws/simpledb.rb +15 -3
  13. data/lib/fog/bin.rb +11 -2
  14. data/lib/fog/bluebox.rb +5 -1
  15. data/lib/fog/connection.rb +9 -1
  16. data/lib/fog/credentials.rb +3 -0
  17. data/lib/fog/new_servers.rb +89 -0
  18. data/lib/fog/new_servers/bin.rb +30 -0
  19. data/lib/fog/new_servers/requests/add_server.rb +39 -0
  20. data/lib/fog/new_servers/requests/cancel_server.rb +36 -0
  21. data/lib/fog/new_servers/requests/get_server.rb +42 -0
  22. data/lib/fog/new_servers/requests/list_images.rb +33 -0
  23. data/lib/fog/new_servers/requests/list_plans.rb +36 -0
  24. data/lib/fog/new_servers/requests/list_servers.rb +43 -0
  25. data/lib/fog/new_servers/requests/reboot_server.rb +30 -0
  26. data/lib/fog/parser.rb +6 -0
  27. data/lib/fog/rackspace/files.rb +8 -2
  28. data/lib/fog/rackspace/models/servers/server.rb +5 -0
  29. data/lib/fog/rackspace/servers.rb +5 -1
  30. data/lib/fog/service.rb +6 -1
  31. data/lib/fog/slicehost.rb +5 -1
  32. data/lib/fog/terremark/ecloud.rb +1 -0
  33. data/lib/fog/terremark/shared.rb +4 -1
  34. data/lib/fog/terremark/vcloud.rb +1 -0
  35. data/lib/fog/vcloud.rb +150 -141
  36. data/lib/fog/vcloud/bin.rb +2 -2
  37. data/lib/fog/vcloud/collection.rb +3 -84
  38. data/lib/fog/vcloud/extension.rb +44 -0
  39. data/lib/fog/vcloud/generators.rb +33 -0
  40. data/lib/fog/vcloud/model.rb +5 -38
  41. data/lib/fog/vcloud/models/vdc.rb +14 -24
  42. data/lib/fog/vcloud/models/vdcs.rb +13 -8
  43. data/lib/fog/vcloud/requests/get_network.rb +4 -11
  44. data/lib/fog/vcloud/requests/get_organization.rb +4 -11
  45. data/lib/fog/vcloud/requests/get_vdc.rb +4 -12
  46. data/lib/fog/vcloud/requests/get_versions.rb +4 -13
  47. data/lib/fog/vcloud/requests/login.rb +4 -4
  48. data/lib/fog/vcloud/terremark/ecloud.rb +125 -54
  49. data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +30 -0
  50. data/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb +31 -0
  51. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +21 -22
  52. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +11 -25
  53. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +38 -5
  54. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +11 -15
  55. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +52 -11
  56. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +14 -13
  57. data/lib/fog/vcloud/terremark/ecloud/models/node.rb +47 -0
  58. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +30 -0
  59. data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +6 -9
  60. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +19 -3
  61. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +203 -0
  62. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +43 -0
  63. data/lib/fog/vcloud/terremark/ecloud/models/task.rb +22 -0
  64. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +30 -0
  65. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +32 -10
  66. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +5 -6
  67. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +23 -10
  68. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +54 -0
  69. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +14 -12
  70. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +53 -0
  71. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +52 -0
  72. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +42 -0
  73. data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +115 -0
  74. data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +4 -23
  75. data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +0 -0
  76. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +19 -0
  77. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +18 -0
  78. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +18 -0
  79. data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +18 -0
  80. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +9 -16
  81. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +8 -14
  82. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +36 -0
  83. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +44 -0
  84. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +11 -12
  85. data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +18 -0
  86. data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +18 -0
  87. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -19
  88. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +5 -12
  89. data/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb +18 -0
  90. data/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb +19 -0
  91. data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +18 -0
  92. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +7 -15
  93. data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +18 -0
  94. data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +18 -0
  95. data/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb +18 -0
  96. data/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb +18 -0
  97. data/lib/fog/vcloud/terremark/vcloud.rb +4 -18
  98. data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +4 -12
  99. data/spec/aws/requests/simpledb/put_attributes_spec.rb +18 -0
  100. data/spec/vcloud/bin_spec.rb +2 -2
  101. data/spec/vcloud/models/vdc_spec.rb +35 -29
  102. data/spec/vcloud/requests/get_network_spec.rb +32 -43
  103. data/spec/vcloud/requests/get_organization_spec.rb +45 -38
  104. data/spec/vcloud/requests/get_vdc_spec.rb +42 -32
  105. data/spec/vcloud/requests/get_versions_spec.rb +17 -17
  106. data/spec/vcloud/requests/login_spec.rb +7 -4
  107. data/spec/vcloud/spec_helper.rb +137 -46
  108. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +53 -58
  109. data/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +20 -20
  110. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +22 -21
  111. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +18 -18
  112. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +55 -51
  113. data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +16 -15
  114. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +26 -27
  115. data/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +16 -15
  116. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +52 -36
  117. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +18 -15
  118. data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +46 -43
  119. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +37 -32
  120. data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +26 -23
  121. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +57 -49
  122. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +41 -0
  123. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +39 -34
  124. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +26 -48
  125. data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +25 -26
  126. data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +35 -27
  127. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +85 -110
  128. data/spec/vcloud/terremark/ecloud/requests/login_spec.rb +7 -4
  129. data/spec/vcloud/vcloud_spec.rb +9 -8
  130. metadata +62 -26
  131. data/lib/fog/vcloud/parser.rb +0 -42
  132. data/lib/fog/vcloud/parsers/get_organization.rb +0 -37
  133. data/lib/fog/vcloud/parsers/get_vdc.rb +0 -62
  134. data/lib/fog/vcloud/parsers/get_versions.rb +0 -46
  135. data/lib/fog/vcloud/parsers/login.rb +0 -36
  136. data/lib/fog/vcloud/parsers/network.rb +0 -53
  137. data/lib/fog/vcloud/terremark/all.rb +0 -9
  138. data/lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb +0 -59
  139. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ip.rb +0 -30
  140. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ips.rb +0 -40
  141. data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +0 -59
  142. data/lib/fog/vcloud/terremark/ecloud/parsers/internet_service.rb +0 -58
  143. data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +0 -28
  144. data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +0 -31
  145. data/lib/fog/vcloud/terremark/ecloud/requests/login.rb +0 -27
  146. data/lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb +0 -34
  147. data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +0 -74
@@ -1,6 +1,21 @@
1
1
  require 'spec'
2
2
  require 'pp'
3
3
 
4
+ module Spec
5
+ module Example
6
+ module Subject
7
+ module ExampleGroupMethods
8
+ def its(attribute, &block)
9
+ describe(attribute) do
10
+ define_method(:subject) { s = super(); s.is_a?(Hash) ? s[attribute] : s.send(attribute) }
11
+ it(&block)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
4
19
  #Initialize this to a known seed
5
20
  srand 1234
6
21
 
@@ -8,15 +23,21 @@ current_directory = File.dirname(__FILE__)
8
23
  require "#{current_directory}/../../lib/fog"
9
24
  require "#{current_directory}/../../lib/fog/bin"
10
25
 
11
- Fog.mock!
26
+ Fog.mock! if ENV['FOG_MOCK']
12
27
 
13
28
  require "#{current_directory}/../../lib/fog/vcloud/bin"
14
29
 
15
- shared_examples_for "all requests" do
30
+ shared_examples_for "all responses" do
16
31
  it { should respond_to :body }
17
32
  it { should respond_to :headers }
18
33
  it { should have_at_least(1).body }
19
34
  it { should have_at_least(0).headers }
35
+ its(:body) { should be_an_instance_of Hash }
36
+ its(:headers) { should be_an_instance_of Hash }
37
+ end
38
+
39
+ shared_examples_for "it has a Content-Type header" do
40
+ its(:headers) { should include "Content-Type" }
20
41
  end
21
42
 
22
43
  shared_examples_for "all rel=down vcloud links" do
@@ -65,31 +86,21 @@ shared_examples_for "all login requests" do
65
86
  before { @login = @vcloud.login }
66
87
  subject { @login }
67
88
 
68
- it_should_behave_like "all requests"
89
+ it_should_behave_like "all responses"
69
90
 
70
91
  its(:headers) { should include "Set-Cookie" }
71
- its(:headers) { should include "Content-Type" }
72
- its(:body) { should be_an_instance_of Struct::VcloudOrgList }
73
-
74
- describe "#body" do
75
- before { @orglist = @login.body }
76
- subject { @orglist }
77
-
78
- its(:xmlns) { should == "http://www.vmware.com/vcloud/v0.8" }
79
92
 
80
- it { should have(1).organizations }
93
+ it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.orgslist+xml" }
81
94
 
82
- describe "#first" do
83
- before { @org = @orglist.organizations.first }
84
- subject { @org }
85
-
86
- it { should be_an_instance_of Struct::VcloudLink }
95
+ describe "#body" do
96
+ subject { @login.body }
87
97
 
88
- its(:href) { should == URI.parse(@mock_organization[:info][:href]) }
89
- its(:name) { should == @mock_organization[:info][:name] }
90
- its(:type) { should == "application/vnd.vmware.vcloud.org+xml" }
98
+ it { should have(4).organizations }
91
99
 
92
- end
100
+ it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
101
+ its(:Org) { should == { :type => "application/vnd.vmware.vcloud.org+xml",
102
+ :href => @mock_organization[:info][:href],
103
+ :name => @mock_organization[:info][:name]} }
93
104
  end
94
105
  end
95
106
  end
@@ -98,6 +109,24 @@ shared_examples_for "it has a vcloud v0.8 xmlns" do
98
109
  its(:xmlns) { should == 'http://www.vmware.com/vcloud/v0.8' }
99
110
  end
100
111
 
112
+ shared_examples_for "it has the proper xmlns_xsi" do
113
+ its(:xmlns_xsi) { should == "http://www.w3.org/2001/XMLSchema-instance" }
114
+ end
115
+
116
+ shared_examples_for "it has the proper xmlns_xsd" do
117
+ its(:xmlns_xsd) { should == "http://www.w3.org/2001/XMLSchema" }
118
+ end
119
+
120
+ shared_examples_for "it has the standard xmlns attributes" do
121
+ it_should_behave_like "it has the proper xmlns_xsi"
122
+ it_should_behave_like "it has the proper xmlns_xsd"
123
+ end
124
+
125
+ shared_examples_for "it has the standard vcloud v0.8 xmlns attributes" do
126
+ it_should_behave_like "it has a vcloud v0.8 xmlns"
127
+ it_should_behave_like "it has the standard xmlns attributes"
128
+ end
129
+
101
130
  shared_examples_for "a request for a resource that doesn't exist" do
102
131
  it { should raise_error Excon::Errors::Unauthorized }
103
132
  end
@@ -108,12 +137,6 @@ shared_examples_for "a vdc catalog link" do
108
137
  its(:href) { should == URI.parse(@mock_vdc[:href] + "/catalog") }
109
138
  end
110
139
 
111
- shared_examples_for "a tmrk vdc" do
112
- it { should respond_to :links }
113
- it { should respond_to :networks }
114
- it { should respond_to :resource_entities }
115
- end
116
-
117
140
  shared_examples_for "a tmrk network link" do
118
141
  it_should_behave_like "all vcloud links w/o a rel"
119
142
  it_should_behave_like "all vcloud network types"
@@ -163,46 +186,64 @@ shared_examples_for "the mocked tmrk resource entity links" do
163
186
  end
164
187
  end
165
188
 
189
+ Spec::Example::ExampleGroupFactory.register(:mock_vcloud_request, Class.new(Spec::Example::ExampleGroup))
190
+ Spec::Example::ExampleGroupFactory.register(:mock_vcloud_model, Class.new(Spec::Example::ExampleGroup))
191
+ Spec::Example::ExampleGroupFactory.register(:mock_tmrk_ecloud_request, Class.new(Spec::Example::ExampleGroup))
192
+ Spec::Example::ExampleGroupFactory.register(:mock_tmrk_ecloud_model, Class.new(Spec::Example::ExampleGroup))
166
193
  Spec::Example::ExampleGroupFactory.register(:vcloud_request, Class.new(Spec::Example::ExampleGroup))
167
- Spec::Example::ExampleGroupFactory.register(:vcloud_model, Class.new(Spec::Example::ExampleGroup))
168
194
  Spec::Example::ExampleGroupFactory.register(:tmrk_ecloud_request, Class.new(Spec::Example::ExampleGroup))
169
- Spec::Example::ExampleGroupFactory.register(:tmrk_ecloud_model, Class.new(Spec::Example::ExampleGroup))
170
195
  Spec::Example::ExampleGroupFactory.register(:tmrk_vcloud_request, Class.new(Spec::Example::ExampleGroup))
171
196
 
172
197
  Spec::Runner.configure do |config|
173
- config.before(:all) do
174
- @mock_data = Fog::Vcloud::Mock.data
198
+ config.after(:all) do
199
+ Fog::Vcloud::Mock.data_reset
200
+ end
201
+ config.before(:each, :type => :mock_vcloud_model) do
202
+ @vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions")
203
+ end
204
+ config.before(:all, :type => :mock_vcloud_model) do
175
205
  @base_url = Fog::Vcloud::Mock.base_url
206
+ @mock_data = Fog::Vcloud::Mock.data
176
207
  @mock_version = @mock_data[:versions][0]
177
208
  @mock_organization = @mock_data[:organizations][0]
178
209
  @mock_vdc = @mock_organization[:vdcs][0]
179
210
  @mock_network = @mock_vdc[:networks][0]
180
211
  end
181
- config.after(:all) do
182
- Fog::Vcloud::Mock.data_reset
212
+ config.before(:all, :type => :mock_vcloud_request) do
213
+ @mock_data = Fog::Vcloud::Mock.data
214
+ @base_url = Fog::Vcloud::Mock.base_url
215
+ @mock_version = @mock_data[:versions][0]
216
+ @mock_organization = @mock_data[:organizations][0]
217
+ @mock_vdc = @mock_organization[:vdcs][0]
218
+ @mock_network = @mock_vdc[:networks][0]
183
219
  end
184
- config.before(:each, :type => :vcloud_model) do
185
- @vcloud = Fog::Vcloud.new
220
+ config.before(:each, :type => :mock_vcloud_request) do
221
+ @vcloud = Fog::Vcloud.new(:username => "", :password => "bar", :versions_uri => "http://fakey.com/api/versions")
186
222
  end
187
- config.before(:each, :type => :vcloud_request) do
188
- @vcloud = Fog::Vcloud.new
223
+ config.before(:each, :type => :mock_tmrk_ecloud_request) do
224
+ @vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
189
225
  end
190
- config.before(:all, :type => :tmrk_ecloud_request) do
226
+ config.before(:all, :type => :mock_tmrk_ecloud_request) do
191
227
  @base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url
192
228
  @mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data
229
+ @mock_version = @mock_data[:versions][0]
230
+ @mock_organization = @mock_data[:organizations][0]
231
+ @mock_vdc = @mock_organization[:vdcs][0]
232
+ @mock_network = @mock_vdc[:networks][0]
193
233
  end
194
- config.before(:each, :type => :tmrk_ecloud_request) do
195
- @vcloud = Fog::Vcloud.new(:module => "Fog::Vcloud::Terremark::Ecloud")
234
+ config.after(:all, :type => :mock_tmrk_ecloud_request) do
235
+ Fog::Vcloud::Terremark::Ecloud::Mock.data_reset
196
236
  end
197
- config.before(:all, :type => :tmrk_ecloud_model) do
237
+ config.before(:all, :type => :mock_tmrk_ecloud_model) do
198
238
  @base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url
199
239
  @mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data
240
+ @mock_version = @mock_data[:versions][0]
241
+ @mock_organization = @mock_data[:organizations][0]
242
+ @mock_vdc = @mock_organization[:vdcs][0]
243
+ @mock_network = @mock_vdc[:networks][0]
200
244
  end
201
- config.before(:each, :type => :tmrk_ecloud_model) do
202
- @vcloud = Fog::Vcloud.new(:module => "Fog::Vcloud::Terremark::Ecloud")
203
- end
204
- config.before(:each, :type => :tmrk_vcloud_request) do
205
- @vcloud = Fog::Vcloud.new(:module => "Fog::Vcloud::Terremark::Vcloud")
245
+ config.before(:each, :type => :mock_tmrk_ecloud_model) do
246
+ @vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
206
247
  end
207
248
  end
208
249
 
@@ -234,3 +275,53 @@ Spec::Matchers.define :have_members_of_the_right_model do
234
275
  actual.all? { |member| member.is_a?(actual.model) }
235
276
  end
236
277
  end
278
+
279
+ Spec::Matchers.define :have_key_with_value do |expected_key, expected_value|
280
+ match do |actual|
281
+ actual.has_key?(expected_key) && actual[expected_key] == expected_value
282
+ end
283
+ end
284
+
285
+ Spec::Matchers.define :have_key_with_array do |expected_key, expected_array|
286
+ match do |actual|
287
+ actual[expected_key].all? { |item| expected_array.include?(item) } && actual[expected_key].length == expected_array.length
288
+ end
289
+ end
290
+
291
+ Spec::Matchers.define :have_headers_denoting_a_content_type_of do |expected|
292
+ match do |actual|
293
+ actual.headers["Content-Type"] == expected
294
+ end
295
+ end
296
+
297
+ Spec::Matchers.define :have_keys_with_values do |expected|
298
+ match do |actual|
299
+ actual.each_pair.all? do |key, value|
300
+ expected.keys.include?(key) && expected[key] == value
301
+ end
302
+ end
303
+ end
304
+
305
+ Spec::Matchers.define :be_a_vapp_link_to do |expected|
306
+ match do |actual|
307
+ actual.is_a?(Hash) and
308
+ actual[:type] == "application/vnd.vmware.vcloud.vApp+xml" and
309
+ actual[:href] == expected[:href] and
310
+ actual[:name] == expected[:name]
311
+ end
312
+ end
313
+
314
+ Spec::Matchers.define :be_a_network_link_to do |expected|
315
+ match do |actual|
316
+ actual.is_a?(Hash) and
317
+ actual[:type] == "application/vnd.vmware.vcloud.network+xml" and
318
+ actual[:href] == expected[:href] and
319
+ actual[:name] == expected[:name]
320
+ end
321
+ end
322
+
323
+ Spec::Matchers.define :have_all_attributes_be_nil do
324
+ match do |actual|
325
+ actual.class.attributes.all? { |attribute| actual.send(attribute.to_sym) == nil }
326
+ end
327
+ end
@@ -1,73 +1,68 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::InternetService", :type => :tmrk_ecloud_model do
4
- before do
5
- @mock_ip = @mock_vdc[:public_ips].first
6
- @mock_service = @mock_ip[:services].first
7
- @mock_service_uri = URI.parse("#{@base_url}/extensions/internetService/#{@mock_service[:id]}")
8
- end
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::InternetService", :type => :mock_tmrk_ecloud_model do
5
+ before do
6
+ @mock_ip = @mock_vdc[:public_ips].first
7
+ @mock_service = @mock_ip[:services].first
8
+ @mock_service_uri = "#{@base_url}/extensions/internetService/#{@mock_service[:id]}"
9
+ end
9
10
 
10
- subject { @vcloud.vdcs[0].public_ips[0].internet_services[0] }
11
+ subject { @vcloud.vdcs[0].public_ips[0].internet_services[0] }
11
12
 
12
- describe :class do
13
- subject { Fog::Vcloud::Terremark::Ecloud::InternetService }
13
+ describe :class do
14
+ subject { Fog::Vcloud::Terremark::Ecloud::InternetService }
14
15
 
15
- it { should have_identity :href }
16
- it { should have_only_these_attributes [:href, :name, :id, :type, :protocol, :port, :enabled, :description, :public_ip, :timeout, :url_send_string, :http_header] }
17
- end
16
+ it { should have_identity :href }
17
+ it { should have_only_these_attributes [:href, :name, :id, :protocol, :port, :enabled, :description, :public_ip, :timeout, :redirect_url, :monitor] }
18
+ end
18
19
 
19
- context "with no uri" do
20
+ context "with no uri" do
20
21
 
21
- subject { Fog::Vcloud::Terremark::Ecloud::InternetService.new() }
22
+ subject { Fog::Vcloud::Terremark::Ecloud::InternetService.new() }
23
+ it { should have_all_attributes_be_nil }
22
24
 
23
- its(:href) { should be_nil }
24
- its(:identity) { should be_nil }
25
- its(:name) { should be_nil }
26
- its(:type) { should be_nil }
27
- its(:id) { should be_nil }
28
- its(:protocol) { should be_nil }
29
- its(:port) { should be_nil }
30
- its(:enabled) { should be_nil }
31
- its(:description) { should be_nil }
32
- its(:public_ip) { should be_nil }
33
- its(:timeout) { should be_nil }
34
- its(:url_send_string) { should be_nil }
35
- its(:http_header) { should be_nil }
36
- end
25
+ end
37
26
 
38
- context "as a collection member" do
39
- subject { @vcloud.vdcs[0].public_ips[0].internet_services[0] }
40
- let(:public_ip) { @vcloud.get_public_ip(@vcloud.vdcs[0].public_ips[0].internet_services[0].public_ip.href).body }
41
- let(:composed_public_ip_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_ip_data) }
42
- let(:composed_service_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_service_data) }
27
+ context "as a collection member" do
28
+ subject { @vcloud.vdcs[0].public_ips[0].internet_services[0].reload; @vcloud.vdcs[0].public_ips[0].internet_services[0] }
29
+
30
+ let(:public_ip) {
31
+ pip = @vcloud.get_public_ip(@vcloud.vdcs[0].public_ips[0].internet_services[0].public_ip[:Href]).body
32
+ pip.delete_if{ |k,v| [:xmlns, :xmlns_i].include?(k)}
33
+ pip
34
+ }
35
+ let(:composed_public_ip_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_ip_data) }
36
+ let(:composed_service_data) { @vcloud.vdcs[0].public_ips[0].internet_services[0].send(:_compose_service_data) }
43
37
 
44
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::InternetService }
38
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::InternetService }
45
39
 
46
- its(:href) { should == @mock_service_uri }
47
- its(:identity) { should == @mock_service_uri }
48
- its(:name) { should == @mock_service[:name] }
49
- its(:id) { should == @mock_service[:id] }
50
- its(:type) { should == "application/vnd.tmrk.ecloud.internetService+xml" }
51
- its(:protocol) { should == "HTTP" }
52
- its(:port) { should == 80 }
53
- its(:enabled) { should == true }
54
- its(:description) { should == "Web Servers" }
55
- its(:public_ip) { should == public_ip }
56
- its(:timeout) { should == 2 }
57
- its(:url_send_string) { should == nil }
58
- its(:http_header) { should == nil }
40
+ its(:href) { should == @mock_service_uri }
41
+ its(:identity) { should == @mock_service_uri }
42
+ its(:name) { should == @mock_service[:name] }
43
+ its(:id) { should == @mock_service[:id] }
44
+ its(:protocol) { should == "HTTP" }
45
+ its(:port) { should == "80" }
46
+ its(:enabled) { should == "true" }
47
+ its(:description) { should == "Web Servers" }
48
+ its(:public_ip) { should == public_ip }
49
+ its(:timeout) { should == "2" }
50
+ its(:redirect_url) { should == "" }
51
+ its(:monitor) { should == "" }
59
52
 
60
- specify { composed_public_ip_data[:href].should == public_ip.href.to_s }
61
- specify { composed_public_ip_data[:name].should == public_ip.name }
62
- specify { composed_public_ip_data[:id].should == public_ip.id }
53
+ specify { composed_public_ip_data[:href].should == public_ip[:Href].to_s }
54
+ specify { composed_public_ip_data[:name].should == public_ip[:Name] }
55
+ specify { composed_public_ip_data[:id].should == public_ip[:Id] }
63
56
 
64
- specify { composed_service_data[:href].should == subject.href.to_s }
65
- specify { composed_service_data[:name].should == subject.name }
66
- specify { composed_service_data[:id].should == subject.id.to_s }
67
- specify { composed_service_data[:protocol].should == subject.protocol }
68
- specify { composed_service_data[:port].should == subject.port.to_s }
69
- specify { composed_service_data[:enabled].should == subject.enabled.to_s }
70
- specify { composed_service_data[:description].should == subject.description }
71
- specify { composed_service_data[:timeout].should == subject.timeout.to_s }
57
+ specify { composed_service_data[:href].should == subject.href.to_s }
58
+ specify { composed_service_data[:name].should == subject.name }
59
+ specify { composed_service_data[:id].should == subject.id.to_s }
60
+ specify { composed_service_data[:protocol].should == subject.protocol }
61
+ specify { composed_service_data[:port].should == subject.port.to_s }
62
+ specify { composed_service_data[:enabled].should == subject.enabled.to_s }
63
+ specify { composed_service_data[:description].should == subject.description }
64
+ specify { composed_service_data[:timeout].should == subject.timeout.to_s }
65
+ end
72
66
  end
67
+ else
73
68
  end
@@ -1,29 +1,29 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::InternetServices", :type => :tmrk_ecloud_model do
4
- context "as an attribute of a VDC" do
5
- subject { @vcloud.vdcs[0] }
6
-
7
- it { should respond_to :internet_services }
8
-
9
- describe :class do
10
- subject { @vcloud.vdcs[0].internet_services.class }
11
- its(:model) { should == Fog::Vcloud::Terremark::Ecloud::InternetService }
12
- its(:get_request) { should == nil }
13
- its(:all_request) { should be_an_instance_of Proc }
14
- its(:vcloud_type) { should == "application/vnd.tmrk.ecloud.internetService+xml" }
15
- end
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::InternetServices", :type => :mock_tmrk_ecloud_model do
5
+ context "as an attribute of a VDC" do
6
+ subject { @vcloud.vdcs[0] }
7
+
8
+ it { should respond_to :internet_services }
9
+
10
+ describe :class do
11
+ subject { @vcloud.vdcs[0].internet_services.class }
12
+ its(:model) { should == Fog::Vcloud::Terremark::Ecloud::InternetService }
13
+ end
16
14
 
17
- describe :internet_services do
18
- subject { @vcloud.vdcs[0].internet_services }
15
+ describe :internet_services do
16
+ subject { @vcloud.vdcs[0].internet_services }
19
17
 
20
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::InternetServices }
18
+ it { should respond_to :create }
21
19
 
22
- its(:length) { should == 4 }
20
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::InternetServices }
23
21
 
24
- it { should have_members_of_the_right_model }
22
+ its(:length) { should == 4 }
23
+
24
+ it { should have_members_of_the_right_model }
25
+ end
25
26
  end
26
27
  end
28
+ else
27
29
  end
28
-
29
-
@@ -1,35 +1,36 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::Ip", :type => :tmrk_ecloud_model do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::Ip", :type => :mock_tmrk_ecloud_model do
5
+ subject { @vcloud }
5
6
 
6
- describe :class do
7
- subject { Fog::Vcloud::Terremark::Ecloud::Ip }
7
+ describe :class do
8
+ subject { Fog::Vcloud::Terremark::Ecloud::Ip }
8
9
 
9
- it { should have_identity :name }
10
- it { should have_only_these_attributes [:name, :status, :server] }
11
- end
10
+ it { should have_identity :href }
11
+ it { should have_only_these_attributes [:href, :name, :status, :server, :rnat, :id] }
12
+ end
12
13
 
13
- context "with no uri" do
14
+ context "with no uri" do
14
15
 
15
- subject { Fog::Vcloud::Terremark::Ecloud::Ip.new() }
16
+ subject { Fog::Vcloud::Terremark::Ecloud::Ip.new() }
17
+ it { should have_all_attributes_be_nil }
16
18
 
17
- its(:name) { should be_nil }
18
- its(:status) { should be_nil }
19
- its(:server) { should be_nil }
20
- end
19
+ end
21
20
 
22
- context "as a collection member" do
23
- subject { @vcloud.vdcs[0].networks[0].ips[0] }
24
- let(:status) { @mock_network[:ips].keys.include?(@vcloud.vdcs[0].networks[0].ips[0].name) ? "Assigned" : nil }
25
- let(:server) { @mock_network[:ips][@vcloud.vdcs[0].networks[0].ips[0].name] }
21
+ context "as a collection member" do
22
+ subject { @vcloud.vdcs[0].networks[0].ips[0].reload; @vcloud.vdcs[0].networks[0].ips[0] }
23
+ let(:status) { @mock_network[:ips].keys.include?(@vcloud.vdcs[0].networks[0].ips[0].name) ? "Assigned" : nil }
24
+ let(:server) { @mock_network[:ips][@vcloud.vdcs[0].networks[0].ips[0].name] }
26
25
 
27
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Ip }
26
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Ip }
28
27
 
29
- its(:name) { should == IPAddr.new(@mock_network[:name]).to_range.to_a[3].to_s }
30
- its(:status) { should == status }
31
- its(:server) { should == server }
28
+ its(:name) { should == IPAddr.new(@mock_network[:name]).to_range.to_a[3].to_s }
29
+ its(:status) { should == status }
30
+ its(:server) { should == server }
32
31
 
32
+ end
33
33
  end
34
+ else
34
35
  end
35
36