skyscape-vpn 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/Rakefile +13 -13
- data/bin/skyscape-vpn +4 -4
- data/lib/cli.rb +28 -28
- data/lib/configuration.rb +39 -39
- data/lib/main.rb +83 -83
- data/lib/version.rb +7 -7
- data/skyscape-vpn.gemspec +36 -36
- metadata +4 -5
- data/bin/skyscape-vpn.bat +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a072a576f027e00aa7e7bf038869fea21d8d1db9
|
4
|
+
data.tar.gz: 44e3fb53bddf8988d1943f20e06d1f906a29e7b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83c23fb510ec1d01e42825db7e5ff5c3fb8ecc1aed79dcd56287464eb12282f203fa1f4936d32fac4569b5fe9e4273eaadcb2aec6c4c10ee66e087ebc539135a
|
7
|
+
data.tar.gz: bb61d511315c1467cc06e76d27501c559d40843f10441557bac5d3d90a8b53c4f25738f12bb0d19b2b309314ac38a3e1eb1d4afd417657976254ee4a20702d88
|
data/Rakefile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
require 'cucumber'
|
4
|
-
require 'cucumber/rake/task'
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
8
|
-
t.cucumber_opts = "features --format pretty"
|
9
|
-
end
|
10
|
-
|
11
|
-
task :default => :spec
|
12
|
-
task :test => :spec
|
13
|
-
task :test => :features
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
8
|
+
t.cucumber_opts = "features --format pretty"
|
9
|
+
end
|
10
|
+
|
11
|
+
task :default => :spec
|
12
|
+
task :test => :spec
|
13
|
+
task :test => :features
|
data/bin/skyscape-vpn
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
3
|
-
require 'cli'
|
4
|
-
Skyscape::Vcloud::Ipsec::Cli.start(ARGV)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
3
|
+
require 'cli'
|
4
|
+
Skyscape::Vcloud::Ipsec::Cli.start(ARGV)
|
data/lib/cli.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'main'
|
3
|
-
require 'version'
|
4
|
-
|
5
|
-
module Skyscape
|
6
|
-
module Vcloud
|
7
|
-
module Ipsec
|
8
|
-
class Cli < Thor
|
9
|
-
desc "version", "Print skyscape-vpn version"
|
10
|
-
|
11
|
-
|
12
|
-
def version
|
13
|
-
puts Skyscape::Vcloud::Ipsec::VERSION
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
desc "apply <location>", "Begin configuration of IPSec tunnels"
|
18
|
-
def apply(path)
|
19
|
-
begin
|
20
|
-
Skyscape::Vcloud::Ipsec::Main.new(path)
|
21
|
-
rescue Exception => e
|
22
|
-
puts e.message
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
1
|
+
require 'thor'
|
2
|
+
require 'main'
|
3
|
+
require 'version'
|
4
|
+
|
5
|
+
module Skyscape
|
6
|
+
module Vcloud
|
7
|
+
module Ipsec
|
8
|
+
class Cli < Thor
|
9
|
+
desc "version", "Print skyscape-vpn version"
|
10
|
+
|
11
|
+
|
12
|
+
def version
|
13
|
+
puts Skyscape::Vcloud::Ipsec::VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
desc "apply <location>", "Begin configuration of IPSec tunnels"
|
18
|
+
def apply(path)
|
19
|
+
begin
|
20
|
+
Skyscape::Vcloud::Ipsec::Main.new(path)
|
21
|
+
rescue Exception => e
|
22
|
+
puts e.message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/configuration.rb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'active_support/hash_with_indifferent_access'
|
3
|
-
|
4
|
-
|
5
|
-
module Skyscape
|
6
|
-
module Vcloud
|
7
|
-
module Ipsec
|
8
|
-
class Configuration
|
9
|
-
attr_accessor :file_location, :full_config, :firewalls
|
10
|
-
def initialize(file_location = "#{Dir.pwd}/firewalls.yml")
|
11
|
-
@file_location = file_location
|
12
|
-
raise("Configuration File Not Found At #{file_location}") unless File.exists?(file_location)
|
13
|
-
|
14
|
-
@full_config = load_yaml
|
15
|
-
@firewalls = parse_config
|
16
|
-
end
|
17
|
-
|
18
|
-
def load_yaml
|
19
|
-
file = File.open(@file_location)
|
20
|
-
conf = YAML.load(file)
|
21
|
-
file.close
|
22
|
-
|
23
|
-
conf.deep_symbolize_keys! unless conf == false
|
24
|
-
end
|
25
|
-
|
26
|
-
def parse_config
|
27
|
-
raise("No firewalls In Config File: #{@file_location}") unless @full_config.is_a?(Hash) && @full_config[:Firewalls]
|
28
|
-
raise("No firewalls In Config File: #{@file_location}") unless @full_config[:Firewalls].is_a?(Array) && @full_config[:Firewalls].length > 0
|
29
|
-
#To Do: Add Config Schema?
|
30
|
-
@full_config[:Firewalls]
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
require 'yaml'
|
2
|
+
require 'active_support/hash_with_indifferent_access'
|
3
|
+
|
4
|
+
|
5
|
+
module Skyscape
|
6
|
+
module Vcloud
|
7
|
+
module Ipsec
|
8
|
+
class Configuration
|
9
|
+
attr_accessor :file_location, :full_config, :firewalls
|
10
|
+
def initialize(file_location = "#{Dir.pwd}/firewalls.yml")
|
11
|
+
@file_location = file_location
|
12
|
+
raise("Configuration File Not Found At #{file_location}") unless File.exists?(file_location)
|
13
|
+
|
14
|
+
@full_config = load_yaml
|
15
|
+
@firewalls = parse_config
|
16
|
+
end
|
17
|
+
|
18
|
+
def load_yaml
|
19
|
+
file = File.open(@file_location)
|
20
|
+
conf = YAML.load(file)
|
21
|
+
file.close
|
22
|
+
|
23
|
+
conf.deep_symbolize_keys! unless conf == false
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_config
|
27
|
+
raise("No firewalls In Config File: #{@file_location}") unless @full_config.is_a?(Hash) && @full_config[:Firewalls]
|
28
|
+
raise("No firewalls In Config File: #{@file_location}") unless @full_config[:Firewalls].is_a?(Array) && @full_config[:Firewalls].length > 0
|
29
|
+
#To Do: Add Config Schema?
|
30
|
+
@full_config[:Firewalls]
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
40
|
end
|
data/lib/main.rb
CHANGED
@@ -1,83 +1,83 @@
|
|
1
|
-
require 'fog'
|
2
|
-
require 'configuration'
|
3
|
-
|
4
|
-
|
5
|
-
module Skyscape
|
6
|
-
module Vcloud
|
7
|
-
module Ipsec
|
8
|
-
class Main
|
9
|
-
attr_accessor :config
|
10
|
-
def initialize(config_file)
|
11
|
-
@config = Skyscape::Vcloud::Ipsec::Configuration.new(config_file)
|
12
|
-
configure_firewalls(@config.firewalls)
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def configure_firewalls(firewalls)
|
17
|
-
firewalls.each do |firewall|
|
18
|
-
configure_firewall(firewall)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def configure_firewall(firewall)
|
23
|
-
creds = firewall[:Creds]
|
24
|
-
connection = vcloud_login(creds)
|
25
|
-
edge_id = get_edge_href(creds[:Edge],connection).split('/').last
|
26
|
-
|
27
|
-
puts "Configuring VPN Service For Firewall: #{creds[:Edge]}"
|
28
|
-
task = connection.post_configure_edge_gateway_services(edge_id,firewall).body
|
29
|
-
monitor_task(task[:href].split('/').last,connection)
|
30
|
-
puts "Finished Configuring VPN Service For Firewall: #{creds[:Edge]}"
|
31
|
-
|
32
|
-
#TO DO: SUPPORT MERGING CONFIG WITH EXISTING
|
33
|
-
#current_config = get_current_config(edge_href,connection)
|
34
|
-
#new_config = merge_configs(current_config, new_config)
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def vcloud_login(creds)
|
39
|
-
puts "Connecting to vCloud Director API"
|
40
|
-
connection = Fog::Compute::VcloudDirector.new(
|
41
|
-
:vcloud_director_username => "#{creds[:User]}@#{creds[:Org]}",
|
42
|
-
:vcloud_director_password => creds[:Password],
|
43
|
-
:vcloud_director_host => creds[:Url],
|
44
|
-
:vcloud_director_show_progress => true, # task progress bar on/off
|
45
|
-
:connection_options => {
|
46
|
-
:omit_default_port => true
|
47
|
-
}
|
48
|
-
)
|
49
|
-
puts "Connected to vCloud Director API"
|
50
|
-
|
51
|
-
connection
|
52
|
-
end
|
53
|
-
|
54
|
-
def get_edge_href(edge_name, connection)
|
55
|
-
puts "Getting vShield Edge HREF From Query"
|
56
|
-
results = connection.get_execute_query(type="edgeGateway", :filter => "name==#{edge_name}").body
|
57
|
-
|
58
|
-
raise "Edge #{edge_name} Not Found!" unless results[:total] == "1"
|
59
|
-
raise "Edge Name #{edge_name} Not Unique!" if results[:total].to_i > 1
|
60
|
-
puts "Finished Getting vShield Edge HREF From Query"
|
61
|
-
result = results[:EdgeGatewayRecord][:href]
|
62
|
-
end
|
63
|
-
|
64
|
-
def get_current_config(edge_href,connection)
|
65
|
-
configuration = connection.get_edge_gateway(edge_href.split('/').last).body
|
66
|
-
|
67
|
-
vpn_service = configuration[:Configuration][:EdgeGatewayServiceConfiguration][:GatewayIpsecVpnService]
|
68
|
-
end
|
69
|
-
|
70
|
-
def monitor_task(task_id,connection)
|
71
|
-
task = connection.get_task(task_id).body
|
72
|
-
while(task[:status] == "running") do
|
73
|
-
puts " Task: #{task[:operation]} Still Running"
|
74
|
-
task = connection.get_task(task_id).body
|
75
|
-
sleep(3)
|
76
|
-
end
|
77
|
-
|
78
|
-
puts " Task: #{task[:operation]} Completed With Status: #{task[:status]}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
1
|
+
require 'fog'
|
2
|
+
require 'configuration'
|
3
|
+
|
4
|
+
|
5
|
+
module Skyscape
|
6
|
+
module Vcloud
|
7
|
+
module Ipsec
|
8
|
+
class Main
|
9
|
+
attr_accessor :config
|
10
|
+
def initialize(config_file)
|
11
|
+
@config = Skyscape::Vcloud::Ipsec::Configuration.new(config_file)
|
12
|
+
configure_firewalls(@config.firewalls)
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure_firewalls(firewalls)
|
17
|
+
firewalls.each do |firewall|
|
18
|
+
configure_firewall(firewall)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure_firewall(firewall)
|
23
|
+
creds = firewall[:Creds]
|
24
|
+
connection = vcloud_login(creds)
|
25
|
+
edge_id = get_edge_href(creds[:Edge],connection).split('/').last
|
26
|
+
|
27
|
+
puts "Configuring VPN Service For Firewall: #{creds[:Edge]}"
|
28
|
+
task = connection.post_configure_edge_gateway_services(edge_id,firewall).body
|
29
|
+
monitor_task(task[:href].split('/').last,connection)
|
30
|
+
puts "Finished Configuring VPN Service For Firewall: #{creds[:Edge]}"
|
31
|
+
|
32
|
+
#TO DO: SUPPORT MERGING CONFIG WITH EXISTING
|
33
|
+
#current_config = get_current_config(edge_href,connection)
|
34
|
+
#new_config = merge_configs(current_config, new_config)
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def vcloud_login(creds)
|
39
|
+
puts "Connecting to vCloud Director API"
|
40
|
+
connection = Fog::Compute::VcloudDirector.new(
|
41
|
+
:vcloud_director_username => "#{creds[:User]}@#{creds[:Org]}",
|
42
|
+
:vcloud_director_password => creds[:Password],
|
43
|
+
:vcloud_director_host => creds[:Url],
|
44
|
+
:vcloud_director_show_progress => true, # task progress bar on/off
|
45
|
+
:connection_options => {
|
46
|
+
:omit_default_port => true
|
47
|
+
}
|
48
|
+
)
|
49
|
+
puts "Connected to vCloud Director API"
|
50
|
+
|
51
|
+
connection
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_edge_href(edge_name, connection)
|
55
|
+
puts "Getting vShield Edge HREF From Query"
|
56
|
+
results = connection.get_execute_query(type="edgeGateway", :filter => "name==#{edge_name}").body
|
57
|
+
|
58
|
+
raise "Edge #{edge_name} Not Found!" unless results[:total] == "1"
|
59
|
+
raise "Edge Name #{edge_name} Not Unique!" if results[:total].to_i > 1
|
60
|
+
puts "Finished Getting vShield Edge HREF From Query"
|
61
|
+
result = results[:EdgeGatewayRecord][:href]
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_current_config(edge_href,connection)
|
65
|
+
configuration = connection.get_edge_gateway(edge_href.split('/').last).body
|
66
|
+
|
67
|
+
vpn_service = configuration[:Configuration][:EdgeGatewayServiceConfiguration][:GatewayIpsecVpnService]
|
68
|
+
end
|
69
|
+
|
70
|
+
def monitor_task(task_id,connection)
|
71
|
+
task = connection.get_task(task_id).body
|
72
|
+
while(task[:status] == "running") do
|
73
|
+
puts " Task: #{task[:operation]} Still Running"
|
74
|
+
task = connection.get_task(task_id).body
|
75
|
+
sleep(3)
|
76
|
+
end
|
77
|
+
|
78
|
+
puts " Task: #{task[:operation]} Completed With Status: #{task[:status]}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module Skyscape
|
2
|
-
module Vcloud
|
3
|
-
module Ipsec
|
4
|
-
VERSION = "0.0.
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
1
|
+
module Skyscape
|
2
|
+
module Vcloud
|
3
|
+
module Ipsec
|
4
|
+
VERSION = "0.0.5"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/skyscape-vpn.gemspec
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "skyscape-vpn"
|
8
|
-
spec.version = Skyscape::Vcloud::Ipsec::VERSION
|
9
|
-
spec.authors = ["Tim Lawrence"]
|
10
|
-
spec.email = ["tlawrence@skyscapecloud.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Configure vCloud Director IPSec VPNs}
|
13
|
-
spec.homepage = "https://github.com/skyscape-cloud-services"
|
14
|
-
|
15
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
16
|
-
# delete this section to allow pushing this gem to any host.
|
17
|
-
if spec.respond_to?(:metadata)
|
18
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
-
else
|
20
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
-
end
|
22
|
-
|
23
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
-
spec.bindir = "bin"
|
25
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
|
-
spec.require_paths = ["lib"]
|
27
|
-
|
28
|
-
spec.add_development_dependency "bundler", "~> 1.10"
|
29
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
-
spec.add_development_dependency "rspec"
|
31
|
-
spec.add_development_dependency "aruba"
|
32
|
-
|
33
|
-
spec.add_runtime_dependency 'fog', '>=1.26.0'
|
34
|
-
spec.add_runtime_dependency 'activesupport'
|
35
|
-
spec.add_runtime_dependency 'thor'
|
36
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "skyscape-vpn"
|
8
|
+
spec.version = Skyscape::Vcloud::Ipsec::VERSION
|
9
|
+
spec.authors = ["Tim Lawrence"]
|
10
|
+
spec.email = ["tlawrence@skyscapecloud.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Configure vCloud Director IPSec VPNs}
|
13
|
+
spec.homepage = "https://github.com/skyscape-cloud-services"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
16
|
+
# delete this section to allow pushing this gem to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.bindir = "bin"
|
25
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec"
|
31
|
+
spec.add_development_dependency "aruba"
|
32
|
+
|
33
|
+
spec.add_runtime_dependency 'fog', '>=1.26.0'
|
34
|
+
spec.add_runtime_dependency 'activesupport'
|
35
|
+
spec.add_runtime_dependency 'thor'
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skyscape-vpn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Lawrence
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,7 +113,6 @@ email:
|
|
113
113
|
- tlawrence@skyscapecloud.com
|
114
114
|
executables:
|
115
115
|
- skyscape-vpn
|
116
|
-
- skyscape-vpn.bat
|
117
116
|
extensions: []
|
118
117
|
extra_rdoc_files: []
|
119
118
|
files:
|
@@ -124,7 +123,6 @@ files:
|
|
124
123
|
- README.md
|
125
124
|
- Rakefile
|
126
125
|
- bin/skyscape-vpn
|
127
|
-
- bin/skyscape-vpn.bat
|
128
126
|
- lib/cli.rb
|
129
127
|
- lib/configuration.rb
|
130
128
|
- lib/main.rb
|
@@ -150,8 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
148
|
version: '0'
|
151
149
|
requirements: []
|
152
150
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.0.3
|
154
152
|
signing_key:
|
155
153
|
specification_version: 4
|
156
154
|
summary: Configure vCloud Director IPSec VPNs
|
157
155
|
test_files: []
|
156
|
+
has_rdoc:
|