vcloud-core 0.0.4 → 0.0.5
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/.gitignore
CHANGED
@@ -26,6 +26,15 @@ module Vcloud
|
|
26
26
|
fsi.post_configure_edge_gateway_services(id, config)
|
27
27
|
end
|
28
28
|
|
29
|
+
def vcloud_gateway_interface_by_id gateway_interface_id
|
30
|
+
gateway_interfaces = vcloud_attributes[:Configuration][:GatewayInterfaces][:GatewayInterface]
|
31
|
+
unless gateway_interfaces.empty?
|
32
|
+
return gateway_interfaces.find{ |interface|
|
33
|
+
interface[:Network][:href].split('/').last == gateway_interface_id
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
29
38
|
def self.get_by_name(name)
|
30
39
|
ids = self.get_ids_by_name(name)
|
31
40
|
raise "edgeGateway #{name} not found" if ids.size == 0
|
data/lib/vcloud/core/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Vcloud
|
4
|
+
module Core
|
5
|
+
describe EdgeGateway do
|
6
|
+
context "get vcloud attributes for given gateway interface id " do
|
7
|
+
before(:all) do
|
8
|
+
@edge_gateway = EdgeGateway.get_by_name(ENV['VCLOUD_EDGE_GATEWAY'])
|
9
|
+
end
|
10
|
+
it "should return provider network" do
|
11
|
+
gateway_interface = @edge_gateway.vcloud_gateway_interface_by_id(ENV['VCLOUD_PROVIDER_NETWORK_ID'])
|
12
|
+
expect(gateway_interface[:Network]).not_to be_nil
|
13
|
+
expect(gateway_interface[:Network][:href]).to include(ENV['VCLOUD_PROVIDER_NETWORK_ID'])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return orgVdcNetwork" do
|
17
|
+
gateway_interface = @edge_gateway.vcloud_gateway_interface_by_id(ENV['VCLOUD_NETWORK1_ID'])
|
18
|
+
expect(gateway_interface[:Network]).not_to be_nil
|
19
|
+
expect(gateway_interface[:Network][:href]).to include(ENV['VCLOUD_NETWORK1_ID'])
|
20
|
+
end
|
21
|
+
|
22
|
+
it "return nil if network with given id is not found" do
|
23
|
+
gateway_interface = @edge_gateway.vcloud_gateway_interface_by_id(SecureRandom.uuid)
|
24
|
+
expect(gateway_interface).to be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -20,6 +20,7 @@ module Vcloud
|
|
20
20
|
it { should respond_to(:id) }
|
21
21
|
it { should respond_to(:name) }
|
22
22
|
it { should respond_to(:href) }
|
23
|
+
it { should respond_to(:vcloud_gateway_interface_by_id) }
|
23
24
|
end
|
24
25
|
|
25
26
|
context "#initialize" do
|
@@ -72,6 +73,77 @@ module Vcloud
|
|
72
73
|
|
73
74
|
end
|
74
75
|
|
76
|
+
context "#vcloud_gateway_interface_by_id" do
|
77
|
+
|
78
|
+
before(:each) do
|
79
|
+
@valid_ext_id = "12345678-70ac-487e-9c1e-124716764274"
|
80
|
+
@valid_int_id = "12345678-70ac-487e-9c1e-552f1f0a91dc"
|
81
|
+
edge_gateway_hash = {
|
82
|
+
:Configuration=>
|
83
|
+
{:GatewayBackingConfig=>"compact",
|
84
|
+
:GatewayInterfaces=>
|
85
|
+
{:GatewayInterface=>
|
86
|
+
[{:Name=>"EXTERNAL_NETWORK",
|
87
|
+
:Network=>
|
88
|
+
{:type=>"application/vnd.vmware.admin.network+xml",
|
89
|
+
:name=>"EXTERNAL_NETWORK",
|
90
|
+
:href=>
|
91
|
+
"https://example.com/api/admin/network/#{@valid_ext_id}"},
|
92
|
+
:InterfaceType=>"uplink",
|
93
|
+
:SubnetParticipation=>
|
94
|
+
{:Gateway=>"192.2.0.1",
|
95
|
+
:Netmask=>"255.255.255.0",
|
96
|
+
:IpAddress=>"192.2.0.66"},
|
97
|
+
:UseForDefaultRoute=>"true"},
|
98
|
+
{:Name=>"INTERNAL_NETWORK",
|
99
|
+
:Network=>
|
100
|
+
{:type=>"application/vnd.vmware.admin.network+xml",
|
101
|
+
:name=>"INTERNAL_NETWORK",
|
102
|
+
:href=>
|
103
|
+
"https://example.com/api/admin/network/#{@valid_int_id}"},
|
104
|
+
:InterfaceType=>"internal",
|
105
|
+
:SubnetParticipation=>
|
106
|
+
{:Gateway=>"192.168.1.1",
|
107
|
+
:Netmask=>"255.255.255.0",
|
108
|
+
:IpAddress=>"192.168.1.55"},
|
109
|
+
:UseForDefaultRoute=>"false"
|
110
|
+
},
|
111
|
+
]
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
@mock_fog_interface.should_receive(:get_edge_gateway).
|
116
|
+
and_return(edge_gateway_hash)
|
117
|
+
@edgegw = EdgeGateway.new(@edgegw_id)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return nil if the network id is not found" do
|
121
|
+
expect(@edgegw.vcloud_gateway_interface_by_id(
|
122
|
+
'12345678-1234-1234-1234-123456789012')).
|
123
|
+
to be_nil
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should return a vcloud network hash if the network id is found" do
|
127
|
+
expect(@edgegw.vcloud_gateway_interface_by_id(@valid_int_id)).
|
128
|
+
to eq(
|
129
|
+
{:Name=>"INTERNAL_NETWORK",
|
130
|
+
:Network=>
|
131
|
+
{:type=>"application/vnd.vmware.admin.network+xml",
|
132
|
+
:name=>"INTERNAL_NETWORK",
|
133
|
+
:href=>
|
134
|
+
"https://example.com/api/admin/network/#{@valid_int_id}"},
|
135
|
+
:InterfaceType=>"internal",
|
136
|
+
:SubnetParticipation=>
|
137
|
+
{:Gateway=>"192.168.1.1",
|
138
|
+
:Netmask=>"255.255.255.0",
|
139
|
+
:IpAddress=>"192.168.1.55"},
|
140
|
+
:UseForDefaultRoute=>"false"
|
141
|
+
},
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
75
147
|
end
|
76
148
|
|
77
149
|
end
|
@@ -10,8 +10,8 @@ module Vcloud
|
|
10
10
|
it 'should raise a exception if named vdc not found in the data returned' do
|
11
11
|
|
12
12
|
fog_facade = double(:FogFacade)
|
13
|
-
expect(fog_facade).to receive(:session).
|
14
|
-
expect(fog_facade).to receive(:get_organization).
|
13
|
+
expect(fog_facade).to receive(:session).and_return { FOG_SESSION_RESPONSE }
|
14
|
+
expect(fog_facade).to receive(:get_organization).and_return { FOG_ORGANIZATION_RESPONSE }
|
15
15
|
|
16
16
|
service_interface = ServiceInterface.new(fog_facade)
|
17
17
|
|
@@ -21,8 +21,8 @@ module Vcloud
|
|
21
21
|
it 'should raise a exception if named catalog cannot be found in the data returned' do
|
22
22
|
|
23
23
|
fog_facade = double(:FogFacade)
|
24
|
-
expect(fog_facade).to receive(:session).
|
25
|
-
expect(fog_facade).to receive(:get_organization).
|
24
|
+
expect(fog_facade).to receive(:session).and_return { FOG_SESSION_RESPONSE }
|
25
|
+
expect(fog_facade).to receive(:get_organization).and_return { FOG_ORGANIZATION_RESPONSE }
|
26
26
|
|
27
27
|
service_interface = ServiceInterface.new(fog_facade)
|
28
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcloud-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/vcloud/fog/relation.rb
|
142
142
|
- lib/vcloud/fog/service_interface.rb
|
143
143
|
- spec/integration/edge_gateway/configure_edge_gateway_services_spec.rb
|
144
|
+
- spec/integration/edge_gateway/edge_gateway_spec.rb
|
144
145
|
- spec/spec_helper.rb
|
145
146
|
- spec/support/stub_fog_interface.rb
|
146
147
|
- spec/vcloud/core/edge_gateway_spec.rb
|
@@ -177,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
178
|
version: '0'
|
178
179
|
segments:
|
179
180
|
- 0
|
180
|
-
hash: -
|
181
|
+
hash: -849601463027409956
|
181
182
|
requirements: []
|
182
183
|
rubyforge_project:
|
183
184
|
rubygems_version: 1.8.23
|
@@ -186,6 +187,7 @@ specification_version: 3
|
|
186
187
|
summary: Core tools for interacting with VMware vCloud Director
|
187
188
|
test_files:
|
188
189
|
- spec/integration/edge_gateway/configure_edge_gateway_services_spec.rb
|
190
|
+
- spec/integration/edge_gateway/edge_gateway_spec.rb
|
189
191
|
- spec/spec_helper.rb
|
190
192
|
- spec/support/stub_fog_interface.rb
|
191
193
|
- spec/vcloud/core/edge_gateway_spec.rb
|