vcloud-edge_gateway 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +0 -3
- data/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +66 -0
- data/README.md +16 -8
- data/Rakefile +1 -1
- data/bin/vcloud-configure-edge +2 -29
- data/bin/vcloud-edge-configure +5 -0
- data/jenkins.sh +7 -0
- data/jenkins_integration_tests.sh +7 -0
- data/lib/vcloud/edge_gateway/cli.rb +137 -0
- data/lib/vcloud/edge_gateway/configuration_differ.rb +2 -1
- data/lib/vcloud/edge_gateway/configure.rb +9 -5
- data/lib/vcloud/edge_gateway/edge_gateway_configuration.rb +36 -30
- data/lib/vcloud/edge_gateway/version.rb +1 -1
- data/lib/vcloud/edge_gateway.rb +1 -0
- data/spec/integration/README.md +38 -0
- data/spec/integration/edge_gateway/{firewall_service_spec.rb → configure_firewall_spec.rb} +14 -43
- data/spec/integration/edge_gateway/{load_balancer_service_spec.rb → configure_load_balancer_spec.rb} +26 -32
- data/spec/integration/edge_gateway/{nat_service_spec.rb → configure_nat_spec.rb} +32 -44
- data/spec/integration/edge_gateway/{edge_gateway_services_spec.rb → configure_services_spec.rb} +26 -28
- data/spec/integration/vcloud_tools_testing_config.yaml.template +8 -0
- data/spec/spec_helper.rb +26 -15
- data/spec/support/integration_helper.rb +8 -20
- data/spec/vcloud/edge_gateway/cli_spec.rb +221 -0
- data/spec/vcloud/edge_gateway/configure_spec.rb +81 -0
- data/spec/vcloud/edge_gateway/edge_gateway_configuration_spec.rb +75 -0
- data/vcloud-edge_gateway.gemspec +3 -1
- metadata +59 -15
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
## 1.0.0 (2014-06-04)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- `vcloud-edge-configure` now prints diff output. Colour is optional.
|
6
|
+
Defaults to off when STDOUT is redirected.
|
7
|
+
- `vcloud-edge-configure --dry-run` new argument to print the diff without
|
8
|
+
modifying the remote edge gateway.
|
9
|
+
- `vcloud-edge-configure --version` now only returns the version string
|
10
|
+
and no usage information.
|
11
|
+
- A side effect of changes to the executable means that exceptions from
|
12
|
+
Vcloud::EdgeGateway and Vcloud::Core will now result in a stacktrace
|
13
|
+
being returned by the CLI, which we'll retain for now until we refine
|
14
|
+
the error messages.
|
15
|
+
|
16
|
+
API changes:
|
17
|
+
|
18
|
+
- Vcloud::EdgeGateway::Configure returns a hash, keyed by service name, of
|
19
|
+
HashDiff#diff arrays. It will be empty if there are no differences.
|
20
|
+
- Vcloud::EdgeGateway::Configure#update takes a `dry_run` argument which
|
21
|
+
defaults to false. When set to true it won't update the remote Edge GW.
|
22
|
+
|
23
|
+
Bugfixes:
|
24
|
+
|
25
|
+
- The `vcloud-configure-edge` command has been renamed to `vcloud-edge-configure`.
|
26
|
+
|
1
27
|
## 0.5.0 (2014-05-15)
|
2
28
|
|
3
29
|
Bugfixes:
|
@@ -33,6 +59,10 @@ Features:
|
|
33
59
|
- Now uses the config loader and validator in vcloud-core rather than its own duplicate.
|
34
60
|
- Require fog v1.21 to allow use of FOG_VCLOUD_TOKEN via ENV as an alternative to a .fog file
|
35
61
|
|
62
|
+
Documentation credits:
|
63
|
+
|
64
|
+
- Thanks to @Azulinho who added some example configuration.
|
65
|
+
|
36
66
|
## 0.2.2 (2014-03-05)
|
37
67
|
|
38
68
|
Bugfixes:
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Contributing to vCloud Edge Gateway
|
2
|
+
|
3
|
+
We really welcome contributions.
|
4
|
+
|
5
|
+
## A quick guide on how to contribute
|
6
|
+
|
7
|
+
1. Clone the repo:
|
8
|
+
|
9
|
+
git clone git@github.com:alphagov/vcloud-edge_gateway.git
|
10
|
+
|
11
|
+
2. Run `bundle` to get the required dependecies
|
12
|
+
|
13
|
+
3. Run the tests. Pull requests that add features must include unit tests,
|
14
|
+
so it is good to ensure you've got them passing to begin with.
|
15
|
+
|
16
|
+
bundle exec rake
|
17
|
+
|
18
|
+
If you have access to a live environment for testing, it would be great
|
19
|
+
if you could run the integration tests too - for more details on the
|
20
|
+
set-up for that, please see the [integration tests README]
|
21
|
+
(https://github.com/alphagov/vcloud-edge_gateway/blob/master/spec/integration/README.md)
|
22
|
+
|
23
|
+
4. Add your functionality or bug fix and a test for your change. Only refactoring and
|
24
|
+
documentation changes do not require tests. If the functionality is at all complicated
|
25
|
+
then it is likely that more than one test will be required. If you would like help
|
26
|
+
with writing tests please do ask us.
|
27
|
+
|
28
|
+
5. Make sure all the tests pass, including the integration tests if possible.
|
29
|
+
|
30
|
+
6. Update the [CHANGELOG](https://github.com/alphagov/vcloud-edge_gateway/blob/master/CHANGELOG.md)
|
31
|
+
with a short description of what the change is. This may be a feature, a bugfix, or an
|
32
|
+
API change. If your change is documenation or refactoring, you do not need to add a line
|
33
|
+
to the CHANGELOG.
|
34
|
+
|
35
|
+
7. Fork the repo, push to your fork, and submit a pull request.
|
36
|
+
|
37
|
+
## How soon will we respond?
|
38
|
+
|
39
|
+
We will comment on your pull request within two working days. However, we might not be able to review it immediately.
|
40
|
+
|
41
|
+
We may come back to you with comments and suggestions, and if we would like you to make changes, we will close the pull request as well as adding details of the changes we'd like you to make.
|
42
|
+
|
43
|
+
If you feel your pull request has been outstanding too long, please feel free to bump it by making a comment on it.
|
44
|
+
|
45
|
+
## Guidelines for making a pull request
|
46
|
+
|
47
|
+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
|
48
|
+
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
|
49
|
+
interpreted as described in RFC 2119.
|
50
|
+
|
51
|
+
## In order for a pull request to be accepted, it MUST
|
52
|
+
|
53
|
+
- Include at least one test (unless it is documentation or refactoring). If you have any questions about how to write tests, please ask us, we will be happy to help
|
54
|
+
- Follow our [Git style guide](https://github.com/alphagov/styleguides/blob/master/git.md)
|
55
|
+
- Include a clear summary in the pull request comments as to what the change is and why
|
56
|
+
you are making it
|
57
|
+
- Be readable - we might ask you to change unclear variable names or obscure syntactic sugar
|
58
|
+
- Have [good commit messages](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
59
|
+
that explain the change being made in that commit. Don't be afraid to write a lot in the
|
60
|
+
detail.
|
61
|
+
|
62
|
+
## In order for a pull request to be accepted, it SHOULD
|
63
|
+
|
64
|
+
- Include a line in the CHANGELOG unless it is a refactoring or documentation change
|
65
|
+
- If it is code, follow our [Ruby style guide](https://github.com/alphagov/styleguides/blob/master/ruby.md)
|
66
|
+
- If it is documentation, follow the [GDS content style guide](https://www.gov.uk/design-principles/style-guide/style-points)
|
data/README.md
CHANGED
@@ -23,12 +23,12 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
To configure an Edge Gateway:
|
25
25
|
|
26
|
-
$ vcloud-configure
|
26
|
+
$ vcloud-edge-configure input.yaml
|
27
27
|
|
28
28
|
To use [mustache](http://mustache.github.io) templates so that rulesets can
|
29
29
|
be re-used between environments:
|
30
30
|
|
31
|
-
$ vcloud-configure
|
31
|
+
$ vcloud-edge-configure --template-vars vars.yaml input.yaml.mustache
|
32
32
|
|
33
33
|
## Credentials
|
34
34
|
|
@@ -60,7 +60,7 @@ credentials that allow it to talk to a vCloud Director environment.
|
|
60
60
|
|
61
61
|
FOG_CREDENTIAL=test_credentials \
|
62
62
|
FOG_VCLOUD_TOKEN=AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF= \
|
63
|
-
vcloud-configure
|
63
|
+
vcloud-edge-configure input.yaml
|
64
64
|
|
65
65
|
You may find it easier to export one or both of the values as environment variables.
|
66
66
|
|
@@ -71,7 +71,7 @@ credentials that allow it to talk to a vCloud Director environment.
|
|
71
71
|
### Configure edge gateway services
|
72
72
|
|
73
73
|
You can configure the following services on an existing edgegateway using
|
74
|
-
`vcloud-configure
|
74
|
+
`vcloud-edge-configure`.
|
75
75
|
|
76
76
|
- firewall_service
|
77
77
|
- nat_service
|
@@ -80,7 +80,7 @@ You can configure the following services on an existing edgegateway using
|
|
80
80
|
NB: DHCP and VPN Services are not yet supported by the Fog platform underneath.
|
81
81
|
Support for these is being considered.
|
82
82
|
|
83
|
-
The `vcloud-configure
|
83
|
+
The `vcloud-edge-configure` tool takes an input YAML file describing one
|
84
84
|
or more of these services and updates the edge gateway configuration to match,
|
85
85
|
obeying the following rules:
|
86
86
|
|
@@ -237,7 +237,7 @@ The vCloud Director load balancer service is quite basic, but supports the follo
|
|
237
237
|
* Ability to persist sessions to the same backend member node, via a variety of
|
238
238
|
means (eg HTTP cookie value, SSL session ID, source IP hash).
|
239
239
|
|
240
|
-
`vcloud-configure
|
240
|
+
`vcloud-edge-configure` supports all of the above features.
|
241
241
|
|
242
242
|
It is also worth noting that the vCloud Director load balancer *does not support*:
|
243
243
|
|
@@ -423,9 +423,14 @@ cat edges.out | jq '
|
|
423
423
|
'
|
424
424
|
```
|
425
425
|
|
426
|
-
### Full configuration examples
|
426
|
+
### Full configuration examples and schemas
|
427
427
|
|
428
|
-
|
428
|
+
Full configuration examples are in the [`examples/`][examples] folder.
|
429
|
+
|
430
|
+
Configuration schemas are in [`lib/vcloud/edge_gateway/schema/`][schema].
|
431
|
+
|
432
|
+
[examples]: /examples
|
433
|
+
[schema]: /lib/vcloud/edge_gateway/schema
|
429
434
|
|
430
435
|
## The vCloud API
|
431
436
|
|
@@ -453,6 +458,9 @@ Run the integration tests (slower and requires a real environment):
|
|
453
458
|
|
454
459
|
bundle exec rake integration
|
455
460
|
|
461
|
+
You need access to a suitable vCloud Director organization to run the integration tests. See the [integration tests
|
462
|
+
README](/spec/integration/README.md) for further details.
|
463
|
+
|
456
464
|
### References
|
457
465
|
|
458
466
|
* [vCloud Director Edge Gateway documentation](http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.admin.doc_51/GUID-ADE1DCAB-874F-45A9-9337-1E971DAC0F7D.html)
|
data/Rakefile
CHANGED
data/bin/vcloud-configure-edge
CHANGED
@@ -1,31 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
class App
|
7
|
-
include Methadone::Main
|
8
|
-
include Methadone::CLILogging
|
9
|
-
|
10
|
-
main do |config_file|
|
11
|
-
if options['template-vars']
|
12
|
-
vse = Vcloud::EdgeGateway::Configure.new(config_file, options['template-vars'])
|
13
|
-
else
|
14
|
-
vse = Vcloud::EdgeGateway::Configure.new(config_file)
|
15
|
-
end
|
16
|
-
vse.update
|
17
|
-
end
|
18
|
-
|
19
|
-
arg :config_file
|
20
|
-
on('--template-vars FILE', 'Enable templating with variables from this file')
|
21
|
-
|
22
|
-
description '
|
23
|
-
vcloud-edge_gateway allows you to configure an EdgeGateway with an input
|
24
|
-
file which may optionally be a Mustache template.
|
25
|
-
|
26
|
-
See https://github.com/alphagov/vcloud-edge_gateway for more info'
|
27
|
-
|
28
|
-
version Vcloud::EdgeGateway::VERSION
|
29
|
-
|
30
|
-
go!
|
31
|
-
end
|
3
|
+
$stderr.puts "This command has been renamed. Please use: vcloud-edge-configure"
|
4
|
+
exit 1
|
data/jenkins.sh
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
#!/bin/bash -x
|
2
2
|
set -e
|
3
|
+
|
4
|
+
git clean -ffdx
|
3
5
|
bundle install --path "${HOME}/bundles/${JOB_NAME}"
|
4
6
|
bundle exec rake
|
5
7
|
|
8
|
+
# Obtain the integration test parameters
|
9
|
+
git clone git@github.gds:gds/vcloud-tools-testing-config.git
|
10
|
+
mv vcloud-tools-testing-config/vcloud_tools_testing_config.yaml spec/integration/
|
11
|
+
rm -rf vcloud-tools-testing-config
|
12
|
+
|
6
13
|
RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration
|
7
14
|
|
8
15
|
bundle exec rake publish_gem
|
@@ -1,5 +1,12 @@
|
|
1
1
|
#!/bin/bash -x
|
2
2
|
set -e
|
3
|
+
|
4
|
+
git clean -ffdx
|
3
5
|
bundle install --path "${HOME}/bundles/${JOB_NAME}"
|
4
6
|
|
7
|
+
# Obtain the integration test parameters
|
8
|
+
git clone git@github.gds:gds/vcloud-tools-testing-config.git
|
9
|
+
mv vcloud-tools-testing-config/vcloud_tools_testing_config.yaml spec/integration/
|
10
|
+
rm -rf vcloud-tools-testing-config
|
11
|
+
|
5
12
|
RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Vcloud
|
4
|
+
module EdgeGateway
|
5
|
+
class Cli
|
6
|
+
ANSI_RESET = "\033[0m"
|
7
|
+
ANSI_RED = "\033[31m"
|
8
|
+
ANSI_GREEN = "\033[32m"
|
9
|
+
|
10
|
+
def initialize(argv_array)
|
11
|
+
@usage_text = nil
|
12
|
+
@config_file = nil
|
13
|
+
@options = {
|
14
|
+
:template_vars => nil,
|
15
|
+
:colour => STDOUT.tty?,
|
16
|
+
:dry_run => nil,
|
17
|
+
}
|
18
|
+
|
19
|
+
parse(argv_array)
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
config_args = [@config_file]
|
24
|
+
if @options[:template_vars]
|
25
|
+
config_args << @options[:template_vars]
|
26
|
+
end
|
27
|
+
|
28
|
+
update_args = []
|
29
|
+
if @options[:dry_run]
|
30
|
+
update_args << @options[:dry_run]
|
31
|
+
end
|
32
|
+
|
33
|
+
conf = Vcloud::EdgeGateway::Configure.new(*config_args)
|
34
|
+
diff = conf.update(*update_args)
|
35
|
+
puts render_diff(diff)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def parse(args)
|
41
|
+
opt_parser = OptionParser.new do |opts|
|
42
|
+
opts.banner = <<-EOS
|
43
|
+
Usage: #{$0} [options] config_file
|
44
|
+
|
45
|
+
vcloud-edge_gateway allows you to configure an EdgeGateway with an input
|
46
|
+
file which may optionally be a Mustache template.
|
47
|
+
|
48
|
+
It will always output a diff of the changes between the remote config and
|
49
|
+
your local config.
|
50
|
+
|
51
|
+
See https://github.com/alphagov/vcloud-edge_gateway for more info
|
52
|
+
EOS
|
53
|
+
|
54
|
+
opts.separator ""
|
55
|
+
opts.separator "Options:"
|
56
|
+
|
57
|
+
opts.on("--dry-run", "Don't apply configuration changes") do
|
58
|
+
@options[:dry_run] = true
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on("--template-vars FILE", "Enable templating with variables from this file") do |f|
|
62
|
+
@options[:template_vars] = f
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on("--[no-]colour", "Disable/enable colour output. Enabled by default unless output is redirected") do |c|
|
66
|
+
@options[:colour] = c
|
67
|
+
end
|
68
|
+
|
69
|
+
opts.on("-h", "--help", "Print usage and exit") do
|
70
|
+
$stderr.puts opts
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on("--version", "Display version and exit") do
|
75
|
+
puts Vcloud::EdgeGateway::VERSION
|
76
|
+
exit
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
@usage_text = opt_parser.to_s
|
81
|
+
begin
|
82
|
+
opt_parser.parse!(args)
|
83
|
+
rescue OptionParser::InvalidOption => e
|
84
|
+
exit_error_usage(e)
|
85
|
+
end
|
86
|
+
|
87
|
+
exit_error_usage("must supply config_file") unless args.size == 1
|
88
|
+
@config_file = args.first
|
89
|
+
end
|
90
|
+
|
91
|
+
def exit_error_usage(error)
|
92
|
+
$stderr.puts "#{$0}: #{error}"
|
93
|
+
$stderr.puts @usage_text
|
94
|
+
exit 2
|
95
|
+
end
|
96
|
+
|
97
|
+
def render_diff(diff)
|
98
|
+
lines = diff.collect { |service_name, service_diff|
|
99
|
+
service_diff.collect { |diff_tuple|
|
100
|
+
key = "#{service_name}.#{diff_tuple[1]}"
|
101
|
+
case diff_tuple[0]
|
102
|
+
when "-"
|
103
|
+
diff_line_rem(key, diff_tuple[2])
|
104
|
+
when "+"
|
105
|
+
diff_line_add(key, diff_tuple[2])
|
106
|
+
when "~"
|
107
|
+
[
|
108
|
+
diff_line_rem(key, diff_tuple[2]),
|
109
|
+
diff_line_add(key, diff_tuple[3]),
|
110
|
+
]
|
111
|
+
end
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
lines.join("\n")
|
116
|
+
end
|
117
|
+
|
118
|
+
def diff_line_add(key, value)
|
119
|
+
line = "+ #{key}: #{value}"
|
120
|
+
if @options.fetch(:colour)
|
121
|
+
line = "#{ANSI_GREEN}#{line}#{ANSI_RESET}"
|
122
|
+
end
|
123
|
+
|
124
|
+
line
|
125
|
+
end
|
126
|
+
|
127
|
+
def diff_line_rem(key, value)
|
128
|
+
line = "- #{key}: #{value}"
|
129
|
+
if @options.fetch(:colour)
|
130
|
+
line = "#{ANSI_RED}#{line}#{ANSI_RESET}"
|
131
|
+
end
|
132
|
+
|
133
|
+
line
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'hashdiff'
|
2
|
-
|
3
1
|
module Vcloud
|
4
2
|
module EdgeGateway
|
5
3
|
class Configure
|
6
4
|
|
7
|
-
def initialize(config_file
|
5
|
+
def initialize(config_file=nil, vars_file=nil)
|
8
6
|
config_loader = Vcloud::Core::ConfigLoader.new
|
9
7
|
@local_config = config_loader.load_config(config_file, Vcloud::EdgeGateway::Schema::EDGE_GATEWAY_SERVICES, vars_file)
|
10
8
|
end
|
11
9
|
|
12
|
-
def update
|
10
|
+
def update(dry_run=false)
|
13
11
|
edge_gateway = Vcloud::Core::EdgeGateway.get_by_name @local_config[:gateway]
|
14
12
|
remote_config = edge_gateway.vcloud_attributes[:Configuration][:EdgeGatewayServiceConfiguration]
|
15
13
|
edge_gateway_interface_list = edge_gateway.interfaces
|
@@ -21,10 +19,16 @@ module Vcloud
|
|
21
19
|
)
|
22
20
|
|
23
21
|
if proposed_config.update_required?
|
24
|
-
|
22
|
+
if dry_run
|
23
|
+
Vcloud::Core.logger.info("EdgeGateway::Configure.update: Dry run. Skipping.")
|
24
|
+
else
|
25
|
+
edge_gateway.update_configuration proposed_config.config
|
26
|
+
end
|
25
27
|
else
|
26
28
|
Vcloud::Core.logger.info("EdgeGateway::Configure.update: Configuration is already up to date. Skipping.")
|
27
29
|
end
|
30
|
+
|
31
|
+
proposed_config.diff
|
28
32
|
end
|
29
33
|
|
30
34
|
end
|
@@ -2,63 +2,69 @@ module Vcloud
|
|
2
2
|
module EdgeGateway
|
3
3
|
class EdgeGatewayConfiguration
|
4
4
|
|
5
|
+
attr_reader :config, :diff
|
6
|
+
|
5
7
|
def initialize(local_config, remote_config, edge_gateway_interfaces)
|
6
|
-
@
|
7
|
-
@remote_config = remote_config
|
8
|
-
@edge_gateway_interfaces = edge_gateway_interfaces
|
9
|
-
@config = { }
|
10
|
-
@update_required = nil
|
8
|
+
@config, @diff = generate_new_config(local_config, remote_config, edge_gateway_interfaces)
|
11
9
|
end
|
12
10
|
|
13
11
|
def update_required?
|
14
|
-
@
|
12
|
+
@config.any?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def generate_new_config(local_config, remote_config, edge_gateway_interfaces)
|
17
|
+
new_config = { }
|
18
|
+
diff = { }
|
19
|
+
|
20
|
+
firewall_service_config =
|
21
|
+
EdgeGateway::ConfigurationGenerator::FirewallService.new.
|
22
|
+
generate_fog_config(local_config[:firewall_service])
|
15
23
|
|
16
|
-
firewall_service_config = EdgeGateway::ConfigurationGenerator::FirewallService.new.generate_fog_config(@local_config[:firewall_service])
|
17
24
|
unless firewall_service_config.nil?
|
18
|
-
differ = EdgeGateway::FirewallConfigurationDiffer.new(
|
25
|
+
differ = EdgeGateway::FirewallConfigurationDiffer.new(
|
26
|
+
remote_config[:FirewallService],
|
27
|
+
firewall_service_config
|
28
|
+
)
|
19
29
|
unless differ.diff.empty?
|
20
|
-
|
21
|
-
|
30
|
+
diff[:FirewallService] = differ.diff
|
31
|
+
new_config[:FirewallService] = firewall_service_config
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
25
35
|
nat_service_config = EdgeGateway::ConfigurationGenerator::NatService.new(
|
26
|
-
|
27
|
-
|
36
|
+
local_config[:nat_service],
|
37
|
+
edge_gateway_interfaces
|
28
38
|
).generate_fog_config
|
29
39
|
|
30
40
|
unless nat_service_config.nil?
|
31
|
-
differ = EdgeGateway::NatConfigurationDiffer.new(
|
41
|
+
differ = EdgeGateway::NatConfigurationDiffer.new(
|
42
|
+
remote_config[:NatService],
|
43
|
+
nat_service_config
|
44
|
+
)
|
32
45
|
unless differ.diff.empty?
|
33
|
-
|
34
|
-
|
46
|
+
diff[:NatService] = differ.diff
|
47
|
+
new_config[:NatService] = nat_service_config
|
35
48
|
end
|
36
49
|
end
|
37
50
|
|
38
51
|
load_balancer_service_config =
|
39
52
|
EdgeGateway::ConfigurationGenerator::LoadBalancerService.new(
|
40
|
-
|
41
|
-
).generate_fog_config(
|
53
|
+
edge_gateway_interfaces
|
54
|
+
).generate_fog_config(local_config[:load_balancer_service])
|
42
55
|
|
43
56
|
unless load_balancer_service_config.nil?
|
44
57
|
differ = EdgeGateway::LoadBalancerConfigurationDiffer.new(
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
remote_config[:LoadBalancerService],
|
59
|
+
load_balancer_service_config
|
60
|
+
)
|
48
61
|
unless differ.diff.empty?
|
49
|
-
|
50
|
-
|
62
|
+
diff[:LoadBalancerService] = differ.diff
|
63
|
+
new_config[:LoadBalancerService] = load_balancer_service_config
|
51
64
|
end
|
52
65
|
end
|
53
66
|
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
def config
|
58
|
-
if @update_required.nil?
|
59
|
-
update_required?
|
60
|
-
end
|
61
|
-
@config
|
67
|
+
return new_config, diff
|
62
68
|
end
|
63
69
|
|
64
70
|
end
|
data/lib/vcloud/edge_gateway.rb
CHANGED
@@ -8,6 +8,7 @@ require 'vcloud/edge_gateway/schema/firewall_service'
|
|
8
8
|
require 'vcloud/edge_gateway/schema/load_balancer_service'
|
9
9
|
require 'vcloud/edge_gateway/schema/edge_gateway'
|
10
10
|
|
11
|
+
require 'vcloud/edge_gateway/cli'
|
11
12
|
require 'vcloud/edge_gateway/configure'
|
12
13
|
require 'vcloud/edge_gateway/configuration_generator/id_ranges'
|
13
14
|
require 'vcloud/edge_gateway/configuration_generator/firewall_service'
|
@@ -0,0 +1,38 @@
|
|
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/alphagov/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`
|