vcloud-edge_gateway 1.4.1 → 1.5.0
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/CHANGELOG.md +13 -4
- data/LICENSE.txt +1 -1
- data/README.md +15 -6
- data/examples/vcloud-configure-edge/static-routing-rules.yaml +13 -0
- data/lib/vcloud/edge_gateway.rb +3 -1
- data/lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb +58 -0
- data/lib/vcloud/edge_gateway/edge_gateway_configuration.rb +15 -0
- data/lib/vcloud/edge_gateway/schema/edge_gateway.rb +1 -0
- data/lib/vcloud/edge_gateway/schema/static_routing_service.rb +33 -0
- data/lib/vcloud/edge_gateway/static_routing_configuration_differ.rb +16 -0
- data/lib/vcloud/edge_gateway/version.rb +1 -1
- data/spec/integration/edge_gateway/configure_static_routing_spec.rb +144 -0
- data/spec/integration/edge_gateway/data/static_routing_config.yaml.mustache +14 -0
- data/spec/integration/edge_gateway/data/static_routing_empty.yaml.mustache +4 -0
- data/spec/vcloud/edge_gateway/configuration_generator/static_routing_service_spec.rb +98 -0
- data/spec/vcloud/edge_gateway/edge_gateway_configuration_spec.rb +30 -0
- data/spec/vcloud/edge_gateway/static_routing_schema_validation_spec.rb +41 -0
- metadata +35 -23
- data/spec/integration/README.md +0 -38
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,23 @@
|
|
1
|
+
## 1.5.0 (2015-03-04)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
- Add support for static routes, thanks @geriBatai!
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
- Correct the Copyright notice
|
8
|
+
- Guide for integration tests moved to GDS Operations web site
|
9
|
+
|
1
10
|
## 1.4.1 (2015-01-26)
|
2
11
|
|
3
|
-
|
4
|
-
|
12
|
+
- Update vCloud Core to 1.0.0 since the API is now stable.
|
13
|
+
- Update vcloud-tools-tester to 1.0.0 since the API is now stable.
|
5
14
|
|
6
15
|
## 1.4.0 (2014-12-03)
|
7
16
|
|
8
17
|
Features:
|
9
18
|
|
10
|
-
|
11
|
-
|
19
|
+
- Update vCloud Core to 0.14.0 to improve speed of integration tests.
|
20
|
+
- Update vCloud Core to 0.16.0 for `vcloud-logout` utility.
|
12
21
|
|
13
22
|
## 1.3.0 (2014-10-14)
|
14
23
|
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2014
|
3
|
+
Copyright (c) 2014 Crown Copyright (Government Digital Service)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
data/README.md
CHANGED
@@ -421,12 +421,21 @@ Run the default suite of tests (e.g. lint, unit, features):
|
|
421
421
|
|
422
422
|
bundle exec rake
|
423
423
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
424
|
+
There are also integration tests. These are slower and require a real environment.
|
425
|
+
See the [vCloud Tools website](http://gds-operations.github.io/vcloud-tools/testing/) for details of how to set up and run the integration tests.
|
426
|
+
|
427
|
+
The parameters required to run the vCloud Edge Gateway integration tests are:
|
428
|
+
|
429
|
+
````
|
430
|
+
default: # This is the fog credential that refers to your testing environment, e.g. `test_credential`
|
431
|
+
network_1: # Primary network name
|
432
|
+
network_1_id: # Primary network ID
|
433
|
+
network_1_ip: # Primary network IP
|
434
|
+
edge_gateway: # Edge gateway name
|
435
|
+
provider_network: # Provider (external-facing) network name
|
436
|
+
provider_network_id: # Provider network ID
|
437
|
+
provider_network_ip: # Provider network IP
|
438
|
+
````
|
430
439
|
|
431
440
|
### References
|
432
441
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
gateway: "My Gateway Name"
|
3
|
+
static_routing_service:
|
4
|
+
:enabled: true
|
5
|
+
:static_routes:
|
6
|
+
- :name: 'Test rule #1'
|
7
|
+
:network: '192.168.192.0/24'
|
8
|
+
:next_hop: '192.168.0.2'
|
9
|
+
:apply_on: 'Network-Name-To-Apply-On'
|
10
|
+
- :name: 'Test rule #2'
|
11
|
+
:network: '192.168.182.0/24'
|
12
|
+
:next_hop: '192.168.0.2'
|
13
|
+
:apply_on: 'Network-Name-To-Apply-On'
|
data/lib/vcloud/edge_gateway.rb
CHANGED
@@ -5,6 +5,7 @@ require 'vcloud/core'
|
|
5
5
|
require 'vcloud/edge_gateway/schema/nat_service'
|
6
6
|
require 'vcloud/edge_gateway/schema/firewall_service'
|
7
7
|
require 'vcloud/edge_gateway/schema/load_balancer_service'
|
8
|
+
require 'vcloud/edge_gateway/schema/static_routing_service'
|
8
9
|
require 'vcloud/edge_gateway/schema/edge_gateway'
|
9
10
|
|
10
11
|
require 'vcloud/edge_gateway/cli'
|
@@ -13,9 +14,10 @@ require 'vcloud/edge_gateway/configuration_generator/id_ranges'
|
|
13
14
|
require 'vcloud/edge_gateway/configuration_generator/firewall_service'
|
14
15
|
require 'vcloud/edge_gateway/configuration_generator/nat_service'
|
15
16
|
require 'vcloud/edge_gateway/configuration_generator/load_balancer_service'
|
17
|
+
require 'vcloud/edge_gateway/configuration_generator/static_routing_service'
|
16
18
|
require 'vcloud/edge_gateway/configuration_differ'
|
17
19
|
require 'vcloud/edge_gateway/nat_configuration_differ'
|
18
20
|
require 'vcloud/edge_gateway/firewall_configuration_differ'
|
19
21
|
require 'vcloud/edge_gateway/load_balancer_configuration_differ'
|
22
|
+
require 'vcloud/edge_gateway/static_routing_configuration_differ'
|
20
23
|
require 'vcloud/edge_gateway/edge_gateway_configuration'
|
21
|
-
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Vcloud
|
2
|
+
module EdgeGateway
|
3
|
+
module ConfigurationGenerator
|
4
|
+
|
5
|
+
class StaticRoutingService
|
6
|
+
def initialize input_config, edge_gateway_interfaces
|
7
|
+
@input_config = input_config
|
8
|
+
@edge_gateway_interfaces = edge_gateway_interfaces
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_fog_config
|
12
|
+
return nil unless @input_config
|
13
|
+
{
|
14
|
+
IsEnabled: routing_enabled?,
|
15
|
+
StaticRoute: generate_static_route_section
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_static_route_section
|
20
|
+
routes = @input_config[:static_routes]
|
21
|
+
return [] if routes.nil?
|
22
|
+
routes.collect do |route|
|
23
|
+
route[:enabled] ||= 'true'
|
24
|
+
{
|
25
|
+
Name: route[:name],
|
26
|
+
Network: route[:network],
|
27
|
+
NextHopIp: route[:next_hop],
|
28
|
+
IsEnabled: route[:enabled],
|
29
|
+
GatewayInterface: generate_gateway_interface_section(route[:apply_on])
|
30
|
+
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_gateway_interface_section(network_name)
|
36
|
+
egw_interface = find_egw_interface(network_name)
|
37
|
+
raise "unable to find gateway network interface with id #{network_id}" unless egw_interface
|
38
|
+
|
39
|
+
{
|
40
|
+
type: "application/vnd.vmware.vcloud.orgVdcNetwork+xml",
|
41
|
+
name: egw_interface.network_name,
|
42
|
+
href: egw_interface.network_href
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def routing_enabled?
|
47
|
+
return 'false' unless @input_config
|
48
|
+
@input_config.key?(:enabled) ? @input_config[:enabled].to_s : 'true'
|
49
|
+
end
|
50
|
+
|
51
|
+
def find_egw_interface(network_name)
|
52
|
+
@edge_gateway_interfaces.find{|i| i.network_name == network_name}
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -64,6 +64,21 @@ module Vcloud
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
static_routing_service_config = EdgeGateway::ConfigurationGenerator::StaticRoutingService.new(
|
68
|
+
local_config[:static_routing_service],
|
69
|
+
edge_gateway_interfaces
|
70
|
+
).generate_fog_config
|
71
|
+
|
72
|
+
unless static_routing_service_config.nil?
|
73
|
+
differ = EdgeGateway::StaticRoutingConfigurationDiffer.new(
|
74
|
+
remote_config[:StaticRoutingService],
|
75
|
+
static_routing_service_config
|
76
|
+
)
|
77
|
+
unless differ.diff.empty?
|
78
|
+
diff[:StaticRoutingService] = differ.diff
|
79
|
+
new_config[:StaticRoutingService] = static_routing_service_config
|
80
|
+
end
|
81
|
+
end
|
67
82
|
return new_config, diff
|
68
83
|
end
|
69
84
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Vcloud
|
2
|
+
module EdgeGateway
|
3
|
+
module Schema
|
4
|
+
STATIC_ROUTE = {
|
5
|
+
type: Hash,
|
6
|
+
internals: {
|
7
|
+
enabled: { type: 'boolean', required: false },
|
8
|
+
name: { type: 'string', required: true },
|
9
|
+
network: { type: 'ip_address_range', required: true },
|
10
|
+
next_hop: { type: 'ip_address', required: true },
|
11
|
+
apply_on: { type: 'string', required: true }
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
STATIC_ROUTING_SERVICE = {
|
17
|
+
type: Hash,
|
18
|
+
allowed_empty: true,
|
19
|
+
required: false,
|
20
|
+
internals: {
|
21
|
+
enabled: { type: 'boolean', required: false },
|
22
|
+
static_routes: {
|
23
|
+
type: Array,
|
24
|
+
required: false,
|
25
|
+
allowed_empty: true,
|
26
|
+
each_element_is: STATIC_ROUTE
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vcloud
|
2
|
+
module EdgeGateway
|
3
|
+
class StaticRoutingConfigurationDiffer < ConfigurationDiffer
|
4
|
+
def strip_fields_for_differ_to_ignore(config)
|
5
|
+
remote_cfg = Marshal.load(Marshal.dump(config))
|
6
|
+
if remote_cfg.key?(:StaticRoute)
|
7
|
+
remote_cfg[:StaticRoute].each do |route_rule|
|
8
|
+
route_rule.delete(:IsEnabled)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
remote_cfg
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
module Vcloud
|
5
|
+
describe EdgeGateway::Configure do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
config_file = File.join(File.dirname(__FILE__), "../vcloud_tools_testing_config.yaml")
|
9
|
+
required_user_params = [
|
10
|
+
"edge_gateway",
|
11
|
+
"provider_network",
|
12
|
+
"provider_network_default_gateway"
|
13
|
+
]
|
14
|
+
|
15
|
+
@test_params = Vcloud::Tools::Tester::TestSetup.new(config_file, required_user_params).test_params
|
16
|
+
@files_to_delete = []
|
17
|
+
end
|
18
|
+
|
19
|
+
context "Test StaticRoutingService specifics" do
|
20
|
+
|
21
|
+
before(:all) do
|
22
|
+
reset_edge_gateway
|
23
|
+
@vars_config_file = generate_vars_file(edge_gateway_vars_hash)
|
24
|
+
@initial_static_routing_config_file = IntegrationHelper.fixture_file('static_routing_config.yaml.mustache')
|
25
|
+
@edge_gateway = Vcloud::Core::EdgeGateway.get_by_name(@test_params.edge_gateway)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "Check update is functional" do
|
29
|
+
|
30
|
+
before(:all) do
|
31
|
+
local_config = Core::ConfigLoader.new.load_config(
|
32
|
+
@initial_static_routing_config_file,
|
33
|
+
Vcloud::EdgeGateway::Schema::EDGE_GATEWAY_SERVICES,
|
34
|
+
@vars_config_file
|
35
|
+
)
|
36
|
+
@local_vcloud_config = EdgeGateway::ConfigurationGenerator::StaticRoutingService.new(
|
37
|
+
local_config[:static_routing_service],
|
38
|
+
@edge_gateway.interfaces
|
39
|
+
).generate_fog_config
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be starting our tests from an empty StaticRoutingService" do
|
43
|
+
edge_service_config = @edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
44
|
+
remote_vcloud_config = edge_service_config[:StaticRoutingService]
|
45
|
+
if remote_vcloud_config
|
46
|
+
expect(remote_vcloud_config[:StaticRoute].nil?).to be_true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should only make one EdgeGateway update task, to minimise EdgeGateway reload events" do
|
51
|
+
start_time = Time.now.getutc
|
52
|
+
task_list_before_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
53
|
+
diff = EdgeGateway::Configure.new(@initial_static_routing_config_file, @vars_config_file).update
|
54
|
+
task_list_after_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
55
|
+
|
56
|
+
expect(diff.keys).to eq([:StaticRoutingService])
|
57
|
+
expect(diff[:StaticRoutingService]).to have_at_least(1).items
|
58
|
+
expect(task_list_after_update.size - task_list_before_update.size).to be(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should have configured at least one static route" do
|
62
|
+
edge_service_config = @edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
63
|
+
remote_vcloud_config = edge_service_config[:StaticRoutingService]
|
64
|
+
expect(remote_vcloud_config[:StaticRoute].empty?).to be_false
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have configured the same number of static routes as in our configuration" do
|
68
|
+
edge_service_config = @edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
69
|
+
remote_vcloud_config = edge_service_config[:StaticRoutingService]
|
70
|
+
expect(remote_vcloud_config[:StaticRoute].size).
|
71
|
+
to eq(@local_vcloud_config[:StaticRoute].size)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
it "should not then configure the StaticRoutingService if updated again with the same configuration" do
|
76
|
+
expect(Vcloud::Core.logger).to receive(:info).
|
77
|
+
with('EdgeGateway::Configure.update: Configuration is already up to date. Skipping.')
|
78
|
+
diff = EdgeGateway::Configure.new(@initial_static_routing_config_file, @vars_config_file).update
|
79
|
+
|
80
|
+
expect(diff).to eq({})
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
context "Check specific StaticRoutingService update cases" do
|
86
|
+
|
87
|
+
it "should be able to configure with no static routes" do
|
88
|
+
config_file = IntegrationHelper.fixture_file('static_routing_empty.yaml.mustache')
|
89
|
+
diff = EdgeGateway::Configure.new(config_file, @vars_config_file).update
|
90
|
+
edge_config = @edge_gateway.vcloud_attributes[:Configuration]
|
91
|
+
remote_vcloud_config = edge_config[:EdgeGatewayServiceConfiguration][:StaticRoutingService]
|
92
|
+
|
93
|
+
expect(diff.keys).to eq([:StaticRoutingService])
|
94
|
+
expect(diff[:StaticRoutingService]).to have_at_least(1).items
|
95
|
+
expect(remote_vcloud_config[:StaticRoute].nil?).to be_true
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
after(:all) do
|
101
|
+
IntegrationHelper.remove_temp_config_files(@files_to_delete)
|
102
|
+
end
|
103
|
+
|
104
|
+
def reset_edge_gateway
|
105
|
+
edge_gateway = Core::EdgeGateway.get_by_name @test_params.edge_gateway
|
106
|
+
edge_gateway.update_configuration({
|
107
|
+
StaticRoutingService: {
|
108
|
+
IsEnabled: "false",
|
109
|
+
StaticRoute: []
|
110
|
+
}
|
111
|
+
})
|
112
|
+
end
|
113
|
+
|
114
|
+
def generate_vars_file(vars_hash)
|
115
|
+
file = Tempfile.new('vars_file')
|
116
|
+
file.write(vars_hash.to_yaml)
|
117
|
+
file.close
|
118
|
+
@files_to_delete << file
|
119
|
+
|
120
|
+
file.path
|
121
|
+
end
|
122
|
+
|
123
|
+
def edge_gateway_vars_hash
|
124
|
+
{
|
125
|
+
:edge_gateway_name => @test_params.edge_gateway,
|
126
|
+
:edge_gateway_ext_network_name => @test_params.provider_network,
|
127
|
+
:edge_gateway_ext_default_gateway => @test_params.provider_network_default_gateway
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(timestamp)
|
132
|
+
vcloud_time = timestamp.strftime('%FT%T.000Z')
|
133
|
+
q = Vcloud::Core::QueryRunner.new
|
134
|
+
q.run('task',
|
135
|
+
:filter =>
|
136
|
+
"name==networkConfigureEdgeGatewayServices;objectName==#{@test_params.edge_gateway};startDate=ge=#{vcloud_time}",
|
137
|
+
:sortDesc => 'startDate',
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
gateway: {{ edge_gateway_name }}
|
3
|
+
static_routing_service:
|
4
|
+
static_routes:
|
5
|
+
- enabled: true
|
6
|
+
name: 'A rule #1'
|
7
|
+
network: '192.168.192.0/24'
|
8
|
+
next_hop: {{ edge_gateway_ext_default_gateway }}
|
9
|
+
apply_on: {{ edge_gateway_ext_network_name }}
|
10
|
+
- enabled: true
|
11
|
+
name: 'A rule #2'
|
12
|
+
network: '192.168.193.0/24'
|
13
|
+
next_hop: {{ edge_gateway_ext_default_gateway }}
|
14
|
+
apply_on: {{ edge_gateway_ext_network_name }}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Vcloud
|
4
|
+
module EdgeGateway
|
5
|
+
module ConfigurationGenerator
|
6
|
+
describe StaticRoutingService do
|
7
|
+
before(:each) do
|
8
|
+
mock_uplink_interface = double(
|
9
|
+
:mock_uplink,
|
10
|
+
:network_name => "ane012345",
|
11
|
+
:network_id => "2ad93597-7b54-43dd-9eb1-631dd337e5a7",
|
12
|
+
:network_href => "https://vmware.api.net/api/admin/network/2ad93597-7b54-43dd-9eb1-631dd337e5a7",
|
13
|
+
)
|
14
|
+
mock_internal_interface = double(
|
15
|
+
:mock_uplink,
|
16
|
+
:network_name => "internal_interface",
|
17
|
+
:network_id => "12346788-1234-1234-1234-123456789000",
|
18
|
+
:network_href => "https://vmware.api.net/api/admin/network/12346788-1234-1234-1234-123456789000",
|
19
|
+
)
|
20
|
+
@edge_gw_interface_list = [ mock_internal_interface, mock_uplink_interface ]
|
21
|
+
end
|
22
|
+
|
23
|
+
context "top level static routing configuration defaults" do
|
24
|
+
|
25
|
+
it 'should default to StaticRoutingService enabled' do
|
26
|
+
@output = StaticRoutingService.new({}, @edge_gw_interface_list).generate_fog_config
|
27
|
+
expect(@output[:IsEnabled]).to eq('true')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "static routing defaults" do
|
32
|
+
|
33
|
+
before(:each) do
|
34
|
+
routes = { static_routes: [{
|
35
|
+
name: "Test Route",
|
36
|
+
network: "192.2.0.0/24",
|
37
|
+
next_hop: "192.168.1.1",
|
38
|
+
apply_on: "ane012345"
|
39
|
+
}]}
|
40
|
+
output = StaticRoutingService.new(routes,@edge_gw_interface_list).generate_fog_config
|
41
|
+
@route = output[:StaticRoute].first
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should default to route being enabled' do
|
45
|
+
expect(@route[:IsEnabled]).to eq('true')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should have name set' do
|
49
|
+
expect(@route[:Name]).to eq('Test Route')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should have next hop set' do
|
53
|
+
expect(@route[:NextHopIp]).to eq('192.168.1.1')
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should have correct gateway interface set' do
|
57
|
+
interface = @route[:GatewayInterface]
|
58
|
+
expect(interface[:name]).to eq('ane012345')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "static route config generation" do
|
63
|
+
|
64
|
+
it 'should have disabled firewall with a disabled rule' do
|
65
|
+
input = {
|
66
|
+
static_routes: [{
|
67
|
+
name: 'Disabled route',
|
68
|
+
enabled: 'false',
|
69
|
+
network: '192.192.192.0/24',
|
70
|
+
next_hop: '192.192.182.1',
|
71
|
+
apply_on: 'ane012345'
|
72
|
+
}]
|
73
|
+
}
|
74
|
+
output = {
|
75
|
+
IsEnabled: 'true',
|
76
|
+
StaticRoute: [
|
77
|
+
{
|
78
|
+
Name: 'Disabled route',
|
79
|
+
Network: '192.192.192.0/24',
|
80
|
+
NextHopIp: '192.192.182.1',
|
81
|
+
IsEnabled: 'false',
|
82
|
+
GatewayInterface: {
|
83
|
+
type: 'application/vnd.vmware.vcloud.orgVdcNetwork+xml',
|
84
|
+
name: 'ane012345',
|
85
|
+
href: 'https://vmware.api.net/api/admin/network/2ad93597-7b54-43dd-9eb1-631dd337e5a7'
|
86
|
+
}
|
87
|
+
}
|
88
|
+
]
|
89
|
+
}
|
90
|
+
generated_config = StaticRoutingService.new(input, @edge_gw_interface_list).generate_fog_config
|
91
|
+
expect(generated_config).to eq(output)
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -23,11 +23,13 @@ module Vcloud
|
|
23
23
|
:nat_service => test_nat_config,
|
24
24
|
:firewall_service => test_firewall_config,
|
25
25
|
:load_balancer_service => test_load_balancer_config,
|
26
|
+
:static_routing_service => test_static_routing_config
|
26
27
|
}
|
27
28
|
@remote_config = {
|
28
29
|
:FirewallService => different_firewall_config,
|
29
30
|
:NatService => different_nat_config,
|
30
31
|
:LoadBalancerService => different_load_balancer_config,
|
32
|
+
:StaticRoutingService => different_static_routing_config
|
31
33
|
}
|
32
34
|
@proposed_config = EdgeGateway::EdgeGatewayConfiguration.new(
|
33
35
|
@test_config,
|
@@ -628,6 +630,18 @@ module Vcloud
|
|
628
630
|
}
|
629
631
|
end
|
630
632
|
|
633
|
+
|
634
|
+
def test_static_routing_config
|
635
|
+
{
|
636
|
+
:static_routes => [{
|
637
|
+
name: 'Test route',
|
638
|
+
network: '192.192.192.0/24',
|
639
|
+
next_hop: '192.192.182.1',
|
640
|
+
apply_on: 'ane012345'
|
641
|
+
}]
|
642
|
+
}
|
643
|
+
end
|
644
|
+
|
631
645
|
def test_load_balancer_config
|
632
646
|
{
|
633
647
|
enabled: 'true',
|
@@ -706,6 +720,22 @@ module Vcloud
|
|
706
720
|
}
|
707
721
|
end
|
708
722
|
|
723
|
+
def different_static_routing_config
|
724
|
+
{
|
725
|
+
:StaticRoutingService => [{
|
726
|
+
Name: 'Different rule',
|
727
|
+
IsEnabled: 'false',
|
728
|
+
Network: '192.192.193.0/24',
|
729
|
+
NextHopIp: '192.192.182.1',
|
730
|
+
GatewayInterface: {
|
731
|
+
type: 'application/vnd.vmware.vcloud.orgVdcNetwork+xml',
|
732
|
+
name: 'ane012345',
|
733
|
+
href: 'https://vmware.api.net/api/admin/network/2ad93597-7b54-43dd-9eb1-631dd337e5a7'
|
734
|
+
}
|
735
|
+
}]
|
736
|
+
}
|
737
|
+
end
|
738
|
+
|
709
739
|
def different_load_balancer_config
|
710
740
|
{
|
711
741
|
:IsEnabled=>"true",
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Vcloud
|
4
|
+
describe 'static_routing_service_schema_validations' do
|
5
|
+
context 'source and destination ips' do
|
6
|
+
it 'should error if network or next_hop IPs are invalid' do
|
7
|
+
config = {
|
8
|
+
static_routes: [
|
9
|
+
{
|
10
|
+
name: 'Some Name',
|
11
|
+
network: '10.10.10.10/256',
|
12
|
+
next_hop: '192.1',
|
13
|
+
apply_on: 'interface'
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
17
|
+
validator = Vcloud::Core::ConfigValidator.validate(:base, config, Vcloud::EdgeGateway::Schema::STATIC_ROUTING_SERVICE)
|
18
|
+
expect(validator.valid?).to be_false
|
19
|
+
expect(validator.errors).to eq([
|
20
|
+
"network: 10.10.10.10/256 is not a valid IP address range. Valid values can be IP address, CIDR, IP range, 'Any','internal' and 'external'.",
|
21
|
+
"next_hop: 192.1 is not a valid ip_address",
|
22
|
+
])
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should validate OK if source_ip/destination_ip are valid IPs' do
|
26
|
+
config = {
|
27
|
+
static_routes: [
|
28
|
+
{
|
29
|
+
name: 'Some Name',
|
30
|
+
network: '10.10.10.0/24',
|
31
|
+
next_hop: '192.168.0.1',
|
32
|
+
apply_on: 'interface'
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
validator = Vcloud::Core::ConfigValidator.validate(:base, config, Vcloud::EdgeGateway::Schema::STATIC_ROUTING_SERVICE)
|
37
|
+
expect(validator.valid?).to be_true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcloud-edge_gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: vcloud-core
|
16
|
-
requirement: &
|
16
|
+
requirement: &19376300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19376300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hashdiff
|
27
|
-
requirement: &
|
27
|
+
requirement: &19375620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19375620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: pry
|
38
|
-
requirement: &
|
38
|
+
requirement: &19374700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *19374700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &19373680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *19373680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &19370360 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.14.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *19370360
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop
|
71
|
-
requirement: &
|
71
|
+
requirement: &19383420 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.23.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *19383420
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: simplecov
|
82
|
-
requirement: &
|
82
|
+
requirement: &19382600 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.7.1
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *19382600
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: gem_publisher
|
93
|
-
requirement: &
|
93
|
+
requirement: &19380820 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - =
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.2.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *19380820
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: vcloud-tools-tester
|
104
|
-
requirement: &
|
104
|
+
requirement: &19379340 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 1.0.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *19379340
|
113
113
|
description: Tool to configure a VMware vCloud Edge Gateway. Uses vcloud-core.
|
114
114
|
email:
|
115
115
|
- anna.shipman@digital.cabinet-office.gov.uk
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- examples/vcloud-configure-edge/firewall-rules.yaml
|
133
133
|
- examples/vcloud-configure-edge/loadbalancer-rules.yaml
|
134
134
|
- examples/vcloud-configure-edge/nat-rules.yaml
|
135
|
+
- examples/vcloud-configure-edge/static-routing-rules.yaml
|
135
136
|
- examples/vcloud-configure-edge/template-nat-rules.yaml.mustache
|
136
137
|
- examples/vcloud-configure-edge/template-vars-env1.yaml
|
137
138
|
- examples/vcloud-configure-edge/template-vars-env2.yaml
|
@@ -144,6 +145,7 @@ files:
|
|
144
145
|
- lib/vcloud/edge_gateway/configuration_generator/id_ranges.rb
|
145
146
|
- lib/vcloud/edge_gateway/configuration_generator/load_balancer_service.rb
|
146
147
|
- lib/vcloud/edge_gateway/configuration_generator/nat_service.rb
|
148
|
+
- lib/vcloud/edge_gateway/configuration_generator/static_routing_service.rb
|
147
149
|
- lib/vcloud/edge_gateway/configure.rb
|
148
150
|
- lib/vcloud/edge_gateway/edge_gateway_configuration.rb
|
149
151
|
- lib/vcloud/edge_gateway/firewall_configuration_differ.rb
|
@@ -153,12 +155,14 @@ files:
|
|
153
155
|
- lib/vcloud/edge_gateway/schema/firewall_service.rb
|
154
156
|
- lib/vcloud/edge_gateway/schema/load_balancer_service.rb
|
155
157
|
- lib/vcloud/edge_gateway/schema/nat_service.rb
|
158
|
+
- lib/vcloud/edge_gateway/schema/static_routing_service.rb
|
159
|
+
- lib/vcloud/edge_gateway/static_routing_configuration_differ.rb
|
156
160
|
- lib/vcloud/edge_gateway/version.rb
|
157
|
-
- spec/integration/README.md
|
158
161
|
- spec/integration/edge_gateway/configure_firewall_spec.rb
|
159
162
|
- spec/integration/edge_gateway/configure_load_balancer_spec.rb
|
160
163
|
- spec/integration/edge_gateway/configure_multiple_services_spec.rb
|
161
164
|
- spec/integration/edge_gateway/configure_nat_spec.rb
|
165
|
+
- spec/integration/edge_gateway/configure_static_routing_spec.rb
|
162
166
|
- spec/integration/edge_gateway/data/firewall_config.yaml.mustache
|
163
167
|
- spec/integration/edge_gateway/data/firewall_config_updated_rule.yaml.mustache
|
164
168
|
- spec/integration/edge_gateway/data/firewall_rule_order_test.yaml.mustache
|
@@ -172,6 +176,8 @@ files:
|
|
172
176
|
- spec/integration/edge_gateway/data/nat_and_firewall_config.yaml.mustache
|
173
177
|
- spec/integration/edge_gateway/data/nat_and_firewall_plus_load_balancer_config.yaml.mustache
|
174
178
|
- spec/integration/edge_gateway/data/nat_config.yaml.mustache
|
179
|
+
- spec/integration/edge_gateway/data/static_routing_config.yaml.mustache
|
180
|
+
- spec/integration/edge_gateway/data/static_routing_empty.yaml.mustache
|
175
181
|
- spec/integration/vcloud_tools_testing_config.yaml.template
|
176
182
|
- spec/spec_helper.rb
|
177
183
|
- spec/support/integration_helper.rb
|
@@ -190,6 +196,7 @@ files:
|
|
190
196
|
- spec/vcloud/edge_gateway/configuration_generator/firewall_service_spec.rb
|
191
197
|
- spec/vcloud/edge_gateway/configuration_generator/load_balancer_service_spec.rb
|
192
198
|
- spec/vcloud/edge_gateway/configuration_generator/nat_service_spec.rb
|
199
|
+
- spec/vcloud/edge_gateway/configuration_generator/static_routing_service_spec.rb
|
193
200
|
- spec/vcloud/edge_gateway/configure_spec.rb
|
194
201
|
- spec/vcloud/edge_gateway/edge_gateway_configuration_spec.rb
|
195
202
|
- spec/vcloud/edge_gateway/firewall_configuration_differ_spec.rb
|
@@ -198,6 +205,7 @@ files:
|
|
198
205
|
- spec/vcloud/edge_gateway/load_balancer_schema_validation_spec.rb
|
199
206
|
- spec/vcloud/edge_gateway/nat_configuration_differ_spec.rb
|
200
207
|
- spec/vcloud/edge_gateway/nat_schema_validation_spec.rb
|
208
|
+
- spec/vcloud/edge_gateway/static_routing_schema_validation_spec.rb
|
201
209
|
- vcloud-edge_gateway.gemspec
|
202
210
|
homepage: http://github.com/gds-operations/vcloud-edge_gateway
|
203
211
|
licenses:
|
@@ -220,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
228
|
version: '0'
|
221
229
|
segments:
|
222
230
|
- 0
|
223
|
-
hash:
|
231
|
+
hash: 3095233766048741
|
224
232
|
requirements: []
|
225
233
|
rubyforge_project:
|
226
234
|
rubygems_version: 1.8.11
|
@@ -228,11 +236,11 @@ signing_key:
|
|
228
236
|
specification_version: 3
|
229
237
|
summary: Tool to configure a VMware vCloud Edge Gateway
|
230
238
|
test_files:
|
231
|
-
- spec/integration/README.md
|
232
239
|
- spec/integration/edge_gateway/configure_firewall_spec.rb
|
233
240
|
- spec/integration/edge_gateway/configure_load_balancer_spec.rb
|
234
241
|
- spec/integration/edge_gateway/configure_multiple_services_spec.rb
|
235
242
|
- spec/integration/edge_gateway/configure_nat_spec.rb
|
243
|
+
- spec/integration/edge_gateway/configure_static_routing_spec.rb
|
236
244
|
- spec/integration/edge_gateway/data/firewall_config.yaml.mustache
|
237
245
|
- spec/integration/edge_gateway/data/firewall_config_updated_rule.yaml.mustache
|
238
246
|
- spec/integration/edge_gateway/data/firewall_rule_order_test.yaml.mustache
|
@@ -246,6 +254,8 @@ test_files:
|
|
246
254
|
- spec/integration/edge_gateway/data/nat_and_firewall_config.yaml.mustache
|
247
255
|
- spec/integration/edge_gateway/data/nat_and_firewall_plus_load_balancer_config.yaml.mustache
|
248
256
|
- spec/integration/edge_gateway/data/nat_config.yaml.mustache
|
257
|
+
- spec/integration/edge_gateway/data/static_routing_config.yaml.mustache
|
258
|
+
- spec/integration/edge_gateway/data/static_routing_empty.yaml.mustache
|
249
259
|
- spec/integration/vcloud_tools_testing_config.yaml.template
|
250
260
|
- spec/spec_helper.rb
|
251
261
|
- spec/support/integration_helper.rb
|
@@ -264,6 +274,7 @@ test_files:
|
|
264
274
|
- spec/vcloud/edge_gateway/configuration_generator/firewall_service_spec.rb
|
265
275
|
- spec/vcloud/edge_gateway/configuration_generator/load_balancer_service_spec.rb
|
266
276
|
- spec/vcloud/edge_gateway/configuration_generator/nat_service_spec.rb
|
277
|
+
- spec/vcloud/edge_gateway/configuration_generator/static_routing_service_spec.rb
|
267
278
|
- spec/vcloud/edge_gateway/configure_spec.rb
|
268
279
|
- spec/vcloud/edge_gateway/edge_gateway_configuration_spec.rb
|
269
280
|
- spec/vcloud/edge_gateway/firewall_configuration_differ_spec.rb
|
@@ -272,3 +283,4 @@ test_files:
|
|
272
283
|
- spec/vcloud/edge_gateway/load_balancer_schema_validation_spec.rb
|
273
284
|
- spec/vcloud/edge_gateway/nat_configuration_differ_spec.rb
|
274
285
|
- spec/vcloud/edge_gateway/nat_schema_validation_spec.rb
|
286
|
+
- spec/vcloud/edge_gateway/static_routing_schema_validation_spec.rb
|
data/spec/integration/README.md
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Running vCloud Edge Gateway Integration Tests
|
2
|
-
|
3
|
-
## Prerequisites
|
4
|
-
|
5
|
-
- Access to a suitable vCloud Director organisation.
|
6
|
-
|
7
|
-
**NB** It is not safe to run them against an environment that is in use
|
8
|
-
(e.g. production, preview) as many of the tests clear down all config at
|
9
|
-
the beginning and/or end to ensure the environment is as the tests expect.
|
10
|
-
|
11
|
-
- A config file with the settings configured.
|
12
|
-
|
13
|
-
There is a [template file](spec/integration/vcloud_tools_testing_config.yaml.template) to
|
14
|
-
help with this. Copy the template file to `spec/integration/vcloud_tools_testing_config.yaml`
|
15
|
-
and update with parameters suitable for your environment.
|
16
|
-
|
17
|
-
- You need to include the set-up for your testing environment in your
|
18
|
-
[fog file](https://github.com/gds-operations/vcloud-core#credentials).
|
19
|
-
|
20
|
-
- The tests use the [vCloud Tools Tester](http://rubygems.org/gems/vcloud-tools-tester) gem.
|
21
|
-
You do not need to install this, `bundler` will do this for you.
|
22
|
-
|
23
|
-
## Parameters
|
24
|
-
|
25
|
-
````
|
26
|
-
default: # This is the fog credential that refers to your testing environment, e.g. `test_credential`
|
27
|
-
network_1: # Primary network name
|
28
|
-
network_1_id: # Primary network ID
|
29
|
-
network_1_ip: # Primary network IP
|
30
|
-
edge_gateway: # Edge gateway name
|
31
|
-
provider_network: # Provider (external-facing) network name
|
32
|
-
provider_network_id: # Provider network ID
|
33
|
-
provider_network_ip: # Provider network IP
|
34
|
-
````
|
35
|
-
|
36
|
-
## To run the tests
|
37
|
-
|
38
|
-
`FOG_CREDENTIAL=test_credential bundle exec integration`
|