vcloud-edge_gateway 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +33 -44
- data/Rakefile +7 -2
- data/bin/vcloud-configure-edge +1 -7
- data/jenkins.sh +1 -4
- data/jenkins_integration_tests.sh +1 -4
- data/lib/vcloud/edge_gateway/configuration_generator/load_balancer_service.rb +9 -12
- data/lib/vcloud/edge_gateway/configuration_generator/nat_service.rb +3 -3
- data/lib/vcloud/edge_gateway/version.rb +1 -1
- data/spec/vcloud/edge_gateway/configuration_differ_shared_examples.rb +1 -1
- data/tools/fog_credentials.rb +17 -0
- data/vcloud-edge_gateway.gemspec +2 -1
- metadata +22 -6
- data/scripts/generate_fog_conf_file.sh +0 -6
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,63 +25,43 @@ To configure an Edge Gateway:
|
|
25
25
|
|
26
26
|
$ vcloud-configure-edge input.yaml
|
27
27
|
|
28
|
-
|
28
|
+
## Credentials
|
29
29
|
|
30
|
-
vCloud Edge Gateway is based around [fog]. To use it you'll need to give it
|
31
|
-
|
30
|
+
vCloud Edge Gateway is based around [fog](http://fog.io/). To use it you'll need to give it
|
31
|
+
credentials that allow it to talk to a vCloud Director environment.
|
32
32
|
|
33
|
-
|
33
|
+
1. Create a '.fog' file in your home directory.
|
34
34
|
|
35
|
-
|
35
|
+
For example:
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
vcloud_director_password: 'password'
|
42
|
-
vcloud_director_host: 'host.api.example.com'
|
43
|
-
|
44
|
-
Unfortunately current usage of fog requires the password in this file. Multiple sets of credentials can be specified in the fog file, using the following format:
|
45
|
-
|
46
|
-
test:
|
47
|
-
vcloud_director_username: 'username@org_name'
|
48
|
-
vcloud_director_password: 'password'
|
49
|
-
vcloud_director_host: 'host.api.example.com'
|
50
|
-
|
51
|
-
test2:
|
52
|
-
vcloud_director_username: 'username@org_name'
|
53
|
-
vcloud_director_password: 'password'
|
54
|
-
vcloud_director_host: 'host.api.vendor.net'
|
55
|
-
|
56
|
-
You can then pass the `FOG_CREDENTIAL` environment variable at the start of your command. The value of the `FOG_CREDENTIAL` environment variable is the name of the credential set in your fog file which you wish to use. For instance:
|
37
|
+
test_credentials:
|
38
|
+
vcloud_director_host: 'host.api.example.com'
|
39
|
+
vcloud_director_username: 'username@org_name'
|
40
|
+
vcloud_director_password: ''
|
57
41
|
|
58
|
-
|
42
|
+
2. Obtain a session token. First, curl the API:
|
59
43
|
|
60
|
-
|
44
|
+
curl -D- -d '' \
|
45
|
+
-H 'Accept: application/*+xml;version=5.1' -u '<username>@<org_name>' \
|
46
|
+
https://<host.api.example.com>/api/sessions
|
61
47
|
|
62
|
-
|
48
|
+
This will prompt for your password.
|
63
49
|
|
64
|
-
|
65
|
-
|
66
|
-
|
50
|
+
From the headers returned, the value of the `x-vcloud-authorization` header is your
|
51
|
+
session token, and this will be valid for 30 minutes idle - any activity will extend
|
52
|
+
its life by another 30 minutes.
|
67
53
|
|
68
|
-
|
54
|
+
3. Specify your credentials and session token at the beginning of the command. For example:
|
69
55
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
-H 'Accept: application/*+xml;version=5.1' -u '<user>@<org>'
|
74
|
-
https://host.com/api/sessions
|
56
|
+
FOG_CREDENTIAL=test_credentials \
|
57
|
+
FOG_VCLOUD_TOKEN=AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF= \
|
58
|
+
vcloud-configure-edge input.yaml
|
75
59
|
|
76
|
-
|
60
|
+
You may find it easier to export one or both of the values as environment variables.
|
77
61
|
|
78
|
-
|
62
|
+
**NB** It is also possible to sidestep the need for the session token by saving your
|
63
|
+
password in the fog file. This is **not recommended**.
|
79
64
|
|
80
|
-
x-vcloud-authorization: AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF=
|
81
|
-
|
82
|
-
Use token as ENV var FOG_VCLOUD_TOKEN
|
83
|
-
|
84
|
-
$ FOG_VCLOUD_TOKEN=AAAABBBBBCCCCCCDDDDDDEEEEEEFFFFF= vcloud-configure-edge input.yaml
|
85
65
|
|
86
66
|
### Configure edge gateway services
|
87
67
|
|
@@ -414,6 +394,15 @@ cat edges.out | jq '
|
|
414
394
|
|
415
395
|
You can find full configuration examples in the `examples` folder.
|
416
396
|
|
397
|
+
## The vCloud API
|
398
|
+
|
399
|
+
vCloud Tools currently use version 5.1 of the [vCloud API](http://pubs.vmware.com/vcd-51/index.jsp?topic=%2Fcom.vmware.vcloud.api.doc_51%2FGUID-F4BF9D5D-EF66-4D36-A6EB-2086703F6E37.html). Version 5.5 may work but is not currently supported. You should be able to access the 5.1 API in a 5.5 environment, and this *is* currently supported.
|
400
|
+
|
401
|
+
The default version is defined in [Fog](https://github.com/fog/fog/blob/244a049918604eadbcebd3a8eaaf433424fe4617/lib/fog/vcloud_director/compute.rb#L32).
|
402
|
+
|
403
|
+
If you want to be sure you are pinning to 5.1, or use 5.5, you can set the API version to use in your fog file, e.g.
|
404
|
+
|
405
|
+
`vcloud_director_api_version: 5.1`
|
417
406
|
|
418
407
|
## Debugging
|
419
408
|
|
data/Rakefile
CHANGED
@@ -10,14 +10,19 @@ RSpec::Core::RakeTask.new(:spec) do |task|
|
|
10
10
|
task.pattern = FileList['spec/vcloud/**/*_spec.rb']
|
11
11
|
end
|
12
12
|
|
13
|
-
task :default => [:spec]
|
13
|
+
task :default => [:rubocop, :spec]
|
14
14
|
|
15
15
|
RSpec::Core::RakeTask.new('integration') do |t|
|
16
16
|
t.pattern = FileList['spec/integration/**/*_spec.rb']
|
17
17
|
end
|
18
18
|
|
19
19
|
require "gem_publisher"
|
20
|
-
task :publish_gem do
|
20
|
+
task :publish_gem do
|
21
21
|
gem = GemPublisher.publish_if_updated("vcloud-edge_gateway.gemspec", :rubygems)
|
22
22
|
puts "Published #{gem}" if gem
|
23
23
|
end
|
24
|
+
|
25
|
+
require 'rubocop/rake_task'
|
26
|
+
Rubocop::RakeTask.new(:rubocop) do |task|
|
27
|
+
task.options = ['--lint']
|
28
|
+
end
|
data/bin/vcloud-configure-edge
CHANGED
data/jenkins.sh
CHANGED
@@ -3,9 +3,6 @@ set -e
|
|
3
3
|
bundle install --path "${HOME}/bundles/${JOB_NAME}"
|
4
4
|
bundle exec rake
|
5
5
|
|
6
|
-
./
|
7
|
-
export FOG_RC=fog_integration_test.config
|
8
|
-
bundle exec rake integration
|
9
|
-
rm fog_integration_test.config
|
6
|
+
RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration
|
10
7
|
|
11
8
|
bundle exec rake publish_gem
|
@@ -2,7 +2,4 @@
|
|
2
2
|
set -e
|
3
3
|
bundle install --path "${HOME}/bundles/${JOB_NAME}"
|
4
4
|
|
5
|
-
./
|
6
|
-
export FOG_RC=fog_integration_test.config
|
7
|
-
bundle exec rake integration
|
8
|
-
rm fog_integration_test.config
|
5
|
+
RUBYOPT="-r ./tools/fog_credentials" bundle exec rake integration
|
@@ -15,13 +15,13 @@ module Vcloud
|
|
15
15
|
load_balancer_input_config[:enabled].to_s : 'true'
|
16
16
|
vcloud_pools = []
|
17
17
|
vcloud_virtual_servers = []
|
18
|
-
if
|
19
|
-
pools.each do |pool_input_entry|
|
18
|
+
if load_balancer_input_config[:pools]
|
19
|
+
load_balancer_input_config[:pools].each do |pool_input_entry|
|
20
20
|
vcloud_pools << generate_pool_entry(pool_input_entry)
|
21
21
|
end
|
22
22
|
end
|
23
|
-
if
|
24
|
-
virtual_servers.each do |virtual_server_input_entry|
|
23
|
+
if load_balancer_input_config[:virtual_servers]
|
24
|
+
load_balancer_input_config[:virtual_servers].each do |virtual_server_input_entry|
|
25
25
|
vcloud_virtual_servers << generate_virtual_server_entry(virtual_server_input_entry)
|
26
26
|
end
|
27
27
|
end
|
@@ -81,7 +81,7 @@ module Vcloud
|
|
81
81
|
IsEnabled: 'false',
|
82
82
|
Protocol: protocol.to_s.upcase,
|
83
83
|
Port: default_port(protocol),
|
84
|
-
Persistence: generate_virtual_server_persistence_section(
|
84
|
+
Persistence: generate_virtual_server_persistence_section(nil)
|
85
85
|
}
|
86
86
|
if input_protocol_section
|
87
87
|
vcloud_protocol_section[:IsEnabled] =
|
@@ -91,10 +91,7 @@ module Vcloud
|
|
91
91
|
input_protocol_section.key?(:port) ?
|
92
92
|
input_protocol_section[:port].to_s : default_port(protocol)
|
93
93
|
vcloud_protocol_section[:Persistence] =
|
94
|
-
generate_virtual_server_persistence_section(
|
95
|
-
protocol,
|
96
|
-
input_protocol_section[:persistence]
|
97
|
-
)
|
94
|
+
generate_virtual_server_persistence_section(input_protocol_section[:persistence])
|
98
95
|
end
|
99
96
|
vcloud_protocol_section
|
100
97
|
end
|
@@ -104,7 +101,7 @@ module Vcloud
|
|
104
101
|
default_port_for[protocol]
|
105
102
|
end
|
106
103
|
|
107
|
-
def generate_virtual_server_persistence_section(
|
104
|
+
def generate_virtual_server_persistence_section(input_persistence_section)
|
108
105
|
input_persistence_section = {} if input_persistence_section.nil?
|
109
106
|
vcloud_persistence_section = { Method: '' }
|
110
107
|
if input_persistence_section.key?(:method)
|
@@ -174,9 +171,9 @@ module Vcloud
|
|
174
171
|
vcloud_pool_service_port[:Port] =
|
175
172
|
input_pool_service_port.key?(:port) ?
|
176
173
|
input_pool_service_port[:port].to_s : default_port(mode)
|
177
|
-
if
|
174
|
+
if input_pool_service_port[:health_check]
|
178
175
|
vcloud_pool_service_port[:HealthCheckPort] =
|
179
|
-
health_check.
|
176
|
+
input_pool_service_port[:health_check].fetch(:port, '').to_s
|
180
177
|
vcloud_pool_service_port[:HealthCheck] =
|
181
178
|
generate_pool_healthcheck(mode, input_pool_service_port[:health_check])
|
182
179
|
end
|
@@ -33,11 +33,11 @@ module Vcloud
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def populate_gateway_nat_rule(rule)
|
36
|
-
raise "Must supply a :network_id parameter" unless
|
36
|
+
raise "Must supply a :network_id parameter" unless rule[:network_id]
|
37
37
|
edge_gw_interface = @edge_gateway_interfaces.find do |interface|
|
38
|
-
interface.network_id ==
|
38
|
+
interface.network_id == rule[:network_id]
|
39
39
|
end
|
40
|
-
raise "unable to find gateway network interface with id #{
|
40
|
+
raise "unable to find gateway network interface with id #{rule[:network_id]}" unless edge_gw_interface
|
41
41
|
gateway_nat_rule = {}
|
42
42
|
gateway_nat_rule[:Interface] = populate_nat_interface(edge_gw_interface)
|
43
43
|
gateway_nat_rule[:OriginalIp] = rule[:original_ip]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Initialiser for getting vCloud credentials into Fog from Jenkins build
|
2
|
+
# parameters, without needing to write them to disk. To be used with:
|
3
|
+
#
|
4
|
+
# RUBYOPT="-r ./tools/fog_credentials" bundle exec integration
|
5
|
+
#
|
6
|
+
# Replace with FOG_VCLOUD_TOKEN support when we have a tool:
|
7
|
+
#
|
8
|
+
# https://www.pivotaltracker.com/story/show/68989754
|
9
|
+
#
|
10
|
+
require 'bundler/setup'
|
11
|
+
require 'fog'
|
12
|
+
|
13
|
+
Fog.credentials = {
|
14
|
+
:vcloud_director_host => ENV['API_HOST'],
|
15
|
+
:vcloud_director_username => ENV['API_USERNAME'],
|
16
|
+
:vcloud_director_password => ENV['API_PASSWORD'],
|
17
|
+
}
|
data/vcloud-edge_gateway.gemspec
CHANGED
@@ -22,10 +22,11 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.required_ruby_version = '>= 1.9.2'
|
23
23
|
|
24
24
|
s.add_runtime_dependency 'fog', '>= 1.21.0'
|
25
|
-
s.add_runtime_dependency 'vcloud-core', '
|
25
|
+
s.add_runtime_dependency 'vcloud-core', '~> 0.0.12'
|
26
26
|
s.add_runtime_dependency 'hashdiff'
|
27
27
|
s.add_development_dependency 'rake'
|
28
28
|
s.add_development_dependency 'rspec', '~> 2.14.1'
|
29
|
+
s.add_development_dependency 'rubocop'
|
29
30
|
s.add_development_dependency 'simplecov', '~> 0.8.2'
|
30
31
|
s.add_development_dependency 'gem_publisher', '1.2.0'
|
31
32
|
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: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 0.0.12
|
38
38
|
type: :runtime
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 0.0.12
|
46
46
|
- !ruby/object:Gem::Dependency
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: 2.14.1
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rubocop
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: simplecov
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,7 +175,6 @@ files:
|
|
159
175
|
- lib/vcloud/schema/firewall_service.rb
|
160
176
|
- lib/vcloud/schema/load_balancer_service.rb
|
161
177
|
- lib/vcloud/schema/nat_service.rb
|
162
|
-
- scripts/generate_fog_conf_file.sh
|
163
178
|
- spec/erb_helper.rb
|
164
179
|
- spec/integration/edge_gateway/data/firewall_config.yaml.erb
|
165
180
|
- spec/integration/edge_gateway/data/firewall_config_updated_rule.yaml.erb
|
@@ -202,6 +217,7 @@ files:
|
|
202
217
|
- spec/vcloud/edge_gateway/load_balancer_schema_validation_spec.rb
|
203
218
|
- spec/vcloud/edge_gateway/nat_configuration_differ_spec.rb
|
204
219
|
- spec/vcloud/edge_gateway/nat_schema_validation_spec.rb
|
220
|
+
- tools/fog_credentials.rb
|
205
221
|
- vcloud-edge_gateway.gemspec
|
206
222
|
homepage: http://github.com/alphagov/vcloud-edge_gateway
|
207
223
|
licenses:
|
@@ -224,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
240
|
version: '0'
|
225
241
|
segments:
|
226
242
|
- 0
|
227
|
-
hash:
|
243
|
+
hash: 346937587144257703
|
228
244
|
requirements: []
|
229
245
|
rubyforge_project:
|
230
246
|
rubygems_version: 1.8.23
|