skyscape-vpn 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +13 -0
- data/bin/skyscape-vpn +4 -0
- data/lib/cli.rb +28 -0
- data/lib/configuration.rb +40 -0
- data/lib/main.rb +83 -0
- data/lib/version.rb +7 -0
- data/skyscape-vpn.gemspec +36 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de9aa4635062a7f57183a7480789535eec6fe783
|
4
|
+
data.tar.gz: 12429326196c699fa058128239bfad4e8648be04
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ebb52cf3bcc0dd2f8186ea90395889e39e5a6170c2f2e24f912e5d6146d82c136915158f7abf68b297e45e70dbfe751cf2f031129b18d4a2745e0fe6411ffd7a
|
7
|
+
data.tar.gz: ee136682c2d9ed3cd6051178ac77a4e62b5ffcd6f81a7ac5a53c018a447a1edf382ca724c9f8e69b62f2a297920eb0966e8c23e26f0db428bb60cf51dd2f2435
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Skyscape::Vpn
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/skyscape/vpn`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'skyscape-vpn'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install skyscape-vpn
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/skyscape-vpn.
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +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
|
data/bin/skyscape-vpn
ADDED
data/lib/cli.rb
ADDED
@@ -0,0 +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
|
@@ -0,0 +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
|
40
|
+
end
|
data/lib/main.rb
ADDED
@@ -0,0 +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
|
data/lib/version.rb
ADDED
@@ -0,0 +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 = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |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
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skyscape-vpn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Lawrence
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aruba
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fog
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.26.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.26.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: thor
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- tlawrence@skyscapecloud.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- bin/skyscape-vpn
|
125
|
+
- lib/cli.rb
|
126
|
+
- lib/configuration.rb
|
127
|
+
- lib/main.rb
|
128
|
+
- lib/version.rb
|
129
|
+
- skyscape-vpn.gemspec
|
130
|
+
homepage: https://github.com/skyscape-cloud-services
|
131
|
+
licenses: []
|
132
|
+
metadata:
|
133
|
+
allowed_push_host: https://rubygems.org
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.4.8
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Configure vCloud Director IPSec VPNs
|
154
|
+
test_files: []
|