fog-networking 0.1.0
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fog-networking.gemspec +32 -0
- data/lib/fog/networking.rb +17 -0
- data/lib/fog/networking/aws/compute.rb +13 -0
- data/lib/fog/networking/oraclecloud/compute.rb +34 -0
- data/lib/fog/networking/oraclecloud/database.rb +14 -0
- data/lib/fog/networking/provider.rb +13 -0
- data/lib/fog/networking/services.rb +34 -0
- data/lib/fog/networking/version.rb +5 -0
- data/registry.yaml +4 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a1f9c8af739ae9582e66a3e05b8e99254bb68059
|
4
|
+
data.tar.gz: e94ff2facdb206a94093320f0df813d28e679293
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a76b9c9c6456b7f46d7c84db6239f91018725b6e5387ae760f4c04210c6feaec2483c6c07658dcb312070a4e47506e27d78561d4029ebf5fe92bbcc85957f62b
|
7
|
+
data.tar.gz: ce2f7393a5238bccc3f26dfb9ec14fb2fb9cabc8e033fcfdf922b16ef99d28777e95bb6f6f6a763091e58fa105bd8486f2c3b8a57aaf16df6a5d95af58572809
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
source 'https://rubygems.org'
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Joel Nation
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Fog::Networking
|
2
|
+
|
3
|
+
Module for the 'fog' gem to provide a simplified way to connect services between clouds
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fog-networking'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fog-networking
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Assumming you've created (or got) two instances the syntax is:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Fog::Networking::Services.connect_instances(instance_1, instance_2, port)
|
27
|
+
```
|
28
|
+
|
29
|
+
You can monitor what it's doing by using the Fog::Logger (which adds entries to STD_ERR if you set DEBUG=true in your environment variables).
|
30
|
+
|
31
|
+
Currently this only supports AWS -> Oracle Compute or Database Cloud. Feel free to contribute other scenarios through a pull request.
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joelith/fog-networking.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fog/networking"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fog/networking/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fog-networking"
|
8
|
+
spec.version = Fog::Networking::VERSION
|
9
|
+
spec.authors = ["Joel Nation"]
|
10
|
+
spec.email = ["joel.nation@outlook.com"]
|
11
|
+
|
12
|
+
spec.summary = "Gem to auto-configure networking between different cloud providers using the Fog Library"
|
13
|
+
spec.description = "Gem to auto-configure networking between different cloud providers using the Fog Library"
|
14
|
+
spec.homepage = "http://github.com/Joelith/fog-networking"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
|
28
|
+
#spec.add_dependency 'fog-aws'
|
29
|
+
#spec.add_dependency 'fog-oraclecloud'
|
30
|
+
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "fog/networking/version"
|
2
|
+
require "fog/networking/services"
|
3
|
+
require "fog/networking/provider"
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
module Fog
|
7
|
+
module Networking
|
8
|
+
module OracleCloud
|
9
|
+
autoload :Compute, File.expand_path('../networking/oraclecloud/compute', __FILE__)
|
10
|
+
autoload :Database, File.expand_path('../networking/oraclecloud/database', __FILE__)
|
11
|
+
end
|
12
|
+
module AWS
|
13
|
+
autoload :Compute, File.expand_path('../networking/aws/compute', __FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Networking
|
5
|
+
module OracleCloud
|
6
|
+
class Compute < Fog::Networking::Provider
|
7
|
+
def prepare
|
8
|
+
@secList = nil
|
9
|
+
# Check if it has a non-default security list
|
10
|
+
secLists = @instance.get_security_lists
|
11
|
+
secLists.each do |i|
|
12
|
+
if !i.name.include? '/default/default' then @secList = i end
|
13
|
+
end
|
14
|
+
if !@secList then
|
15
|
+
Fog::Logger.debug "Only has default security list. Add one now"
|
16
|
+
@secList = @instance.create_security_list
|
17
|
+
end
|
18
|
+
|
19
|
+
# Check if it has a public ip
|
20
|
+
if !@instance.get_public_ip_address then
|
21
|
+
Fog::Logger.debug "Instance doesn't have a public ip address. Add one now"
|
22
|
+
@instance.add_public_ip_address
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def connect(ip, port)
|
28
|
+
Fog::Logger.debug "Connecting #{ip} through port #{port} for #{@instance.name}"
|
29
|
+
@secList.add_rule(port, ip);
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Networking
|
5
|
+
module OracleCloud
|
6
|
+
class Database < Fog::Networking::Provider
|
7
|
+
def connect(ip, port)
|
8
|
+
Fog::Logger.debug "Connecting #{ip} through port #{port} for #{@instance.service_name}"
|
9
|
+
@instance.add_rule(port, ip);
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fog
|
2
|
+
module Networking
|
3
|
+
class Services
|
4
|
+
|
5
|
+
def self.connect_instances(instance_from, instance_to, port)
|
6
|
+
if instance_from == nil || instance_to == nil then
|
7
|
+
raise ArgumentError.new('Need to a Fog instance of both from and to');
|
8
|
+
end
|
9
|
+
|
10
|
+
# Not sure if this is the best approach. I had considered extending the actual
|
11
|
+
# fog libraries and adding the extra functions we need, but then I'd have to
|
12
|
+
# include all the fog modules as dependencies to this one, regardless if the
|
13
|
+
# end user wanted to use them all or not. Simple approach seemed to be to
|
14
|
+
# just record which objects map to which classes in here.
|
15
|
+
|
16
|
+
registry = YAML.load_file( File.expand_path('registry.yaml'))
|
17
|
+
if !registry[instance_to.class.to_s] then
|
18
|
+
raise ArgumentError.new("Fog::Networking does not currently support #{instance_to.class.to_s}")
|
19
|
+
end
|
20
|
+
if !registry[instance_from.class.to_s] then
|
21
|
+
raise ArgumentError.new("Fog::Networking does not currently support #{instance_from.class.to_s}")
|
22
|
+
end
|
23
|
+
|
24
|
+
service_to = Object.const_get(registry[instance_to.class.to_s]).new(instance_to)
|
25
|
+
service_to.prepare
|
26
|
+
service_from = Object.const_get(registry[instance_from.class.to_s]).new(instance_from)
|
27
|
+
service_from.prepare
|
28
|
+
|
29
|
+
# connect the two instances
|
30
|
+
service_to.connect(service_from.get_ip_address, port)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/registry.yaml
ADDED
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fog-networking
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joel Nation
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-12 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.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
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: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Gem to auto-configure networking between different cloud providers using
|
56
|
+
the Fog Library
|
57
|
+
email:
|
58
|
+
- joel.nation@outlook.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- fog-networking.gemspec
|
73
|
+
- lib/fog/networking.rb
|
74
|
+
- lib/fog/networking/aws/compute.rb
|
75
|
+
- lib/fog/networking/oraclecloud/compute.rb
|
76
|
+
- lib/fog/networking/oraclecloud/database.rb
|
77
|
+
- lib/fog/networking/provider.rb
|
78
|
+
- lib/fog/networking/services.rb
|
79
|
+
- lib/fog/networking/version.rb
|
80
|
+
- registry.yaml
|
81
|
+
homepage: http://github.com/Joelith/fog-networking
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.5.1
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Gem to auto-configure networking between different cloud providers using
|
105
|
+
the Fog Library
|
106
|
+
test_files: []
|