vcloud-core 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +13 -1
- data/README.md +13 -8
- data/lib/vcloud/core/version.rb +1 -1
- data/spec/vcloud/core/config_loader_spec.rb +155 -159
- data/spec/vcloud/core/config_validator_spec.rb +615 -619
- data/spec/vcloud/core/edge_gateway_interface_spec.rb +65 -70
- data/spec/vcloud/core/edge_gateway_spec.rb +138 -144
- data/spec/vcloud/core/independent_disk_spec.rb +15 -15
- data/spec/vcloud/core/metadata_helper_spec.rb +73 -77
- data/spec/vcloud/core/org_vdc_network_spec.rb +226 -230
- data/spec/vcloud/core/query_runner_spec.rb +31 -31
- data/spec/vcloud/core/query_spec.rb +1 -1
- data/spec/vcloud/core/vapp_spec.rb +175 -179
- data/spec/vcloud/core/vapp_template_spec.rb +82 -86
- data/spec/vcloud/core/vdc_spec.rb +47 -53
- data/spec/vcloud/core/vm_spec.rb +354 -358
- data/vcloud-core.gemspec +4 -4
- metadata +28 -30
- data/spec/integration/README.md +0 -36
@@ -1,87 +1,82 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@interface = EdgeGatewayInterface.new(@gateway_interface_hash)
|
25
|
-
end
|
26
|
-
|
27
|
-
context "Instance public interface" do
|
28
|
-
subject { EdgeGatewayInterface.new(@gateway_interface_hash) }
|
29
|
-
it { should respond_to(:name) }
|
30
|
-
it { should respond_to(:network_id) }
|
31
|
-
it { should respond_to(:network_name) }
|
32
|
-
it { should respond_to(:network_href) }
|
33
|
-
end
|
34
|
-
|
35
|
-
context "#initialize" do
|
3
|
+
describe Vcloud::Core::EdgeGatewayInterface do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@valid_ext_id = "12345678-70ac-487e-9c1e-124716764274"
|
7
|
+
@gateway_interface_hash = {
|
8
|
+
:Name=>"EXTERNAL_NETWORK",
|
9
|
+
:Network=>{
|
10
|
+
:type=>"application/vnd.vmware.admin.network+xml",
|
11
|
+
:name=>"EXTERNAL_NETWORK",
|
12
|
+
:href=>"https://example.com/api/admin/network/#{@valid_ext_id}"
|
13
|
+
},
|
14
|
+
:InterfaceType=>"uplink",
|
15
|
+
:SubnetParticipation=>{
|
16
|
+
:Gateway=>"192.2.0.1",
|
17
|
+
:Netmask=>"255.255.255.0",
|
18
|
+
:IpAddress=>"192.2.0.66"
|
19
|
+
},
|
20
|
+
:UseForDefaultRoute=>"true"
|
21
|
+
}
|
22
|
+
@interface = Vcloud::Core::EdgeGatewayInterface.new(@gateway_interface_hash)
|
23
|
+
end
|
36
24
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
25
|
+
context "Instance public interface" do
|
26
|
+
subject { Vcloud::Core::EdgeGatewayInterface.new(@gateway_interface_hash) }
|
27
|
+
it { should respond_to(:name) }
|
28
|
+
it { should respond_to(:network_id) }
|
29
|
+
it { should respond_to(:network_name) }
|
30
|
+
it { should respond_to(:network_href) }
|
31
|
+
end
|
41
32
|
|
42
|
-
|
43
|
-
expect { EdgeGatewayInterface.new(nil) }.
|
44
|
-
to raise_error(StandardError, /^EdgeGatewayInterface:/)
|
45
|
-
end
|
33
|
+
context "#initialize" do
|
46
34
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
it "should be constructable from just a Fog vCloud GatewayInterfaceType hash" do
|
36
|
+
obj = Vcloud::Core::EdgeGatewayInterface.new(@gateway_interface_hash)
|
37
|
+
expect(obj.class).to be(Vcloud::Core::EdgeGatewayInterface)
|
38
|
+
end
|
51
39
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
40
|
+
it "should raise an error if passed a nil value" do
|
41
|
+
expect { Vcloud::Core::EdgeGatewayInterface.new(nil) }.
|
42
|
+
to raise_error(StandardError, /^EdgeGatewayInterface:/)
|
43
|
+
end
|
56
44
|
|
57
|
-
|
45
|
+
it "should raise an error if a :Name is not passed" do
|
46
|
+
expect { Vcloud::Core::EdgeGatewayInterface.new({}) }.
|
47
|
+
to raise_error(StandardError, /^EdgeGatewayInterface:/)
|
48
|
+
end
|
58
49
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
50
|
+
it "should raise an error if a :Network is not passed" do
|
51
|
+
expect { Vcloud::Core::EdgeGatewayInterface.new({Name: 'test-interface'}) }.
|
52
|
+
to raise_error(StandardError, /^EdgeGatewayInterface:/)
|
53
|
+
end
|
64
54
|
|
65
|
-
|
66
|
-
it "should return the id of the network the interface is connected to" do
|
67
|
-
expect(@interface.network_id).to eq(@valid_ext_id)
|
68
|
-
end
|
69
|
-
end
|
55
|
+
end
|
70
56
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
57
|
+
context "#name" do
|
58
|
+
it "should return the name of the interface" do
|
59
|
+
expect(@interface.name).to eq('EXTERNAL_NETWORK')
|
60
|
+
end
|
61
|
+
end
|
76
62
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
63
|
+
context "#network_id" do
|
64
|
+
it "should return the id of the network the interface is connected to" do
|
65
|
+
expect(@interface.network_id).to eq(@valid_ext_id)
|
66
|
+
end
|
67
|
+
end
|
82
68
|
|
69
|
+
context "#network_name" do
|
70
|
+
it "should return the name of the network the interface is connected to" do
|
71
|
+
expect(@interface.network_name).to eq('EXTERNAL_NETWORK')
|
83
72
|
end
|
73
|
+
end
|
84
74
|
|
75
|
+
context "#network_href" do
|
76
|
+
it "should return the href of the network the interface is connected to" do
|
77
|
+
expect(@interface.network_href).to eq("https://example.com/api/admin/network/#{@valid_ext_id}")
|
78
|
+
end
|
85
79
|
end
|
86
80
|
|
87
81
|
end
|
82
|
+
|
@@ -1,163 +1,157 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
module Core
|
5
|
-
describe EdgeGateway do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@edgegw_id = '12345678-1234-1234-1234-000000111454'
|
9
|
-
@mock_fog_interface = StubFogInterface.new
|
10
|
-
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
11
|
-
end
|
3
|
+
describe Vcloud::Core::EdgeGateway do
|
12
4
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
before(:each) do
|
6
|
+
@edgegw_id = '12345678-1234-1234-1234-000000111454'
|
7
|
+
@mock_fog_interface = StubFogInterface.new
|
8
|
+
allow(Vcloud::Core::Fog::ServiceInterface).to receive(:new).and_return(@mock_fog_interface)
|
9
|
+
end
|
17
10
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
it { should respond_to(:href) }
|
23
|
-
it { should respond_to(:vcloud_gateway_interface_by_id) }
|
24
|
-
end
|
11
|
+
context "Class public interface" do
|
12
|
+
it { expect(Vcloud::Core::EdgeGateway).to respond_to(:get_ids_by_name) }
|
13
|
+
it { expect(Vcloud::Core::EdgeGateway).to respond_to(:get_by_name) }
|
14
|
+
end
|
25
15
|
|
26
|
-
|
16
|
+
context "Instance public interface" do
|
17
|
+
subject { Vcloud::Core::EdgeGateway.new(@edgegw_id) }
|
18
|
+
it { should respond_to(:id) }
|
19
|
+
it { should respond_to(:name) }
|
20
|
+
it { should respond_to(:href) }
|
21
|
+
it { should respond_to(:vcloud_gateway_interface_by_id) }
|
22
|
+
end
|
27
23
|
|
28
|
-
|
29
|
-
obj = EdgeGateway.new(@edgegw_id)
|
30
|
-
expect(obj.class).to be(Vcloud::Core::EdgeGateway)
|
31
|
-
end
|
24
|
+
context "#initialize" do
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
it "should be constructable from just an id reference" do
|
27
|
+
obj = Vcloud::Core::EdgeGateway.new(@edgegw_id)
|
28
|
+
expect(obj.class).to be(Vcloud::Core::EdgeGateway)
|
29
|
+
end
|
37
30
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
it "should store the id specified" do
|
32
|
+
obj = Vcloud::Core::EdgeGateway.new(@edgegw_id)
|
33
|
+
expect(obj.id).to eq(@edgegw_id)
|
34
|
+
end
|
42
35
|
|
43
|
-
|
36
|
+
it "should raise error if id is not in correct format" do
|
37
|
+
bogus_id = '123123-bogus-id-123445'
|
38
|
+
expect{ Vcloud::Core::EdgeGateway.new(bogus_id) }.to raise_error("EdgeGateway id : #{bogus_id} is not in correct format" )
|
39
|
+
end
|
44
40
|
|
45
|
-
|
41
|
+
end
|
46
42
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
43
|
+
context "#get_by_name" do
|
44
|
+
|
45
|
+
it "should return a Vcloud::Core::EdgeGateway object if name exists" do
|
46
|
+
q_results = [
|
47
|
+
{ :name => 'edgegw-test-1', :href => "/#{@edgegw_id}" }
|
48
|
+
]
|
49
|
+
mock_query = double(:query_runner)
|
50
|
+
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
51
|
+
expect(mock_query).to receive(:run).with('edgeGateway', :filter => "name==edgegw-test-1").and_return(q_results)
|
52
|
+
@obj = Vcloud::Core::EdgeGateway.get_by_name('edgegw-test-1')
|
53
|
+
expect(@obj.class).to be(Vcloud::Core::EdgeGateway)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return an object with the correct id if name exists" do
|
57
|
+
q_results = [
|
58
|
+
{ :name => 'edgegw-test-1', :href => "/#{@edgegw_id}" }
|
59
|
+
]
|
60
|
+
mock_query = double(:query_runner)
|
61
|
+
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
62
|
+
expect(mock_query).to receive(:run).with('edgeGateway', :filter => "name==edgegw-test-1").and_return(q_results)
|
63
|
+
@obj = Vcloud::Core::EdgeGateway.get_by_name('edgegw-test-1')
|
64
|
+
expect(@obj.id).to eq(@edgegw_id)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should raise an error if no edgegw with that name exists" do
|
68
|
+
q_results = [ ]
|
69
|
+
mock_query = double(:query_runner)
|
70
|
+
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
71
|
+
expect(mock_query).to receive(:run).with('edgeGateway', :filter => "name==edgegw-test-1").and_return(q_results)
|
72
|
+
expect{ Vcloud::Core::EdgeGateway.get_by_name('edgegw-test-1') }.to raise_exception(RuntimeError, "edgeGateway edgegw-test-1 not found")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
context "Interface related tests" do
|
78
|
+
|
79
|
+
before(:each) do
|
80
|
+
@valid_ext_id = "12345678-70ac-487e-9c1e-124716764274"
|
81
|
+
@valid_int_id = "12345678-70ac-487e-9c1e-552f1f0a91dc"
|
82
|
+
edge_gateway_hash = {
|
83
|
+
:Configuration=>
|
84
|
+
{:GatewayBackingConfig=>"compact",
|
85
|
+
:GatewayInterfaces=>
|
86
|
+
{:GatewayInterface=>
|
87
|
+
[{:Name=>"EXTERNAL_NETWORK",
|
88
|
+
:Network=>
|
89
|
+
{:type=>"application/vnd.vmware.admin.network+xml",
|
90
|
+
:name=>"EXTERNAL_NETWORK",
|
91
|
+
:href=>
|
92
|
+
"https://example.com/api/admin/network/#{@valid_ext_id}"},
|
93
|
+
:InterfaceType=>"uplink",
|
94
|
+
:SubnetParticipation=>
|
95
|
+
{:Gateway=>"192.2.0.1",
|
96
|
+
:Netmask=>"255.255.255.0",
|
97
|
+
:IpAddress=>"192.2.0.66"},
|
98
|
+
:UseForDefaultRoute=>"true"},
|
99
|
+
{:Name=>"INTERNAL_NETWORK",
|
100
|
+
:Network=>
|
101
|
+
{:type=>"application/vnd.vmware.admin.network+xml",
|
102
|
+
:name=>"INTERNAL_NETWORK",
|
103
|
+
:href=>
|
104
|
+
"https://example.com/api/admin/network/#{@valid_int_id}"},
|
105
|
+
:InterfaceType=>"internal",
|
106
|
+
:SubnetParticipation=>
|
107
|
+
{:Gateway=>"192.168.1.1",
|
108
|
+
:Netmask=>"255.255.255.0",
|
109
|
+
:IpAddress=>"192.168.1.55"},
|
110
|
+
:UseForDefaultRoute=>"false"
|
111
|
+
},
|
61
112
|
]
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
mock_query = double(:query_runner)
|
72
|
-
expect(Vcloud::Core::QueryRunner).to receive(:new).and_return(mock_query)
|
73
|
-
expect(mock_query).to receive(:run).with('edgeGateway', :filter => "name==edgegw-test-1").and_return(q_results)
|
74
|
-
expect{ EdgeGateway.get_by_name('edgegw-test-1') }.to raise_exception(RuntimeError, "edgeGateway edgegw-test-1 not found")
|
75
|
-
end
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
expect(@mock_fog_interface).to receive(:get_edge_gateway).
|
117
|
+
and_return(edge_gateway_hash)
|
118
|
+
@edgegw = Vcloud::Core::EdgeGateway.new(@edgegw_id)
|
119
|
+
end
|
120
|
+
|
121
|
+
context "#vcloud_gateway_interface_by_id" do
|
76
122
|
|
123
|
+
it "should return nil if the network id is not found" do
|
124
|
+
expect(@edgegw.vcloud_gateway_interface_by_id(
|
125
|
+
'12345678-1234-1234-1234-123456789012')).
|
126
|
+
to be_nil
|
77
127
|
end
|
78
128
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
:UseForDefaultRoute=>"true"},
|
101
|
-
{:Name=>"INTERNAL_NETWORK",
|
102
|
-
:Network=>
|
103
|
-
{:type=>"application/vnd.vmware.admin.network+xml",
|
104
|
-
:name=>"INTERNAL_NETWORK",
|
105
|
-
:href=>
|
106
|
-
"https://example.com/api/admin/network/#{@valid_int_id}"},
|
107
|
-
:InterfaceType=>"internal",
|
108
|
-
:SubnetParticipation=>
|
109
|
-
{:Gateway=>"192.168.1.1",
|
110
|
-
:Netmask=>"255.255.255.0",
|
111
|
-
:IpAddress=>"192.168.1.55"},
|
112
|
-
:UseForDefaultRoute=>"false"
|
113
|
-
},
|
114
|
-
]
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
expect(@mock_fog_interface).to receive(:get_edge_gateway).
|
119
|
-
and_return(edge_gateway_hash)
|
120
|
-
@edgegw = EdgeGateway.new(@edgegw_id)
|
121
|
-
end
|
122
|
-
|
123
|
-
context "#vcloud_gateway_interface_by_id" do
|
124
|
-
|
125
|
-
it "should return nil if the network id is not found" do
|
126
|
-
expect(@edgegw.vcloud_gateway_interface_by_id(
|
127
|
-
'12345678-1234-1234-1234-123456789012')).
|
128
|
-
to be_nil
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should return a vcloud network hash if the network id is found" do
|
132
|
-
expect(@edgegw.vcloud_gateway_interface_by_id(@valid_int_id)).
|
133
|
-
to eq(
|
134
|
-
{:Name=>"INTERNAL_NETWORK",
|
135
|
-
:Network=>
|
136
|
-
{:type=>"application/vnd.vmware.admin.network+xml",
|
137
|
-
:name=>"INTERNAL_NETWORK",
|
138
|
-
:href=>
|
139
|
-
"https://example.com/api/admin/network/#{@valid_int_id}"},
|
140
|
-
:InterfaceType=>"internal",
|
141
|
-
:SubnetParticipation=>
|
142
|
-
{:Gateway=>"192.168.1.1",
|
143
|
-
:Netmask=>"255.255.255.0",
|
144
|
-
:IpAddress=>"192.168.1.55"},
|
145
|
-
:UseForDefaultRoute=>"false"
|
146
|
-
},
|
147
|
-
)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context "#interfaces" do
|
152
|
-
|
153
|
-
it "should return an array of EdgeGatewayInterface objects" do
|
154
|
-
interfaces_list = @edgegw.interfaces
|
155
|
-
expect(interfaces_list.class).to be(Array)
|
156
|
-
expect(interfaces_list.first.class).to be(Vcloud::Core::EdgeGatewayInterface)
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
129
|
+
it "should return a vcloud network hash if the network id is found" do
|
130
|
+
expect(@edgegw.vcloud_gateway_interface_by_id(@valid_int_id)).
|
131
|
+
to eq(
|
132
|
+
{:Name=>"INTERNAL_NETWORK",
|
133
|
+
:Network=>
|
134
|
+
{:type=>"application/vnd.vmware.admin.network+xml",
|
135
|
+
:name=>"INTERNAL_NETWORK",
|
136
|
+
:href=>
|
137
|
+
"https://example.com/api/admin/network/#{@valid_int_id}"},
|
138
|
+
:InterfaceType=>"internal",
|
139
|
+
:SubnetParticipation=>
|
140
|
+
{:Gateway=>"192.168.1.1",
|
141
|
+
:Netmask=>"255.255.255.0",
|
142
|
+
:IpAddress=>"192.168.1.55"},
|
143
|
+
:UseForDefaultRoute=>"false"
|
144
|
+
},
|
145
|
+
)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "#interfaces" do
|
160
150
|
|
151
|
+
it "should return an array of Vcloud::Core::EdgeGatewayInterface objects" do
|
152
|
+
interfaces_list = @edgegw.interfaces
|
153
|
+
expect(interfaces_list.class).to be(Array)
|
154
|
+
expect(interfaces_list.first.class).to be(Vcloud::Core::EdgeGatewayInterface)
|
161
155
|
end
|
162
156
|
|
163
157
|
end
|