vcloud-network-configurator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/README.md +116 -0
- data/Rakefile +25 -0
- data/bin/vcloud_configure_edge_gateway +5 -0
- data/docs/find_network_url.md +56 -0
- data/docs/find_organisation_edgegateway_uuid.md +58 -0
- data/jenkins.sh +6 -0
- data/lib/component/firewall.rb +82 -0
- data/lib/component/load_balancer.rb +181 -0
- data/lib/component/nat.rb +73 -0
- data/lib/vcloud_network_configurator.rb +64 -0
- data/lib/vcloud_network_configurator/configure_task.rb +22 -0
- data/lib/vcloud_network_configurator/edge_gateway.rb +51 -0
- data/lib/vcloud_network_configurator/vcloud_auth_request.rb +39 -0
- data/lib/vcloud_network_configurator/vcloud_check_for_configure_task_request.rb +26 -0
- data/lib/vcloud_network_configurator/vcloud_configure_request.rb +51 -0
- data/lib/vcloud_network_configurator/vcloud_settings.rb +22 -0
- data/lib/vcloud_network_configurator/version.rb +1 -0
- data/spec/component/firewall.xml +45 -0
- data/spec/component/firewall_spec.rb +115 -0
- data/spec/component/lb.xml +567 -0
- data/spec/component/load_balancer_spec.rb +67 -0
- data/spec/component/nat.xml +146 -0
- data/spec/component/nat_spec.rb +28 -0
- data/spec/integration/authorization_failed_spec.rb +26 -0
- data/spec/integration/happy_path_firewall_spec.rb +74 -0
- data/spec/integration/happy_path_loadbalancer_spec.rb +173 -0
- data/spec/integration/happy_path_nat_spec.rb +78 -0
- data/spec/integration/test_data/happy_path_auth_response.xml +30 -0
- data/spec/integration/test_data/rules_dir/common_firewall.rb +6 -0
- data/spec/integration/test_data/rules_dir/common_lb.rb +10 -0
- data/spec/integration/test_data/rules_dir/common_nat.rb +0 -0
- data/spec/integration/test_data/rules_dir/preview/firewall.rb +0 -0
- data/spec/integration/test_data/rules_dir/preview/interfaces.yaml +2 -0
- data/spec/integration/test_data/rules_dir/preview/lb.rb +0 -0
- data/spec/integration/test_data/rules_dir/preview/nat.rb +4 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/vcloud_network_configurator/configure_task_spec.rb +59 -0
- data/spec/vcloud_network_configurator/edge_gateway_spec.rb +41 -0
- data/spec/vcloud_network_configurator/vcloud_auth_request_spec.rb +20 -0
- data/spec/vcloud_network_configurator/vcloud_settings_spec.rb +19 -0
- data/vcloud-network-configurator.gemspec +33 -0
- metadata +212 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'equivalent-xml'
|
4
|
+
require 'component/load_balancer'
|
5
|
+
|
6
|
+
|
7
|
+
describe "load balancer" do
|
8
|
+
before :each do
|
9
|
+
@interfaces = {
|
10
|
+
"TestData" => "https://vendor-api-url.net/admin/network/1000"
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to generate XML that matches what we created directly through the control panel" do
|
15
|
+
load_balancer do
|
16
|
+
configure "Signonotron" do
|
17
|
+
pool ["172.16.0.2", "172.16.0.3"] do
|
18
|
+
http :enabled => false
|
19
|
+
https :health_check_port => 9401
|
20
|
+
end
|
21
|
+
|
22
|
+
virtual_server :name => "Signonotron public", :interface => "TestData", :ip => "200.11.99.71"
|
23
|
+
virtual_server :name => "Signonotron internal", :interface => "TestData", :ip => "172.16.1.1"
|
24
|
+
end
|
25
|
+
|
26
|
+
configure "Search" do
|
27
|
+
pool ["172.12.0.2", "172.12.0.3", "172.12.0.4"] do
|
28
|
+
http :health_check_port => 9509
|
29
|
+
https :health_check_port => 9409
|
30
|
+
end
|
31
|
+
|
32
|
+
virtual_server :name => "Search internal", :interface => "TestData", :ip => "172.12.1.3"
|
33
|
+
end
|
34
|
+
|
35
|
+
configure "Router" do
|
36
|
+
pool ["172.11.0.2", "172.11.0.3", "172.11.0.4"] do
|
37
|
+
http
|
38
|
+
https
|
39
|
+
end
|
40
|
+
|
41
|
+
virtual_server :name => "Router public", :interface => "TestData", :ip => "200.11.99.73"
|
42
|
+
end
|
43
|
+
|
44
|
+
configure "router-internal" do
|
45
|
+
pool ["172.11.0.2", "172.11.0.3", "172.11.0.4"] do
|
46
|
+
http :port => 8080, :health_check_path => "/router/management/status"
|
47
|
+
https :enabled => false
|
48
|
+
end
|
49
|
+
|
50
|
+
virtual_server :name => "Router internal", :interface => "TestData", :ip => "172.11.1.1"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
Nokogiri::XML(Component::LoadBalancer.generate_xml(@interfaces).doc.root.to_s).should be_equivalent_to Nokogiri::XML(File.open("spec/component/lb.xml"))
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should blow up if pool is not defined before virtual server" do
|
59
|
+
expect { load_balancer do
|
60
|
+
configure "Signonotron" do
|
61
|
+
virtual_server :name => "Signonotron public", :interface => "TestData", :ip => "200.11.99.71"
|
62
|
+
virtual_server :name => "Signonotron internal", :interface => "TestData", :ip => "172.16.1.1"
|
63
|
+
end
|
64
|
+
end }.to raise_error
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,146 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<EdgeGatewayServiceConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.vmware.com/vcloud/v1.5" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vendor-api-url.net/v1.5/schema/master.xsd">
|
3
|
+
<NatService>
|
4
|
+
<IsEnabled>true</IsEnabled>
|
5
|
+
<NatRule>
|
6
|
+
<RuleType>SNAT</RuleType>
|
7
|
+
<IsEnabled>true</IsEnabled>
|
8
|
+
<Id>65538</Id>
|
9
|
+
<GatewayNatRule>
|
10
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
11
|
+
<OriginalIp>172.10.0.0/8</OriginalIp>
|
12
|
+
<TranslatedIp>200.11.99.70</TranslatedIp>
|
13
|
+
</GatewayNatRule>
|
14
|
+
</NatRule>
|
15
|
+
<NatRule>
|
16
|
+
<RuleType>DNAT</RuleType>
|
17
|
+
<IsEnabled>true</IsEnabled>
|
18
|
+
<Id>65539</Id>
|
19
|
+
<GatewayNatRule>
|
20
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
21
|
+
<OriginalIp>200.11.99.70</OriginalIp>
|
22
|
+
<OriginalPort>22</OriginalPort>
|
23
|
+
<TranslatedIp>172.10.0.100</TranslatedIp>
|
24
|
+
<TranslatedPort>22</TranslatedPort>
|
25
|
+
<Protocol>tcp</Protocol>
|
26
|
+
</GatewayNatRule>
|
27
|
+
</NatRule>
|
28
|
+
<NatRule>
|
29
|
+
<RuleType>DNAT</RuleType>
|
30
|
+
<IsEnabled>true</IsEnabled>
|
31
|
+
<Id>65540</Id>
|
32
|
+
<GatewayNatRule>
|
33
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
34
|
+
<OriginalIp>200.11.99.72</OriginalIp>
|
35
|
+
<OriginalPort>443</OriginalPort>
|
36
|
+
<TranslatedIp>172.16.0.2</TranslatedIp>
|
37
|
+
<TranslatedPort>443</TranslatedPort>
|
38
|
+
<Protocol>tcp</Protocol>
|
39
|
+
</GatewayNatRule>
|
40
|
+
</NatRule>
|
41
|
+
<NatRule>
|
42
|
+
<RuleType>DNAT</RuleType>
|
43
|
+
<IsEnabled>true</IsEnabled>
|
44
|
+
<Id>65537</Id>
|
45
|
+
<GatewayNatRule>
|
46
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
47
|
+
<OriginalIp>200.11.99.70</OriginalIp>
|
48
|
+
<OriginalPort>80</OriginalPort>
|
49
|
+
<TranslatedIp>172.10.0.3</TranslatedIp>
|
50
|
+
<TranslatedPort>80</TranslatedPort>
|
51
|
+
<Protocol>tcp</Protocol>
|
52
|
+
</GatewayNatRule>
|
53
|
+
</NatRule>
|
54
|
+
<NatRule>
|
55
|
+
<RuleType>DNAT</RuleType>
|
56
|
+
<IsEnabled>true</IsEnabled>
|
57
|
+
<Id>65542</Id>
|
58
|
+
<GatewayNatRule>
|
59
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
60
|
+
<OriginalIp>200.11.99.70</OriginalIp>
|
61
|
+
<OriginalPort>1022</OriginalPort>
|
62
|
+
<TranslatedIp>172.10.0.200</TranslatedIp>
|
63
|
+
<TranslatedPort>22</TranslatedPort>
|
64
|
+
<Protocol>tcp</Protocol>
|
65
|
+
</GatewayNatRule>
|
66
|
+
</NatRule>
|
67
|
+
<NatRule>
|
68
|
+
<RuleType>DNAT</RuleType>
|
69
|
+
<IsEnabled>true</IsEnabled>
|
70
|
+
<Id>65543</Id>
|
71
|
+
<GatewayNatRule>
|
72
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
73
|
+
<OriginalIp>200.11.99.74</OriginalIp>
|
74
|
+
<OriginalPort>443</OriginalPort>
|
75
|
+
<TranslatedIp>172.16.0.2</TranslatedIp>
|
76
|
+
<TranslatedPort>443</TranslatedPort>
|
77
|
+
<Protocol>tcp</Protocol>
|
78
|
+
</GatewayNatRule>
|
79
|
+
</NatRule>
|
80
|
+
<NatRule>
|
81
|
+
<RuleType>DNAT</RuleType>
|
82
|
+
<IsEnabled>true</IsEnabled>
|
83
|
+
<Id>65544</Id>
|
84
|
+
<GatewayNatRule>
|
85
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
86
|
+
<OriginalIp>200.11.99.75</OriginalIp>
|
87
|
+
<OriginalPort>80</OriginalPort>
|
88
|
+
<TranslatedIp>172.10.0.20</TranslatedIp>
|
89
|
+
<TranslatedPort>80</TranslatedPort>
|
90
|
+
<Protocol>tcp</Protocol>
|
91
|
+
</GatewayNatRule>
|
92
|
+
</NatRule>
|
93
|
+
<NatRule>
|
94
|
+
<RuleType>DNAT</RuleType>
|
95
|
+
<IsEnabled>true</IsEnabled>
|
96
|
+
<Id>65545</Id>
|
97
|
+
<GatewayNatRule>
|
98
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
99
|
+
<OriginalIp>200.11.99.76</OriginalIp>
|
100
|
+
<OriginalPort>80</OriginalPort>
|
101
|
+
<TranslatedIp>172.10.0.21</TranslatedIp>
|
102
|
+
<TranslatedPort>80</TranslatedPort>
|
103
|
+
<Protocol>tcp</Protocol>
|
104
|
+
</GatewayNatRule>
|
105
|
+
</NatRule>
|
106
|
+
<NatRule>
|
107
|
+
<RuleType>DNAT</RuleType>
|
108
|
+
<IsEnabled>true</IsEnabled>
|
109
|
+
<Id>65546</Id>
|
110
|
+
<GatewayNatRule>
|
111
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
112
|
+
<OriginalIp>200.11.99.75</OriginalIp>
|
113
|
+
<OriginalPort>443</OriginalPort>
|
114
|
+
<TranslatedIp>172.16.0.2</TranslatedIp>
|
115
|
+
<TranslatedPort>443</TranslatedPort>
|
116
|
+
<Protocol>tcp</Protocol>
|
117
|
+
</GatewayNatRule>
|
118
|
+
</NatRule>
|
119
|
+
<NatRule>
|
120
|
+
<RuleType>DNAT</RuleType>
|
121
|
+
<IsEnabled>true</IsEnabled>
|
122
|
+
<Id>65547</Id>
|
123
|
+
<GatewayNatRule>
|
124
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
125
|
+
<OriginalIp>200.11.99.76</OriginalIp>
|
126
|
+
<OriginalPort>443</OriginalPort>
|
127
|
+
<TranslatedIp>172.16.0.2</TranslatedIp>
|
128
|
+
<TranslatedPort>443</TranslatedPort>
|
129
|
+
<Protocol>tcp</Protocol>
|
130
|
+
</GatewayNatRule>
|
131
|
+
</NatRule>
|
132
|
+
<NatRule>
|
133
|
+
<RuleType>DNAT</RuleType>
|
134
|
+
<IsEnabled>true</IsEnabled>
|
135
|
+
<Id>65548</Id>
|
136
|
+
<GatewayNatRule>
|
137
|
+
<Interface href="https://vendor-api-url.net/admin/network/1000" name="TestData" type="application/vnd.vmware.admin.network+xml"/>
|
138
|
+
<OriginalIp>200.11.99.70</OriginalIp>
|
139
|
+
<OriginalPort>443</OriginalPort>
|
140
|
+
<TranslatedIp>172.16.5.0</TranslatedIp>
|
141
|
+
<TranslatedPort>443</TranslatedPort>
|
142
|
+
<Protocol>tcp</Protocol>
|
143
|
+
</GatewayNatRule>
|
144
|
+
</NatRule>
|
145
|
+
</NatService>
|
146
|
+
</EdgeGatewayServiceConfiguration>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'equivalent-xml'
|
4
|
+
require 'component/nat'
|
5
|
+
|
6
|
+
describe "nat" do
|
7
|
+
|
8
|
+
it "should be able to generate XML that matches what we created directly through the control panel" do
|
9
|
+
nat do
|
10
|
+
snat :interface => "TestData", :original => { :ip => "172.10.0.0/8" }, :translated => { :ip => "200.11.99.70" }, :id => 65538
|
11
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.70", :port => 22 }, :translated => { :ip => "172.10.0.100", :port => 22 }, :id => 65539
|
12
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.72", :port => 443 }, :translated => { :ip => "172.16.0.2", :port => 443 }, :id => 65540
|
13
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.70", :port => 80 }, :translated => { :ip => "172.10.0.3", :port => 80 }, :id => 65537
|
14
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.70", :port => 1022 }, :translated => { :ip => "172.10.0.200", :port => 22 }, :id => 65542
|
15
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.74", :port => 443 }, :translated => { :ip => "172.16.0.2", :port => 443 }, :id => 65543
|
16
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.75", :port => 80 }, :translated => { :ip => "172.10.0.20", :port => 80 }, :id => 65544
|
17
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.76", :port => 80 }, :translated => { :ip => "172.10.0.21", :port => 80 }, :id => 65545
|
18
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.75", :port => 443 }, :translated => { :ip => "172.16.0.2", :port => 443 }, :id => 65546
|
19
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.76", :port => 443 }, :translated => { :ip => "172.16.0.2", :port => 443 }, :id => 65547
|
20
|
+
dnat :interface => "TestData", :original => { :ip => "200.11.99.70", :port => 443 }, :translated => { :ip => "172.16.5.0", :port => 443 }, :id => 65548
|
21
|
+
end
|
22
|
+
|
23
|
+
interfaces = {
|
24
|
+
"TestData" => "https://vendor-api-url.net/admin/network/1000"
|
25
|
+
}
|
26
|
+
Nokogiri::XML(Component::NAT.generate_xml(interfaces).doc.root.to_s).should be_equivalent_to Nokogiri::XML(File.open("spec/component/nat.xml"))
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcloud_network_configurator'
|
3
|
+
|
4
|
+
describe "happy path" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
WebMock.disable_net_connect!
|
8
|
+
WebMock.reset!
|
9
|
+
|
10
|
+
session_url = "https://super%40preview:man@www.vcloud.eggplant.com/sessions"
|
11
|
+
|
12
|
+
stub_request(:post, session_url).
|
13
|
+
with(:headers => {'Accept'=>'application/*+xml;version=5.1', 'User-Agent'=>'Ruby'}).
|
14
|
+
to_return(:status => 401)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should abort on failure of authorization" do
|
18
|
+
args = ["-u", "super", "-p", "man", "-U", "123321", "-d",
|
19
|
+
"spec/integration/test_data/rules_dir", "-e", "preview",
|
20
|
+
"-c", "firewall", "https://www.vcloud.eggplant.com"]
|
21
|
+
|
22
|
+
configurator = VcloudNetworkConfigurator.new(args)
|
23
|
+
expect { configurator.execute }.to raise_error(SystemExit, "Could not authenticate user")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcloud_network_configurator'
|
3
|
+
|
4
|
+
describe "happy path" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
WebMock.disable_net_connect!
|
8
|
+
WebMock.reset!
|
9
|
+
|
10
|
+
session_url = "https://super%40preview:man@www.vcloud.eggplant.com/sessions"
|
11
|
+
edge_gateway_configure_url = "https://www.vcloud.eggplant.com/admin/edgeGateway/123321/action/configureServices"
|
12
|
+
task_url = "https://www.vcloud.eggplant.com/api/tasks/10"
|
13
|
+
|
14
|
+
stub_request(:post, session_url).
|
15
|
+
with(:headers => {'Accept'=>'application/*+xml;version=5.1', 'User-Agent'=>'Ruby'}).
|
16
|
+
to_return(:status => 200,
|
17
|
+
:body => File.read('spec/integration/test_data/happy_path_auth_response.xml'),
|
18
|
+
:headers => { 'x-vcloud-authorization' => '123321'})
|
19
|
+
|
20
|
+
stub_request(:post, edge_gateway_configure_url).
|
21
|
+
with(:body => configure_firewall_xml,
|
22
|
+
:headers => { 'Accept'=>'application/*+xml;version=5.1',
|
23
|
+
'Content-Type'=>'application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml',
|
24
|
+
'User-Agent'=>'Ruby',
|
25
|
+
'X-Vcloud-Authorization'=>'123321' }).
|
26
|
+
to_return(:status => 202, :body => configure_task_xml)
|
27
|
+
|
28
|
+
stub_request(:get, task_url).
|
29
|
+
with(:headers => {'Accept'=>'application/*+xml;version=5.1', 'User-Agent'=>'Ruby', 'X-Vcloud-Authorization'=>'123321'}).
|
30
|
+
to_return(:status => 200, :body => configure_task_xml, :headers => {})
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should configure edgegateway successfully" do
|
34
|
+
args = ["-u", "super", "-p", "man", "-U", "123321", "-d",
|
35
|
+
"spec/integration/test_data/rules_dir", "-e", "preview",
|
36
|
+
"-c", "firewall", "https://www.vcloud.eggplant.com"]
|
37
|
+
|
38
|
+
configurator = VcloudNetworkConfigurator.new(args)
|
39
|
+
configurator.execute.should be_true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def configure_task_xml
|
44
|
+
%q{<Task href="https://www.vcloud.eggplant.com/api/tasks/10" status="success"></Task>}
|
45
|
+
end
|
46
|
+
|
47
|
+
def configure_firewall_xml
|
48
|
+
%q{<?xml version="1.0" encoding="UTF-8"?>
|
49
|
+
<EdgeGatewayServiceConfiguration xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vendor-api-url.net/v1.5/schema/master.xsd">
|
50
|
+
<FirewallService>
|
51
|
+
<IsEnabled>true</IsEnabled>
|
52
|
+
<DefaultAction>drop</DefaultAction>
|
53
|
+
<LogDefaultAction>false</LogDefaultAction>
|
54
|
+
<FirewallRule>
|
55
|
+
<Id>1</Id>
|
56
|
+
<IsEnabled>true</IsEnabled>
|
57
|
+
<MatchOnTranslate>false</MatchOnTranslate>
|
58
|
+
<Description>allow all boxes to access peppers box on port 22</Description>
|
59
|
+
<Policy>allow</Policy>
|
60
|
+
<Protocols>
|
61
|
+
<Tcp>true</Tcp>
|
62
|
+
</Protocols>
|
63
|
+
<Port>22</Port>
|
64
|
+
<DestinationPortRange>22</DestinationPortRange>
|
65
|
+
<DestinationIp>172.11.0.1</DestinationIp>
|
66
|
+
<SourcePort>-1</SourcePort>
|
67
|
+
<SourcePortRange>Any</SourcePortRange>
|
68
|
+
<SourceIp>172.10.0.0/24</SourceIp>
|
69
|
+
<EnableLogging>false</EnableLogging>
|
70
|
+
</FirewallRule>
|
71
|
+
</FirewallService>
|
72
|
+
</EdgeGatewayServiceConfiguration>
|
73
|
+
}
|
74
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcloud_network_configurator'
|
3
|
+
|
4
|
+
describe "happy path for lb configurations" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
WebMock.disable_net_connect!
|
8
|
+
WebMock.reset!
|
9
|
+
|
10
|
+
session_url = "https://super%40preview:man@www.vcloud.eggplant.com/sessions"
|
11
|
+
edge_gateway_configure_url = "https://www.vcloud.eggplant.com/admin/edgeGateway/123321/action/configureServices"
|
12
|
+
task_url = "https://www.vcloud.eggplant.com/api/tasks/10"
|
13
|
+
|
14
|
+
stub_request(:post, session_url).
|
15
|
+
with(:headers => {'Accept'=>'application/*+xml;version=5.1', 'User-Agent'=>'Ruby'}).
|
16
|
+
to_return(:status => 200,
|
17
|
+
:body => File.read('spec/integration/test_data/happy_path_auth_response.xml'),
|
18
|
+
:headers => { 'x-vcloud-authorization' => '123321'})
|
19
|
+
|
20
|
+
stub_request(:post, edge_gateway_configure_url).
|
21
|
+
with(:body => configure_lb_xml,
|
22
|
+
:headers => { 'Accept'=>'application/*+xml;version=5.1',
|
23
|
+
'Content-Type'=>'application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml',
|
24
|
+
'User-Agent'=>'Ruby',
|
25
|
+
'X-Vcloud-Authorization'=>'123321' }).
|
26
|
+
to_return(:status => 202, :body => configure_task_xml)
|
27
|
+
|
28
|
+
stub_request(:get, task_url).
|
29
|
+
with(:headers => {'Accept'=>'application/*+xml;version=5.1', 'User-Agent'=>'Ruby', 'X-Vcloud-Authorization'=>'123321'}).
|
30
|
+
to_return(:status => 200, :body => configure_task_xml, :headers => {})
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should configure edgegateway successfully" do
|
34
|
+
args = ["-u", "super", "-p", "man", "-U", "123321", "-d",
|
35
|
+
"spec/integration/test_data/rules_dir", "-e", "preview",
|
36
|
+
"-c", "lb", "https://www.vcloud.eggplant.com"]
|
37
|
+
|
38
|
+
configurator = VcloudNetworkConfigurator.new(args)
|
39
|
+
configurator.execute.should be_true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def configure_task_xml
|
44
|
+
%q{<Task href="https://www.vcloud.eggplant.com/api/tasks/10" status="success"></Task>}
|
45
|
+
end
|
46
|
+
|
47
|
+
def configure_lb_xml
|
48
|
+
%q{<?xml version="1.0" encoding="UTF-8"?>
|
49
|
+
<EdgeGatewayServiceConfiguration xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vendor-api-url.net/v1.5/schema/master.xsd">
|
50
|
+
<LoadBalancerService>
|
51
|
+
<IsEnabled>false</IsEnabled>
|
52
|
+
<Pool>
|
53
|
+
<Name>Frontend pool</Name>
|
54
|
+
<ServicePort>
|
55
|
+
<IsEnabled>true</IsEnabled>
|
56
|
+
<Protocol>HTTP</Protocol>
|
57
|
+
<Algorithm>ROUND_ROBIN</Algorithm>
|
58
|
+
<Port>80</Port>
|
59
|
+
<HealthCheckPort/>
|
60
|
+
<HealthCheck>
|
61
|
+
<Mode>HTTP</Mode>
|
62
|
+
<Uri>/</Uri>
|
63
|
+
<HealthThreshold>2</HealthThreshold>
|
64
|
+
<UnhealthThreshold>3</UnhealthThreshold>
|
65
|
+
<Interval>5</Interval>
|
66
|
+
<Timeout>15</Timeout>
|
67
|
+
</HealthCheck>
|
68
|
+
</ServicePort>
|
69
|
+
<ServicePort>
|
70
|
+
<IsEnabled>true</IsEnabled>
|
71
|
+
<Protocol>HTTPS</Protocol>
|
72
|
+
<Algorithm>ROUND_ROBIN</Algorithm>
|
73
|
+
<Port>443</Port>
|
74
|
+
<HealthCheckPort/>
|
75
|
+
<HealthCheck>
|
76
|
+
<Mode>SSL</Mode>
|
77
|
+
<Uri>/</Uri>
|
78
|
+
<HealthThreshold>2</HealthThreshold>
|
79
|
+
<UnhealthThreshold>3</UnhealthThreshold>
|
80
|
+
<Interval>5</Interval>
|
81
|
+
<Timeout>15</Timeout>
|
82
|
+
</HealthCheck>
|
83
|
+
</ServicePort>
|
84
|
+
<ServicePort>
|
85
|
+
<IsEnabled>false</IsEnabled>
|
86
|
+
<Protocol>TCP</Protocol>
|
87
|
+
<Algorithm>ROUND_ROBIN</Algorithm>
|
88
|
+
<Port/>
|
89
|
+
<HealthCheckPort/>
|
90
|
+
<HealthCheck>
|
91
|
+
<Mode>TCP</Mode>
|
92
|
+
<HealthThreshold>2</HealthThreshold>
|
93
|
+
<UnhealthThreshold>3</UnhealthThreshold>
|
94
|
+
<Interval>5</Interval>
|
95
|
+
<Timeout>15</Timeout>
|
96
|
+
</HealthCheck>
|
97
|
+
</ServicePort>
|
98
|
+
<Member>
|
99
|
+
<IpAddress>20.2.0.1</IpAddress>
|
100
|
+
<Weight>1</Weight>
|
101
|
+
<ServicePort>
|
102
|
+
<Protocol>HTTP</Protocol>
|
103
|
+
<Port>80</Port>
|
104
|
+
<HealthCheckPort/>
|
105
|
+
</ServicePort>
|
106
|
+
<ServicePort>
|
107
|
+
<Protocol>HTTPS</Protocol>
|
108
|
+
<Port>443</Port>
|
109
|
+
<HealthCheckPort/>
|
110
|
+
</ServicePort>
|
111
|
+
<ServicePort>
|
112
|
+
<Protocol>TCP</Protocol>
|
113
|
+
<Port/>
|
114
|
+
<HealthCheckPort/>
|
115
|
+
</ServicePort>
|
116
|
+
</Member>
|
117
|
+
<Member>
|
118
|
+
<IpAddress>20.3.0.2</IpAddress>
|
119
|
+
<Weight>1</Weight>
|
120
|
+
<ServicePort>
|
121
|
+
<Protocol>HTTP</Protocol>
|
122
|
+
<Port>80</Port>
|
123
|
+
<HealthCheckPort/>
|
124
|
+
</ServicePort>
|
125
|
+
<ServicePort>
|
126
|
+
<Protocol>HTTPS</Protocol>
|
127
|
+
<Port>443</Port>
|
128
|
+
<HealthCheckPort/>
|
129
|
+
</ServicePort>
|
130
|
+
<ServicePort>
|
131
|
+
<Protocol>TCP</Protocol>
|
132
|
+
<Port/>
|
133
|
+
<HealthCheckPort/>
|
134
|
+
</ServicePort>
|
135
|
+
</Member>
|
136
|
+
<Operational>false</Operational>
|
137
|
+
</Pool>
|
138
|
+
<VirtualServer>
|
139
|
+
<IsEnabled>true</IsEnabled>
|
140
|
+
<Name>VDC-1</Name>
|
141
|
+
<Interface type="application/vnd.vmware.vcloud.orgVdcNetwork+xml" name="VDC-1" href="http://interface.vdc-1/19237"/>
|
142
|
+
<IpAddress>20.1.0.2</IpAddress>
|
143
|
+
<ServiceProfile>
|
144
|
+
<IsEnabled>true</IsEnabled>
|
145
|
+
<Protocol>HTTP</Protocol>
|
146
|
+
<Port>80</Port>
|
147
|
+
<Persistence>
|
148
|
+
<Method/>
|
149
|
+
</Persistence>
|
150
|
+
</ServiceProfile>
|
151
|
+
<ServiceProfile>
|
152
|
+
<IsEnabled>true</IsEnabled>
|
153
|
+
<Protocol>HTTPS</Protocol>
|
154
|
+
<Port>443</Port>
|
155
|
+
<Persistence>
|
156
|
+
<Method/>
|
157
|
+
</Persistence>
|
158
|
+
</ServiceProfile>
|
159
|
+
<ServiceProfile>
|
160
|
+
<IsEnabled>false</IsEnabled>
|
161
|
+
<Protocol>TCP</Protocol>
|
162
|
+
<Port/>
|
163
|
+
<Persistence>
|
164
|
+
<Method/>
|
165
|
+
</Persistence>
|
166
|
+
</ServiceProfile>
|
167
|
+
<Logging>false</Logging>
|
168
|
+
<Pool>Frontend pool</Pool>
|
169
|
+
</VirtualServer>
|
170
|
+
</LoadBalancerService>
|
171
|
+
</EdgeGatewayServiceConfiguration>
|
172
|
+
}
|
173
|
+
end
|