vcloud-edge_gateway 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -0
- data/jenkins_integration_tests.sh +8 -0
- data/lib/vcloud/edge_gateway/configuration_generator/load_balancer_service.rb +1 -7
- data/lib/vcloud/edge_gateway/configuration_generator/nat_service.rb +16 -6
- data/lib/vcloud/edge_gateway/edge_gateway_configuration.rb +34 -9
- data/lib/vcloud/edge_gateway/load_balancer_configuration_differ.rb +28 -0
- data/lib/vcloud/edge_gateway/version.rb +1 -1
- data/lib/vcloud/edge_gateway.rb +1 -0
- data/lib/vcloud/edge_gateway_services.rb +9 -4
- data/lib/vcloud/schema/edge_gateway.rb +2 -1
- data/lib/vcloud/schema/load_balancer_service.rb +3 -2
- data/spec/erb_helper.rb +1 -1
- data/spec/integration/edge_gateway/data/load_balancer_config.yaml.erb +24 -0
- data/spec/integration/edge_gateway/data/load_balancer_empty.yaml.erb +4 -0
- data/spec/integration/edge_gateway/data/load_balancer_single_pool.yaml.erb +15 -0
- data/spec/integration/edge_gateway/data/load_balancer_single_virtual_server_invalid_pool.yaml.erb +13 -0
- data/spec/integration/edge_gateway/data/load_balancer_single_virtual_server_missing_pool.yaml.erb +12 -0
- data/spec/integration/edge_gateway/data/nat_and_firewall_plus_load_balancer_config.yaml.erb +54 -0
- data/spec/integration/edge_gateway/edge_gateway_services_spec.rb +52 -23
- data/spec/integration/edge_gateway/load_balancer_service_spec.rb +204 -0
- data/spec/integration/edge_gateway/nat_service_spec.rb +7 -2
- data/spec/vcloud/edge_gateway/configuration_generator/data/load_balancer_http-output.yaml +2 -2
- data/spec/vcloud/edge_gateway/configuration_generator/data/load_balancer_https-output.yaml +2 -0
- data/spec/vcloud/edge_gateway/configuration_generator/data/load_balancer_mixed_complex-output.yaml +1 -0
- data/spec/vcloud/edge_gateway/configuration_generator/load_balancer_service_spec.rb +2 -0
- data/spec/vcloud/edge_gateway/configuration_generator/nat_service_spec.rb +198 -94
- data/spec/vcloud/edge_gateway/edge_gateway_configuration_spec.rb +1043 -88
- data/spec/vcloud/edge_gateway/load_balancer_configuration_differ_spec.rb +160 -0
- data/spec/vcloud/edge_gateway/load_balancer_schema_validation_spec.rb +4 -6
- data/vcloud-edge_gateway.gemspec +1 -1
- metadata +24 -5
data/CHANGELOG.md
ADDED
@@ -197,13 +197,7 @@ module Vcloud
|
|
197
197
|
vcloud_pool_healthcheck_entry = {
|
198
198
|
Mode: default_mode,
|
199
199
|
}
|
200
|
-
|
201
|
-
vcloud_pool_healthcheck_entry[:Uri] = ''
|
202
|
-
elsif ( protocol == :https ) &&
|
203
|
-
input_pool_healthcheck_entry &&
|
204
|
-
( input_pool_healthcheck_entry[:protocol] == 'TCP' )
|
205
|
-
vcloud_pool_healthcheck_entry[:Uri] = ''
|
206
|
-
end
|
200
|
+
vcloud_pool_healthcheck_entry[:Uri] = ''
|
207
201
|
vcloud_pool_healthcheck_entry[:HealthThreshold] = '2'
|
208
202
|
vcloud_pool_healthcheck_entry[:UnhealthThreshold] = '3'
|
209
203
|
vcloud_pool_healthcheck_entry[:Interval] = '5'
|
@@ -3,10 +3,9 @@ module Vcloud
|
|
3
3
|
module ConfigurationGenerator
|
4
4
|
|
5
5
|
class NatService
|
6
|
-
def initialize
|
7
|
-
@edge_gateway = Vcloud::Core::EdgeGateway.get_by_name(edge_gateway)
|
6
|
+
def initialize input_config, edge_gateway_interfaces
|
8
7
|
@input_config = input_config
|
9
|
-
@
|
8
|
+
@edge_gateway_interfaces = edge_gateway_interfaces
|
10
9
|
end
|
11
10
|
|
12
11
|
def generate_fog_config
|
@@ -35,9 +34,12 @@ module Vcloud
|
|
35
34
|
|
36
35
|
def populate_gateway_nat_rule(rule)
|
37
36
|
raise "Must supply a :network_id parameter" unless net_id = rule[:network_id]
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
edge_gw_interface = @edge_gateway_interfaces.find do |interface|
|
38
|
+
interface.network_id == net_id
|
39
|
+
end
|
40
|
+
raise "unable to find gateway network interface with id #{net_id}" unless edge_gw_interface
|
41
|
+
gateway_nat_rule = {}
|
42
|
+
gateway_nat_rule[:Interface] = populate_nat_interface(edge_gw_interface)
|
41
43
|
gateway_nat_rule[:OriginalIp] = rule[:original_ip]
|
42
44
|
gateway_nat_rule[:TranslatedIp] = rule[:translated_ip]
|
43
45
|
gateway_nat_rule[:OriginalPort] = rule[:original_port] if rule.key?(:original_port)
|
@@ -48,6 +50,14 @@ module Vcloud
|
|
48
50
|
gateway_nat_rule
|
49
51
|
end
|
50
52
|
|
53
|
+
def populate_nat_interface(edge_interface)
|
54
|
+
vcloud_interface = {}
|
55
|
+
vcloud_interface[:type] = 'application/vnd.vmware.admin.network+xml'
|
56
|
+
vcloud_interface[:name] = edge_interface.network_name
|
57
|
+
vcloud_interface[:href] = edge_interface.network_href
|
58
|
+
vcloud_interface
|
59
|
+
end
|
60
|
+
|
51
61
|
end
|
52
62
|
end
|
53
63
|
end
|
@@ -2,37 +2,62 @@ module Vcloud
|
|
2
2
|
module EdgeGateway
|
3
3
|
class EdgeGatewayConfiguration
|
4
4
|
|
5
|
-
def initialize(local_config)
|
5
|
+
def initialize(local_config, remote_config, edge_gateway_interfaces)
|
6
6
|
@local_config = local_config
|
7
|
+
@remote_config = remote_config
|
8
|
+
@edge_gateway_interfaces = edge_gateway_interfaces
|
7
9
|
@config = { }
|
10
|
+
@update_required = nil
|
8
11
|
end
|
9
12
|
|
10
|
-
def update_required?
|
11
|
-
update_required = false
|
13
|
+
def update_required?
|
14
|
+
@update_required = false
|
12
15
|
|
13
16
|
firewall_service_config = EdgeGateway::ConfigurationGenerator::FirewallService.new.generate_fog_config(@local_config[:firewall_service])
|
14
17
|
unless firewall_service_config.nil?
|
15
|
-
differ = EdgeGateway::ConfigurationDiffer.new(firewall_service_config, remote_config[:FirewallService])
|
18
|
+
differ = EdgeGateway::ConfigurationDiffer.new(firewall_service_config, @remote_config[:FirewallService])
|
16
19
|
unless differ.diff.empty?
|
17
20
|
@config[:FirewallService] = firewall_service_config
|
18
|
-
update_required = true
|
21
|
+
@update_required = true
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
|
-
nat_service_config = EdgeGateway::ConfigurationGenerator::NatService.new(
|
25
|
+
nat_service_config = EdgeGateway::ConfigurationGenerator::NatService.new(
|
26
|
+
@local_config[:nat_service],
|
27
|
+
@edge_gateway_interfaces
|
28
|
+
).generate_fog_config
|
23
29
|
|
24
30
|
unless nat_service_config.nil?
|
25
|
-
differ = EdgeGateway::ConfigurationDiffer.new(nat_service_config, remote_config[:NatService])
|
31
|
+
differ = EdgeGateway::ConfigurationDiffer.new(nat_service_config, @remote_config[:NatService])
|
26
32
|
unless differ.diff.empty?
|
27
33
|
@config[:NatService] = nat_service_config
|
28
|
-
update_required = true
|
34
|
+
@update_required = true
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
32
|
-
|
38
|
+
load_balancer_service_config =
|
39
|
+
EdgeGateway::ConfigurationGenerator::LoadBalancerService.new(
|
40
|
+
@local_config[:gateway]
|
41
|
+
).generate_fog_config(@local_config[:load_balancer_service])
|
42
|
+
|
43
|
+
unless load_balancer_service_config.nil?
|
44
|
+
differ = EdgeGateway::LoadBalancerConfigurationDiffer.new(
|
45
|
+
load_balancer_service_config,
|
46
|
+
@remote_config[:LoadBalancerService]
|
47
|
+
)
|
48
|
+
unless differ.diff.empty?
|
49
|
+
@config[:LoadBalancerService] = load_balancer_service_config
|
50
|
+
@update_required = true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
@update_required
|
33
55
|
end
|
34
56
|
|
35
57
|
def config
|
58
|
+
if @update_required.nil?
|
59
|
+
update_required?
|
60
|
+
end
|
36
61
|
@config
|
37
62
|
end
|
38
63
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Vcloud
|
2
|
+
module EdgeGateway
|
3
|
+
class LoadBalancerConfigurationDiffer
|
4
|
+
|
5
|
+
def initialize local, remote
|
6
|
+
@local = local
|
7
|
+
@remote = remote
|
8
|
+
end
|
9
|
+
|
10
|
+
def diff
|
11
|
+
( @local == stripped_remote_config ) ? [] : HashDiff.diff(@local, stripped_remote_config)
|
12
|
+
end
|
13
|
+
|
14
|
+
def stripped_remote_config
|
15
|
+
return nil if @remote.nil?
|
16
|
+
deep_cloned_remote_config = Marshal.load( Marshal.dump(@remote) )
|
17
|
+
if deep_cloned_remote_config.key?(:Pool)
|
18
|
+
deep_cloned_remote_config[:Pool].each do |pool_entry|
|
19
|
+
pool_entry.delete(:Operational)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
deep_cloned_remote_config
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/vcloud/edge_gateway.rb
CHANGED
@@ -18,6 +18,7 @@ require 'vcloud/edge_gateway/configuration_generator/firewall_service'
|
|
18
18
|
require 'vcloud/edge_gateway/configuration_generator/nat_service'
|
19
19
|
require 'vcloud/edge_gateway/configuration_generator/load_balancer_service'
|
20
20
|
require 'vcloud/edge_gateway/configuration_differ'
|
21
|
+
require 'vcloud/edge_gateway/load_balancer_configuration_differ'
|
21
22
|
require 'vcloud/edge_gateway/edge_gateway_configuration'
|
22
23
|
|
23
24
|
|
@@ -8,14 +8,19 @@ module Vcloud
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def update(config_file = nil)
|
11
|
-
|
11
|
+
local_config = @config_loader.load_config(config_file, Vcloud::Schema::EDGE_GATEWAY_SERVICES)
|
12
12
|
|
13
|
-
edge_gateway = Core::EdgeGateway.get_by_name
|
13
|
+
edge_gateway = Core::EdgeGateway.get_by_name local_config[:gateway]
|
14
14
|
remote_config = edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
15
|
+
edge_gateway_interface_list = edge_gateway.interfaces
|
15
16
|
|
16
|
-
proposed_config = EdgeGateway::EdgeGatewayConfiguration.new(
|
17
|
+
proposed_config = EdgeGateway::EdgeGatewayConfiguration.new(
|
18
|
+
local_config,
|
19
|
+
remote_config,
|
20
|
+
edge_gateway_interface_list
|
21
|
+
)
|
17
22
|
|
18
|
-
if proposed_config.update_required?
|
23
|
+
if proposed_config.update_required?
|
19
24
|
edge_gateway.update_configuration proposed_config.config
|
20
25
|
else
|
21
26
|
Vcloud::EdgeGateway.logger.info("EdgeGatewayServices.update: Configuration is already up to date. Skipping.")
|
@@ -109,17 +109,18 @@ module Vcloud
|
|
109
109
|
LOAD_BALANCER_SERVICE = {
|
110
110
|
type: Hash,
|
111
111
|
allowed_empty: true,
|
112
|
+
required: false,
|
112
113
|
internals: {
|
113
114
|
enabled: { type: 'boolean', required: false },
|
114
115
|
pools: {
|
115
116
|
type: Array,
|
116
|
-
required:
|
117
|
+
required: false,
|
117
118
|
allowed_empty: true,
|
118
119
|
each_element_is: LOAD_BALANCER_POOL_ENTRY,
|
119
120
|
},
|
120
121
|
virtual_servers: {
|
121
122
|
type: Array,
|
122
|
-
required:
|
123
|
+
required: false,
|
123
124
|
allowed_empty: true,
|
124
125
|
each_element_is: LOAD_BALANCER_VIRTUAL_SERVER_ENTRY,
|
125
126
|
},
|
data/spec/erb_helper.rb
CHANGED
@@ -2,7 +2,7 @@ class ErbHelper
|
|
2
2
|
def self.convert_erb_template_to_yaml test_namespace, input_erb_config
|
3
3
|
input_erb_config = input_erb_config
|
4
4
|
e = ERB.new(File.open(input_erb_config).read)
|
5
|
-
output_yaml_config = File.join(File.dirname(input_erb_config), "output_#{Time.now.strftime('%s')}.yaml")
|
5
|
+
output_yaml_config = File.join(File.dirname(input_erb_config), "output_#{Time.now.strftime('%s.%6N')}.yaml")
|
6
6
|
File.open(output_yaml_config, 'w') { |f|
|
7
7
|
f.write e.result(OpenStruct.new(test_namespace).instance_eval { binding })
|
8
8
|
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
gateway: <%= edge_gateway_name %>
|
3
|
+
load_balancer_service:
|
4
|
+
enabled: true
|
5
|
+
pools:
|
6
|
+
- name: 'integration-test-pool-1'
|
7
|
+
description: 'A pool'
|
8
|
+
service:
|
9
|
+
http:
|
10
|
+
enabled: true
|
11
|
+
port: 8080
|
12
|
+
algorithm: 'ROUND_ROBIN'
|
13
|
+
members:
|
14
|
+
- ip_address: 192.0.2.55
|
15
|
+
- ip_address: 192.0.2.56
|
16
|
+
virtual_servers:
|
17
|
+
- name: 'integration-test-vs-1'
|
18
|
+
description: 'A virtual server'
|
19
|
+
ip_address: <%= edge_gateway_ext_network_ip %>
|
20
|
+
network: <%= edge_gateway_ext_network_id %>
|
21
|
+
pool: 'integration-test-pool-1'
|
22
|
+
service_profiles:
|
23
|
+
http:
|
24
|
+
port: 8080
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
gateway: <%= edge_gateway_name %>
|
3
|
+
load_balancer_service:
|
4
|
+
enabled: true
|
5
|
+
pools:
|
6
|
+
- name: 'integration-test-pool-1'
|
7
|
+
description: 'A pool'
|
8
|
+
service:
|
9
|
+
http:
|
10
|
+
enabled: true
|
11
|
+
port: 8080
|
12
|
+
algorithm: 'ROUND_ROBIN'
|
13
|
+
members:
|
14
|
+
- ip_address: 192.0.2.55
|
15
|
+
- ip_address: 192.0.2.56
|
data/spec/integration/edge_gateway/data/load_balancer_single_virtual_server_invalid_pool.yaml.erb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
gateway: <%= edge_gateway_name %>
|
3
|
+
load_balancer_service:
|
4
|
+
enabled: true
|
5
|
+
virtual_servers:
|
6
|
+
- name: 'integration-test-vs-1'
|
7
|
+
description: 'A virtual server'
|
8
|
+
ip_address: <%= edge_gateway_ext_network_ip %>
|
9
|
+
network: <%= edge_gateway_ext_network_id %>
|
10
|
+
pool: 'unconfigured-test-pool-1'
|
11
|
+
service_profiles:
|
12
|
+
http:
|
13
|
+
port: 8080
|
data/spec/integration/edge_gateway/data/load_balancer_single_virtual_server_missing_pool.yaml.erb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
gateway: <%= edge_gateway_name %>
|
3
|
+
load_balancer_service:
|
4
|
+
enabled: true
|
5
|
+
virtual_servers:
|
6
|
+
- name: 'integration-test-vs-1'
|
7
|
+
description: 'A virtual server'
|
8
|
+
ip_address: <%= edge_gateway_ext_network_ip %>
|
9
|
+
network: <%= edge_gateway_ext_network_id %>
|
10
|
+
service_profiles:
|
11
|
+
http:
|
12
|
+
port: 8080
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
gateway: <%= edge_gateway_name %>
|
3
|
+
nat_service:
|
4
|
+
nat_rules:
|
5
|
+
- enabled: true
|
6
|
+
network_id: <%= network_id %>
|
7
|
+
rule_type: 'DNAT'
|
8
|
+
translated_ip: '10.10.1.2-10.10.1.3'
|
9
|
+
translated_port: '3412'
|
10
|
+
original_ip: <%= original_ip %>
|
11
|
+
original_port: '3412'
|
12
|
+
protocol: 'tcp'
|
13
|
+
- enabled: true
|
14
|
+
network_id: <%= network_id %>
|
15
|
+
rule_type: 'SNAT'
|
16
|
+
translated_ip: <%= original_ip %>
|
17
|
+
original_ip: '10.10.1.2-10.10.1.3'
|
18
|
+
firewall_service:
|
19
|
+
policy: drop
|
20
|
+
log_default_action: true
|
21
|
+
firewall_rules:
|
22
|
+
- enabled: true
|
23
|
+
description: 'A rule'
|
24
|
+
policy: allow
|
25
|
+
protocols: 'tcp'
|
26
|
+
destination_port_range: Any
|
27
|
+
destination_ip: 10.10.1.2
|
28
|
+
source_port_range: Any
|
29
|
+
source_ip: 192.0.2.2
|
30
|
+
- enabled: true
|
31
|
+
destination_ip: '10.10.1.3-10.10.1.5'
|
32
|
+
source_ip: 192.0.2.2/24
|
33
|
+
load_balancer_service:
|
34
|
+
enabled: true
|
35
|
+
pools:
|
36
|
+
- name: 'integration-test-pool-1'
|
37
|
+
description: 'A pool'
|
38
|
+
service:
|
39
|
+
http:
|
40
|
+
enabled: true
|
41
|
+
port: 8080
|
42
|
+
algorithm: 'ROUND_ROBIN'
|
43
|
+
members:
|
44
|
+
- ip_address: 10.10.1.2
|
45
|
+
- ip_address: 10.10.1.3
|
46
|
+
virtual_servers:
|
47
|
+
- name: 'integration-test-vs-1'
|
48
|
+
description: 'A virtual server'
|
49
|
+
ip_address: <%= edge_gateway_ext_network_ip %>
|
50
|
+
network: <%= edge_gateway_ext_network_id %>
|
51
|
+
pool: 'integration-test-pool-1'
|
52
|
+
service_profiles:
|
53
|
+
http:
|
54
|
+
port: 8080
|
@@ -36,55 +36,72 @@ module Vcloud
|
|
36
36
|
|
37
37
|
before(:all) do
|
38
38
|
reset_edge_gateway
|
39
|
-
@initial_config_file = generate_input_config_file(
|
39
|
+
@initial_config_file = generate_input_config_file(
|
40
|
+
'nat_and_firewall_config.yaml.erb',
|
41
|
+
edge_gateway_erb_input
|
42
|
+
)
|
43
|
+
@adding_load_balancer_config_file = generate_input_config_file(
|
44
|
+
'nat_and_firewall_plus_load_balancer_config.yaml.erb',
|
45
|
+
edge_gateway_erb_input
|
46
|
+
)
|
40
47
|
@edge_gateway = Vcloud::Core::EdgeGateway.get_by_name(@edge_name)
|
41
48
|
end
|
42
49
|
|
43
50
|
context "Check update is functional" do
|
44
51
|
|
45
52
|
before(:all) do
|
46
|
-
local_config = ConfigLoader.new.load_config(
|
53
|
+
local_config = ConfigLoader.new.load_config(
|
54
|
+
@initial_config_file,
|
55
|
+
Vcloud::Schema::EDGE_GATEWAY_SERVICES
|
56
|
+
)
|
47
57
|
end
|
48
58
|
|
49
59
|
it "should be starting our tests from an empty EdgeGateway" do
|
50
60
|
remote_vcloud_config = @edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
51
61
|
expect(remote_vcloud_config[:FirewallService][:FirewallRule].empty?).to be_true
|
52
62
|
expect(remote_vcloud_config[:NatService][:NatRule].empty?).to be_true
|
63
|
+
expect(remote_vcloud_config[:LoadBalancerService][:Pool].empty?).to be_true
|
64
|
+
expect(remote_vcloud_config[:LoadBalancerService][:VirtualServer].empty?).to be_true
|
53
65
|
end
|
54
66
|
|
55
|
-
it "should only
|
56
|
-
|
57
|
-
|
58
|
-
latest_task = result.first[:task]
|
59
|
-
|
60
|
-
expect_any_instance_of(Core::EdgeGateway).to receive(:update_configuration).exactly(1).times.and_call_original
|
67
|
+
it "should only create one edgeGateway update task when updating the configuration" do
|
68
|
+
start_time = DateTime.now()
|
69
|
+
task_list_before_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
61
70
|
EdgeGatewayServices.new.update(@initial_config_file)
|
62
|
-
|
63
|
-
|
64
|
-
test_latest_task = test_result.first[:task]
|
65
|
-
|
66
|
-
# confirm that a task has been run on the EdgeGateway
|
67
|
-
expect(latest_task == test_latest_task).to be_false
|
71
|
+
task_list_after_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
72
|
+
expect(task_list_after_update.size - task_list_before_update.size).to be(1)
|
68
73
|
end
|
69
74
|
|
70
|
-
it "should now have nat and firewall rules configured" do
|
75
|
+
it "should now have nat and firewall rules configured, no load balancer yet" do
|
71
76
|
remote_vcloud_config = @edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
72
77
|
expect(remote_vcloud_config[:FirewallService][:FirewallRule].empty?).to be_false
|
73
78
|
expect(remote_vcloud_config[:NatService][:NatRule].empty?).to be_false
|
79
|
+
expect(remote_vcloud_config[:LoadBalancerService][:Pool].empty?).to be(true)
|
80
|
+
expect(remote_vcloud_config[:LoadBalancerService][:VirtualServer].empty?).to be(true)
|
74
81
|
end
|
75
82
|
|
76
83
|
it "should not update the EdgeGateway again if the config hasn't changed" do
|
77
|
-
|
78
|
-
|
79
|
-
latest_task = result.first[:task]
|
80
|
-
|
84
|
+
start_time = DateTime.now()
|
85
|
+
task_list_before_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
81
86
|
EdgeGatewayServices.new.update(@initial_config_file)
|
87
|
+
task_list_after_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
88
|
+
expect(task_list_after_update.size - task_list_before_update.size).to be(0)
|
89
|
+
end
|
82
90
|
|
83
|
-
|
84
|
-
|
91
|
+
it "should only create one additional edgeGateway update task when adding the LoadBalancer config" do
|
92
|
+
start_time = DateTime.now()
|
93
|
+
task_list_before_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
94
|
+
EdgeGatewayServices.new.update(@adding_load_balancer_config_file)
|
95
|
+
task_list_after_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
96
|
+
expect(task_list_after_update.size - task_list_before_update.size).to be(1)
|
97
|
+
end
|
85
98
|
|
86
|
-
|
87
|
-
|
99
|
+
it "should not update the EdgeGateway again if we reapply the 'adding load balancer' config" do
|
100
|
+
start_time = DateTime.now()
|
101
|
+
task_list_before_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
102
|
+
EdgeGatewayServices.new.update(@adding_load_balancer_config_file)
|
103
|
+
task_list_after_update = get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(start_time)
|
104
|
+
expect(task_list_after_update.size - task_list_before_update.size).to be(0)
|
88
105
|
end
|
89
106
|
|
90
107
|
end
|
@@ -123,9 +140,21 @@ module Vcloud
|
|
123
140
|
edge_gateway_name: @edge_name,
|
124
141
|
network_id: @ext_net_id,
|
125
142
|
original_ip: @ext_net_ip,
|
143
|
+
edge_gateway_ext_network_id: @ext_net_id,
|
144
|
+
edge_gateway_ext_network_ip: @ext_net_ip,
|
126
145
|
}
|
127
146
|
end
|
128
147
|
|
148
|
+
def get_all_edge_gateway_update_tasks_ordered_by_start_date_since_time(timestamp)
|
149
|
+
vcloud_time = timestamp.strftime('%FT%T.000Z')
|
150
|
+
q = Query.new('task',
|
151
|
+
:filter =>
|
152
|
+
"name==networkConfigureEdgeGatewayServices;objectName==#{@edge_name};startDate=ge=#{vcloud_time}",
|
153
|
+
:sortDesc => 'startDate',
|
154
|
+
)
|
155
|
+
q.get_all_results
|
156
|
+
end
|
157
|
+
|
129
158
|
end
|
130
159
|
|
131
160
|
end
|