fog 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/fog.gemspec +9 -2
- data/lib/fog.rb +1 -1
- data/lib/fog/vcloud.rb +9 -5
- data/lib/fog/vcloud/model.rb +2 -1
- data/lib/fog/vcloud/terremark/ecloud.rb +30 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +2 -18
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +11 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +3 -3
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +12 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +14 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +10 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +28 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +27 -1
- data/spec/vcloud/spec_helper.rb +26 -23
- data/spec/vcloud/terremark/ecloud/models/node_spec.rb +38 -0
- data/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +29 -0
- data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +7 -5
- data/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +52 -0
- data/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +58 -0
- data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +20 -21
- data/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +34 -0
- data/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +41 -0
- data/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +58 -0
- metadata +10 -3
data/fog.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.2.
|
11
|
-
s.date = '2010-06-
|
10
|
+
s.version = '0.2.7'
|
11
|
+
s.date = '2010-06-30'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
@@ -528,17 +528,24 @@ Gem::Specification.new do |s|
|
|
528
528
|
spec/vcloud/terremark/ecloud/models/ips_spec.rb
|
529
529
|
spec/vcloud/terremark/ecloud/models/network_spec.rb
|
530
530
|
spec/vcloud/terremark/ecloud/models/networks_spec.rb
|
531
|
+
spec/vcloud/terremark/ecloud/models/node_spec.rb
|
532
|
+
spec/vcloud/terremark/ecloud/models/nodes_spec.rb
|
531
533
|
spec/vcloud/terremark/ecloud/models/public_ip_spec.rb
|
532
534
|
spec/vcloud/terremark/ecloud/models/public_ips_spec.rb
|
533
535
|
spec/vcloud/terremark/ecloud/models/vdc_spec.rb
|
534
536
|
spec/vcloud/terremark/ecloud/models/vdcs_spec.rb
|
535
537
|
spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb
|
538
|
+
spec/vcloud/terremark/ecloud/requests/add_node_spec.rb
|
536
539
|
spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb
|
540
|
+
spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb
|
537
541
|
spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb
|
542
|
+
spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb
|
538
543
|
spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb
|
539
544
|
spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb
|
540
545
|
spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb
|
541
546
|
spec/vcloud/terremark/ecloud/requests/get_network_spec.rb
|
547
|
+
spec/vcloud/terremark/ecloud/requests/get_node_spec.rb
|
548
|
+
spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb
|
542
549
|
spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb
|
543
550
|
spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb
|
544
551
|
spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb
|
data/lib/fog.rb
CHANGED
data/lib/fog/vcloud.rb
CHANGED
@@ -353,11 +353,15 @@ module Fog
|
|
353
353
|
response = Excon::Response.new
|
354
354
|
|
355
355
|
#Parse the response body into a hash
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
356
|
+
if mock_data.empty?
|
357
|
+
response.body = mock_data
|
358
|
+
else
|
359
|
+
document = Fog::ToHashDocument.new
|
360
|
+
parser = Nokogiri::XML::SAX::PushParser.new(document)
|
361
|
+
parser << mock_data
|
362
|
+
parser.finish
|
363
|
+
response.body = document.body
|
364
|
+
end
|
361
365
|
|
362
366
|
response.status = status
|
363
367
|
response.headers = mock_headers
|
data/lib/fog/vcloud/model.rb
CHANGED
@@ -86,11 +86,15 @@ module Fog
|
|
86
86
|
:services => [
|
87
87
|
{ :id => "71", :href => extension_url + "/internetService/71", :port => "80", :protocol => 'HTTP', :enabled => "true",
|
88
88
|
:timeout => "2", :name => 'Web Site', :description => 'Web Servers', :redirect_url => 'http://fakey.com',
|
89
|
-
:nodes => [ {:
|
89
|
+
:nodes => [ {:id => "81", :href => extension_url + "/nodeService/81", :ip_address => "1.2.3.5",
|
90
|
+
:name => "Test Node 1", :port => "80", :enabled => "true", :description => "web 1" },
|
91
|
+
{:id => "82", :href => extension_url + "/nodeService/82", :ip_address => "1.2.3.6",
|
92
|
+
:name => "Test Node 2", :port => "80", :enabled => "true", :description => "web 2" },
|
90
93
|
] },
|
91
94
|
{ :id => "72", :href => extension_url + "/internetService/72", :port => "7000", :protocol => 'HTTP', :enabled => "true",
|
92
95
|
:timeout => "2", :name => 'An SSH Map', :description => 'SSH 1', :redirect_url => '',
|
93
|
-
:nodes => [ {:
|
96
|
+
:nodes => [ {:id => "83", :href => extension_url + "/nodeService/83", :ip_address => "1.2.3.5",
|
97
|
+
:name => "SSH", :port => "22", :enabled => "true", :description => "web ssh" }
|
94
98
|
] }
|
95
99
|
]
|
96
100
|
},
|
@@ -149,6 +153,30 @@ module Fog
|
|
149
153
|
{ :xmlns => "urn:tmrk:eCloudExtensions-2.3", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" }
|
150
154
|
end
|
151
155
|
|
156
|
+
def mock_ip_from_service_url(uri)
|
157
|
+
mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.compact.detect { |pip| pip[:services].detect { |service| service[:href] == uri } }
|
158
|
+
end
|
159
|
+
|
160
|
+
def mock_ip_and_service_from_service_url(uri)
|
161
|
+
if ip = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.compact.detect { |pip| pip[:services].detect { |service| service[:href] == uri } }
|
162
|
+
if service = ip[:services].detect { |service| service[:href] == uri }
|
163
|
+
[ip, service]
|
164
|
+
else
|
165
|
+
[ip, nil]
|
166
|
+
end
|
167
|
+
else
|
168
|
+
[nil, nil]
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def mock_node_from_url(uri)
|
173
|
+
mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.map { |pip| pip[:services] }.flatten.map { |service| service[:nodes] }.flatten.detect { |node| node[:href] == uri }
|
174
|
+
end
|
175
|
+
|
176
|
+
def mock_service_from_node_url(uri)
|
177
|
+
mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.map { |pip| pip[:services] }.flatten.map { |service| service }.detect {|service| service[:nodes].map { |node| node[:href] }.include?(uri) }
|
178
|
+
end
|
179
|
+
|
152
180
|
def mock_data
|
153
181
|
Fog::Vcloud::Terremark::Ecloud::Mock.data
|
154
182
|
end
|
@@ -66,25 +66,9 @@ module Fog
|
|
66
66
|
internet_services_uri = ensure_unparsed(internet_services_uri)
|
67
67
|
|
68
68
|
if ip = ip_from_uri(internet_services_uri)
|
69
|
-
new_service = service_data.merge!( { :id =>
|
69
|
+
new_service = service_data.merge!( { :href => Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href( { :id => rand(1000) } ), :timeout => 2 } )
|
70
70
|
ip[:services] << new_service
|
71
|
-
|
72
|
-
xml = builder.InternetService(:xmlns => "urn:tmrk:eCloudExtensions-2.0",
|
73
|
-
:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") {
|
74
|
-
builder.Id(new_service[:id])
|
75
|
-
builder.Href(Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href(new_service))
|
76
|
-
builder.Name(new_service[:name])
|
77
|
-
builder.PublicIpAddress {
|
78
|
-
builder.Id(ip[:id])
|
79
|
-
builder.Href(Fog::Vcloud::Terremark::Ecloud::Mock.public_ip_href(ip))
|
80
|
-
builder.Name(ip[:name])
|
81
|
-
}
|
82
|
-
builder.Protocol(new_service[:protocol])
|
83
|
-
builder.Port(new_service[:port])
|
84
|
-
builder.Enabled(new_service[:enabled])
|
85
|
-
builder.Description(new_service[:description])
|
86
|
-
builder.Timeout(new_service[:timeout])
|
87
|
-
}
|
71
|
+
xml = generate_internet_service_response( service_data, ip )
|
88
72
|
|
89
73
|
mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}
|
90
74
|
else
|
@@ -46,7 +46,17 @@ module Fog
|
|
46
46
|
module Mock
|
47
47
|
|
48
48
|
def add_node(nodes_uri, node_data)
|
49
|
-
|
49
|
+
validate_node_data(node_data)
|
50
|
+
nodes_uri = ensure_unparsed(nodes_uri)
|
51
|
+
service_uri = nodes_uri.gsub('/nodeServices','')
|
52
|
+
ip, service = mock_ip_and_service_from_service_url(service_uri)
|
53
|
+
if ip and service
|
54
|
+
id = rand(1000)
|
55
|
+
service[:nodes] << node_data.merge!( :id => id.to_s, :href => Fog::Vcloud::Terremark::Ecloud::Mock.extension_url + "/nodeService/#{id}" )
|
56
|
+
mock_it 200, mock_node_service_response(node_data, ecloud_xmlns), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' }
|
57
|
+
else
|
58
|
+
mock_error 200, "401 Unauthorized"
|
59
|
+
end
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|
@@ -4,7 +4,7 @@ module Fog
|
|
4
4
|
module Ecloud
|
5
5
|
module Real
|
6
6
|
|
7
|
-
def
|
7
|
+
def generate_internet_service_response(service_data,ip_address_data)
|
8
8
|
builder = Builder::XmlMarkup.new
|
9
9
|
builder.InternetService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance",
|
10
10
|
:xmlns => "urn:tmrk:eCloudExtensions-2.3") {
|
@@ -38,7 +38,7 @@ module Fog
|
|
38
38
|
validate_public_ip_address_data(ip_address_data)
|
39
39
|
|
40
40
|
request(
|
41
|
-
:body =>
|
41
|
+
:body => generate_internet_service_response(service_data, ip_address_data),
|
42
42
|
:expects => 200,
|
43
43
|
:headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
|
44
44
|
:method => 'PUT',
|
@@ -67,7 +67,7 @@ module Fog
|
|
67
67
|
if ip = ip_from_uri(ip_address_data[:href])
|
68
68
|
if service = ip[:services].detect { |service| service[:id] == internet_service_uri.split('/')[-1] }
|
69
69
|
ip[:services][ip[:services].index(service)] = service_data
|
70
|
-
xml =
|
70
|
+
xml = generate_internet_service_response(service_data, ip)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -34,7 +34,18 @@ module Fog
|
|
34
34
|
module Mock
|
35
35
|
|
36
36
|
def configure_node(node_uri, node_data)
|
37
|
-
|
37
|
+
node_uri = ensure_unparsed(node_uri)
|
38
|
+
|
39
|
+
validate_node_data(node_data, true)
|
40
|
+
|
41
|
+
if node = mock_node_from_url(node_uri)
|
42
|
+
node[:name] = node_data[:name]
|
43
|
+
node[:enabled] = node_data[:enabled]
|
44
|
+
node[:description] = node_data[:description]
|
45
|
+
mock_it 200, mock_node_service_response(node, ecloud_xmlns), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' }
|
46
|
+
else
|
47
|
+
mock_error 200, "401 Unauthorized"
|
48
|
+
end
|
38
49
|
end
|
39
50
|
end
|
40
51
|
end
|
@@ -10,7 +10,20 @@ module Fog
|
|
10
10
|
module Mock
|
11
11
|
|
12
12
|
def delete_internet_service(service_uri)
|
13
|
-
|
13
|
+
|
14
|
+
deleted = false
|
15
|
+
if ip = mock_ip_from_service_url(service_uri)
|
16
|
+
if service = ip[:services].detect { |service| service[:href] == service_uri }
|
17
|
+
ip[:services].delete(service)
|
18
|
+
deleted = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if deleted
|
23
|
+
mock_it 200, '', { }
|
24
|
+
else
|
25
|
+
mock_error 200, "401 Unauthorized"
|
26
|
+
end
|
14
27
|
end
|
15
28
|
end
|
16
29
|
end
|
@@ -10,7 +10,16 @@ module Fog
|
|
10
10
|
module Mock
|
11
11
|
|
12
12
|
def delete_node(node_uri)
|
13
|
-
|
13
|
+
node_uri = ensure_unparsed(node_uri)
|
14
|
+
|
15
|
+
node = mock_node_from_url(node_uri)
|
16
|
+
service = mock_service_from_node_url(node_uri)
|
17
|
+
if node and service
|
18
|
+
service[:nodes].delete(node)
|
19
|
+
mock_it 200, '', {}
|
20
|
+
else
|
21
|
+
mock_error 200, "401 Unauthorized"
|
22
|
+
end
|
14
23
|
end
|
15
24
|
end
|
16
25
|
end
|
@@ -8,8 +8,35 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module Mock
|
11
|
+
|
12
|
+
#
|
13
|
+
# Based on http://support.theenterprisecloud.com/kb/default.asp?id=641&Lang=1&SID=
|
14
|
+
#
|
15
|
+
#
|
16
|
+
#
|
17
|
+
def mock_node_service_response(node, xmlns)
|
18
|
+
xml = Builder::XmlMarkup.new
|
19
|
+
xml.NodeService(xmlns) {
|
20
|
+
xml.Id(node[:id])
|
21
|
+
xml.Href(node[:href])
|
22
|
+
xml.Name(node[:name])
|
23
|
+
xml.IpAddress(node[:ip_address])
|
24
|
+
xml.Port(node[:port])
|
25
|
+
xml.Enabled(node[:enabled])
|
26
|
+
xml.Description(node[:description])
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
11
30
|
def get_node(node_uri)
|
12
|
-
|
31
|
+
|
32
|
+
node_uri = ensure_unparsed(node_uri)
|
33
|
+
|
34
|
+
if node = mock_node_from_url(node_uri)
|
35
|
+
xml = Builder::XmlMarkup.new
|
36
|
+
mock_it 200, mock_node_service_response(node, ecloud_xmlns), { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' }
|
37
|
+
else
|
38
|
+
mock_error 200, "401 Unauthorized"
|
39
|
+
end
|
13
40
|
end
|
14
41
|
end
|
15
42
|
end
|
@@ -8,8 +8,34 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module Mock
|
11
|
+
|
12
|
+
#
|
13
|
+
# Based off of:
|
14
|
+
# http://support.theenterprisecloud.com/kb/default.asp?id=637&Lang=1&SID=
|
15
|
+
#
|
11
16
|
def get_nodes(nodes_uri)
|
12
|
-
|
17
|
+
nodes_uri = ensure_unparsed(nodes_uri)
|
18
|
+
service_uri = nodes_uri.gsub('/nodeServices','')
|
19
|
+
ip, service = mock_ip_and_service_from_service_url(service_uri)
|
20
|
+
if ip and service
|
21
|
+
xml = Builder::XmlMarkup.new
|
22
|
+
mock_it 200,
|
23
|
+
xml.NodeServices(ecloud_xmlns) {
|
24
|
+
service[:nodes].each do |node|
|
25
|
+
xml.NodeService {
|
26
|
+
xml.Id(node[:id])
|
27
|
+
xml.Href(node[:href])
|
28
|
+
xml.Name(node[:name])
|
29
|
+
xml.IpAddress(node[:ip_address])
|
30
|
+
xml.Port(node[:port])
|
31
|
+
xml.Enabled(node[:enabled])
|
32
|
+
xml.Description(node[:description])
|
33
|
+
}
|
34
|
+
end
|
35
|
+
}, { 'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml' }
|
36
|
+
else
|
37
|
+
mock_error 200, "401 Unauthorized"
|
38
|
+
end
|
13
39
|
end
|
14
40
|
end
|
15
41
|
end
|
data/spec/vcloud/spec_helper.rb
CHANGED
@@ -28,6 +28,7 @@ Fog.mock! if ENV['FOG_MOCK']
|
|
28
28
|
require "#{current_directory}/../../lib/fog/vcloud/bin"
|
29
29
|
|
30
30
|
shared_examples_for "all responses" do
|
31
|
+
it { should be_an_instance_of Excon::Response }
|
31
32
|
it { should respond_to :body }
|
32
33
|
it { should respond_to :headers }
|
33
34
|
it { should have_at_least(1).body }
|
@@ -36,6 +37,13 @@ shared_examples_for "all responses" do
|
|
36
37
|
its(:headers) { should be_an_instance_of Hash }
|
37
38
|
end
|
38
39
|
|
40
|
+
shared_examples_for "all delete responses" do
|
41
|
+
it { should be_an_instance_of Excon::Response }
|
42
|
+
it { should respond_to :body }
|
43
|
+
it { should respond_to :headers }
|
44
|
+
its(:headers) { should be_an_instance_of Hash }
|
45
|
+
end
|
46
|
+
|
39
47
|
shared_examples_for "it has a Content-Type header" do
|
40
48
|
its(:headers) { should include "Content-Type" }
|
41
49
|
end
|
@@ -194,6 +202,18 @@ Spec::Example::ExampleGroupFactory.register(:vcloud_request, Class.new(Spec::Exa
|
|
194
202
|
Spec::Example::ExampleGroupFactory.register(:tmrk_ecloud_request, Class.new(Spec::Example::ExampleGroup))
|
195
203
|
Spec::Example::ExampleGroupFactory.register(:tmrk_vcloud_request, Class.new(Spec::Example::ExampleGroup))
|
196
204
|
|
205
|
+
def setup_ecloud_mock_data
|
206
|
+
@base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url
|
207
|
+
@mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data
|
208
|
+
@mock_version = @mock_data[:versions].first
|
209
|
+
@mock_organization = @mock_data[:organizations].first
|
210
|
+
@mock_vdc = @mock_organization[:vdcs].first
|
211
|
+
@mock_public_ip = @mock_vdc[:public_ips].first
|
212
|
+
@mock_service = @mock_public_ip[:services].first
|
213
|
+
@mock_node = @mock_service[:nodes].first
|
214
|
+
@mock_network = @mock_vdc[:networks].first
|
215
|
+
end
|
216
|
+
|
197
217
|
Spec::Runner.configure do |config|
|
198
218
|
config.after(:all) do
|
199
219
|
Fog::Vcloud::Mock.data_reset
|
@@ -221,32 +241,15 @@ Spec::Runner.configure do |config|
|
|
221
241
|
@vcloud = Fog::Vcloud.new(:username => "", :password => "bar", :versions_uri => "http://fakey.com/api/versions")
|
222
242
|
end
|
223
243
|
config.before(:each, :type => :mock_tmrk_ecloud_request) do
|
224
|
-
|
225
|
-
end
|
226
|
-
config.before(:all, :type => :mock_tmrk_ecloud_request) do
|
227
|
-
@base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url
|
228
|
-
@mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data
|
229
|
-
@mock_version = @mock_data[:versions].first
|
230
|
-
@mock_organization = @mock_data[:organizations].first
|
231
|
-
@mock_vdc = @mock_organization[:vdcs].first
|
232
|
-
@mock_public_ip = @mock_vdc[:public_ips].first
|
233
|
-
@mock_service = @mock_public_ip[:services].first
|
234
|
-
@mock_network = @mock_vdc[:networks].first
|
235
|
-
end
|
236
|
-
config.after(:all, :type => :mock_tmrk_ecloud_request) do
|
244
|
+
Fog::Vcloud::Mock.data_reset
|
237
245
|
Fog::Vcloud::Terremark::Ecloud::Mock.data_reset
|
238
|
-
|
239
|
-
|
240
|
-
@base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url
|
241
|
-
@mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data
|
242
|
-
@mock_version = @mock_data[:versions].first
|
243
|
-
@mock_organization = @mock_data[:organizations].first
|
244
|
-
@mock_vdc = @mock_organization[:vdcs].first
|
245
|
-
@mock_public_ip = @mock_vdc[:public_ips].first
|
246
|
-
@mock_service = @mock_public_ip[:services].first
|
247
|
-
@mock_network = @mock_vdc[:networks].first
|
246
|
+
setup_ecloud_mock_data
|
247
|
+
@vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
|
248
248
|
end
|
249
249
|
config.before(:each, :type => :mock_tmrk_ecloud_model) do
|
250
|
+
Fog::Vcloud::Mock.data_reset
|
251
|
+
Fog::Vcloud::Terremark::Ecloud::Mock.data_reset
|
252
|
+
setup_ecloud_mock_data
|
250
253
|
@vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
|
251
254
|
end
|
252
255
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe "Fog::Vcloud::Terremark::Ecloud::Node", :type => :mock_tmrk_ecloud_model do
|
5
|
+
|
6
|
+
subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.first }
|
7
|
+
|
8
|
+
describe :class do
|
9
|
+
subject { Fog::Vcloud::Terremark::Ecloud::Node }
|
10
|
+
|
11
|
+
it { should have_identity :href }
|
12
|
+
it { should have_only_these_attributes [:href, :ip_address, :description, :name, :port, :enabled, :id] }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with no uri" do
|
16
|
+
|
17
|
+
subject { Fog::Vcloud::Terremark::Ecloud::Node.new() }
|
18
|
+
it { should have_all_attributes_be_nil }
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
context "as a collection member" do
|
23
|
+
subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.first.reload }
|
24
|
+
|
25
|
+
it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Node }
|
26
|
+
|
27
|
+
its(:href) { should == @mock_node[:href] }
|
28
|
+
its(:identity) { should == @mock_node[:href] }
|
29
|
+
its(:name) { should == @mock_node[:name] }
|
30
|
+
its(:id) { should == @mock_node[:id] }
|
31
|
+
its(:port) { should == @mock_node[:port] }
|
32
|
+
its(:enabled) { should == @mock_node[:enabled] }
|
33
|
+
its(:description) { should == @mock_node[:description] }
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe "Fog::Vcloud::Terremark::Ecloud::InternetServices", :type => :mock_tmrk_ecloud_model do
|
5
|
+
context "as an attribute of an internet_service" do
|
6
|
+
subject { @vcloud.vdcs.first.public_ips.first.internet_services.first }
|
7
|
+
|
8
|
+
it { should respond_to :nodes }
|
9
|
+
|
10
|
+
describe :class do
|
11
|
+
subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.class }
|
12
|
+
its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Node }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe :nodes do
|
16
|
+
subject { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes }
|
17
|
+
|
18
|
+
it { should respond_to :create }
|
19
|
+
|
20
|
+
it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Nodes }
|
21
|
+
|
22
|
+
its(:length) { should == 2 }
|
23
|
+
|
24
|
+
it { should have_members_of_the_right_model }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
@@ -35,11 +35,13 @@ if Fog.mocking?
|
|
35
35
|
let(:body) { subject.body }
|
36
36
|
|
37
37
|
its(:body) { should be_an_instance_of Hash }
|
38
|
-
specify { body[:Href].
|
39
|
-
specify { body[:Name].should ==
|
40
|
-
specify { body[:Protocol].should ==
|
41
|
-
specify { body[:Enabled].should ==
|
42
|
-
specify { body[:Description].should ==
|
38
|
+
specify { body[:Href].should_not be_empty }
|
39
|
+
specify { body[:Name].should == @new_service_data[:name] }
|
40
|
+
specify { body[:Protocol].should == @new_service_data[:protocol] }
|
41
|
+
specify { body[:Enabled].should == @new_service_data[:enabled] }
|
42
|
+
specify { body[:Description].should == @new_service_data[:description] }
|
43
|
+
specify { body[:RedirectURL].should == @new_service_data[:redirect_url] }
|
44
|
+
specify { body[:Monitor].should == nil }
|
43
45
|
|
44
46
|
let(:public_ip) { subject.body[:PublicIpAddress] }
|
45
47
|
specify { public_ip.should be_an_instance_of Hash }
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
#FIXME: with rspec2
|
5
|
+
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
6
|
+
subject { @vcloud }
|
7
|
+
|
8
|
+
it { should respond_to :add_node }
|
9
|
+
|
10
|
+
describe "#add_node" do
|
11
|
+
|
12
|
+
let(:new_node_data) { { :ip_address => '1.2.3.4',
|
13
|
+
:name => 'Foo',
|
14
|
+
:port => '9090',
|
15
|
+
:enabled => 'true',
|
16
|
+
:description => 'Foo Service'
|
17
|
+
} }
|
18
|
+
|
19
|
+
context "with a valid node services uri" do
|
20
|
+
|
21
|
+
subject { @vcloud.add_node(@mock_service[:href] + "/nodeServices", new_node_data) }
|
22
|
+
|
23
|
+
it_should_behave_like "all responses"
|
24
|
+
|
25
|
+
let(:service) { @vcloud.vdcs.first.public_ips.first.internet_services.first }
|
26
|
+
|
27
|
+
it "should change the count by 1" do
|
28
|
+
service.nodes.length.should == 2
|
29
|
+
subject
|
30
|
+
service.nodes.reload.length.should == 3
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#body" do
|
34
|
+
subject { @vcloud.add_node(@mock_service[:href] + "/nodeServices", new_node_data).body }
|
35
|
+
its(:Enabled) { should == new_node_data[:enabled] }
|
36
|
+
its(:Port) { should == new_node_data[:port] }
|
37
|
+
its(:IpAddress) { should == new_node_data[:ip_address] }
|
38
|
+
its(:Name) { should == new_node_data[:name] }
|
39
|
+
its(:Description) { should == new_node_data[:description] }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with a nodes uri that doesn't exist" do
|
44
|
+
subject { lambda { @vcloud.add_node(URI.parse('https://www.fakey.c/piv8vc99'), new_node_data ) } }
|
45
|
+
|
46
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
else
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
5
|
+
subject { @vcloud }
|
6
|
+
|
7
|
+
it { should respond_to :configure_node }
|
8
|
+
|
9
|
+
describe "#configure_node" do
|
10
|
+
let(:original_node) { @vcloud.vdcs.first.public_ips.first.internet_services.first.nodes.first }
|
11
|
+
let(:node_data) { { :name => "TEST BOOM", :enabled => "false", :description => "TEST BOOM DESC" } }
|
12
|
+
|
13
|
+
context "with a valid node service uri" do
|
14
|
+
|
15
|
+
subject { @vcloud.configure_node(@mock_node[:href],node_data) }
|
16
|
+
|
17
|
+
it_should_behave_like "all responses"
|
18
|
+
|
19
|
+
describe "#body" do
|
20
|
+
subject { @vcloud.configure_node(@mock_node[:href],node_data).body }
|
21
|
+
|
22
|
+
its(:Description) { should == node_data[:description] }
|
23
|
+
its(:Href) { should == @mock_node[:href] }
|
24
|
+
its(:Name) { should == node_data[:name] }
|
25
|
+
its(:Id) { should == @mock_node[:id] }
|
26
|
+
its(:Port) { should == @mock_node[:port] }
|
27
|
+
its(:Enabled) { should == node_data[:enabled] }
|
28
|
+
its(:IpAddress) { should == @mock_node[:ip_address] }
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should change the name" do
|
32
|
+
original_node.name.should == @mock_node[:name]
|
33
|
+
subject
|
34
|
+
original_node.reload.name.should == node_data[:name]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should change enabled" do
|
38
|
+
original_node.enabled.should == @mock_node[:enabled]
|
39
|
+
subject
|
40
|
+
original_node.reload.enabled.should == node_data[:enabled]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should change the description" do
|
44
|
+
original_node.description.should == @mock_node[:description]
|
45
|
+
subject
|
46
|
+
original_node.reload.description.should == node_data[:description]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "with a nodes uri that doesn't exist" do
|
51
|
+
subject { lambda { @vcloud.configure_node(URI.parse('https://www.fakey.c/piv8vc99'), node_data) } }
|
52
|
+
|
53
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
end
|
@@ -1,36 +1,35 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
2
|
|
3
|
+
#FIXME: Make this more sane with rspec2
|
3
4
|
if Fog.mocking?
|
4
5
|
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
5
6
|
subject { @vcloud }
|
6
7
|
|
7
|
-
|
8
|
+
it { should respond_to :delete_internet_service }
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# @before_services = @vcloud.get_internet_services(@public_ip.href)
|
13
|
-
# end
|
10
|
+
describe "#delete_internet_service" do
|
11
|
+
context "with a valid internet service uri" do
|
12
|
+
subject { @vcloud.delete_internet_service(@mock_service[:href]) }
|
14
13
|
|
15
|
-
|
16
|
-
# subject { @vcloud.delete_internet_service(@before_services.body.tap{|o| pp o}.links[0].href) }
|
17
|
-
#
|
18
|
-
# specify { @before_services.body.links.should have(2).links }
|
14
|
+
it_should_behave_like "all delete responses"
|
19
15
|
|
20
|
-
|
21
|
-
# subject
|
22
|
-
# after_services = @vcloud.get_internet_services(@public_ip.href)
|
23
|
-
# after_services.body.links.should have(1).link
|
24
|
-
# end
|
16
|
+
let(:public_ip) { @vcloud.vdcs.first.public_ips.first }
|
25
17
|
|
26
|
-
|
18
|
+
it "should change the count by -1" do
|
19
|
+
public_ip.internet_services.length.should == 2
|
20
|
+
subject
|
21
|
+
public_ip.internet_services.reload.length.should == 1
|
22
|
+
end
|
27
23
|
|
28
|
-
|
29
|
-
|
24
|
+
describe "#body" do
|
25
|
+
its(:body) { should == '' }
|
26
|
+
end
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
34
33
|
end
|
35
34
|
else
|
36
35
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
#FIXME: with rspec2
|
5
|
+
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
6
|
+
subject { @vcloud }
|
7
|
+
|
8
|
+
it { should respond_to :delete_node }
|
9
|
+
|
10
|
+
describe "#delete_node" do
|
11
|
+
context "with a valid node service uri" do
|
12
|
+
subject { @vcloud.delete_node(@mock_node[:href]) }
|
13
|
+
|
14
|
+
#it_should_behave_like "all delete responses"
|
15
|
+
|
16
|
+
let(:internet_service) { @vcloud.vdcs.first.public_ips.first.internet_services.first }
|
17
|
+
|
18
|
+
it "should change the count by -1" do
|
19
|
+
internet_service.nodes.length.should == 2
|
20
|
+
subject
|
21
|
+
internet_service.nodes.reload.length.should == 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with a nodes uri that doesn't exist" do
|
26
|
+
subject { lambda { @vcloud.delete_node(URI.parse('https://www.fakey.c/piv8vc99')) } }
|
27
|
+
|
28
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
5
|
+
subject { @vcloud }
|
6
|
+
|
7
|
+
it { should respond_to :get_node }
|
8
|
+
|
9
|
+
describe "#get_node" do
|
10
|
+
context "with a valid nodes_uri" do
|
11
|
+
before { @node = @vcloud.get_node(@mock_node[:href]) }
|
12
|
+
subject { @node }
|
13
|
+
|
14
|
+
it_should_behave_like "all responses"
|
15
|
+
it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.nodeService+xml" }
|
16
|
+
|
17
|
+
describe "#body" do
|
18
|
+
subject { @node.body }
|
19
|
+
|
20
|
+
it { should have(9).keys }
|
21
|
+
|
22
|
+
its(:Href) { should == @mock_node[:href] }
|
23
|
+
its(:Id) { should == @mock_node[:id] }
|
24
|
+
its(:Name) { should == @mock_node[:name] }
|
25
|
+
its(:Enabled) { should == @mock_node[:enabled] }
|
26
|
+
its(:Port) { should == @mock_node[:port] }
|
27
|
+
its(:Description) { should == @mock_node[:description]}
|
28
|
+
its(:IpAddress) { should == @mock_node[:ip_address]}
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with a public_ips_uri that doesn't exist" do
|
34
|
+
subject { lambda { @vcloud.get_node(URI.parse('https://www.fakey.c/piv8vc99')) } }
|
35
|
+
|
36
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
|
2
|
+
|
3
|
+
if Fog.mocking?
|
4
|
+
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
5
|
+
subject { @vcloud }
|
6
|
+
|
7
|
+
it { should respond_to :get_nodes }
|
8
|
+
|
9
|
+
describe "#get_nodes" do
|
10
|
+
context "with a valid nodes_uri" do
|
11
|
+
before { @nodes = @vcloud.get_nodes(@mock_service[:href] + "/nodeServices") }
|
12
|
+
subject { @nodes }
|
13
|
+
|
14
|
+
it_should_behave_like "all responses"
|
15
|
+
it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.nodeService+xml" }
|
16
|
+
|
17
|
+
describe "#body" do
|
18
|
+
subject { @nodes.body }
|
19
|
+
|
20
|
+
it { should have(3).items }
|
21
|
+
|
22
|
+
describe "[:NodeService]" do
|
23
|
+
subject { @nodes.body[:NodeService] }
|
24
|
+
|
25
|
+
it { should have(@mock_service[:nodes].length).nodes }
|
26
|
+
|
27
|
+
[0,1].each do |idx|
|
28
|
+
|
29
|
+
context "[#{idx}]" do
|
30
|
+
subject { @nodes.body[:NodeService][idx] }
|
31
|
+
let(:mock_node) { @mock_service[:nodes][idx] }
|
32
|
+
let(:keys) { subject.keys.sort {|a,b| a.to_s <=> b.to_s } }
|
33
|
+
specify { keys.should == [:Description, :Enabled, :Href, :Id, :IpAddress, :Name, :Port] }
|
34
|
+
its(:Href) { should == mock_node[:href] }
|
35
|
+
its(:Id) { should == mock_node[:id] }
|
36
|
+
its(:Name) { should == mock_node[:name] }
|
37
|
+
its(:Enabled) { should == mock_node[:enabled] }
|
38
|
+
its(:Port) { should == mock_node[:port] }
|
39
|
+
its(:IpAddress) { should == mock_node[:ip_address] }
|
40
|
+
its(:Description) { should == mock_node[:description] }
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "with a public_ips_uri that doesn't exist" do
|
51
|
+
subject { lambda { @vcloud.get_nodes(URI.parse('https://www.fakey.c/piv8vc99')) } }
|
52
|
+
|
53
|
+
it_should_behave_like "a request for a resource that doesn't exist"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 7
|
9
|
+
version: 0.2.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- geemus (Wesley Beary)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-30 00:00:00 -05:00
|
18
18
|
default_executable: fog
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -617,17 +617,24 @@ files:
|
|
617
617
|
- spec/vcloud/terremark/ecloud/models/ips_spec.rb
|
618
618
|
- spec/vcloud/terremark/ecloud/models/network_spec.rb
|
619
619
|
- spec/vcloud/terremark/ecloud/models/networks_spec.rb
|
620
|
+
- spec/vcloud/terremark/ecloud/models/node_spec.rb
|
621
|
+
- spec/vcloud/terremark/ecloud/models/nodes_spec.rb
|
620
622
|
- spec/vcloud/terremark/ecloud/models/public_ip_spec.rb
|
621
623
|
- spec/vcloud/terremark/ecloud/models/public_ips_spec.rb
|
622
624
|
- spec/vcloud/terremark/ecloud/models/vdc_spec.rb
|
623
625
|
- spec/vcloud/terremark/ecloud/models/vdcs_spec.rb
|
624
626
|
- spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb
|
627
|
+
- spec/vcloud/terremark/ecloud/requests/add_node_spec.rb
|
625
628
|
- spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb
|
629
|
+
- spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb
|
626
630
|
- spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb
|
631
|
+
- spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb
|
627
632
|
- spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb
|
628
633
|
- spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb
|
629
634
|
- spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb
|
630
635
|
- spec/vcloud/terremark/ecloud/requests/get_network_spec.rb
|
636
|
+
- spec/vcloud/terremark/ecloud/requests/get_node_spec.rb
|
637
|
+
- spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb
|
631
638
|
- spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb
|
632
639
|
- spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb
|
633
640
|
- spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb
|