topo-provision 0.0.1
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/LICENSE +201 -0
- data/README.md +100 -0
- data/bin/topo-provision +23 -0
- data/lib/topo/converter.rb +80 -0
- data/lib/topo/converter/cloudformation/converter.rb +219 -0
- data/lib/topo/exporter.rb +15 -0
- data/lib/topo/loader.rb +31 -0
- data/lib/topo/provision.rb +3 -0
- data/lib/topo/provision/aws/generator.rb +55 -0
- data/lib/topo/provision/aws/generators/aws_auto_scaling_group.rb +61 -0
- data/lib/topo/provision/aws/generators/aws_launch_configuration.rb +65 -0
- data/lib/topo/provision/aws/generators/context.rb +33 -0
- data/lib/topo/provision/aws/generators/load_balancer.rb +47 -0
- data/lib/topo/provision/aws/generators/machine.rb +36 -0
- data/lib/topo/provision/aws/generators/machine_image.rb +38 -0
- data/lib/topo/provision/aws/generators/node_group.rb +64 -0
- data/lib/topo/provision/cli.rb +95 -0
- data/lib/topo/provision/generator.rb +185 -0
- data/lib/topo/provision/generators/chef_node.rb +35 -0
- data/lib/topo/provision/generators/context.rb +70 -0
- data/lib/topo/provision/generators/load_balancer.rb +40 -0
- data/lib/topo/provision/generators/machine.rb +50 -0
- data/lib/topo/provision/generators/machine_image.rb +43 -0
- data/lib/topo/provision/generators/node_group.rb +74 -0
- data/lib/topo/provision/generators/resource.rb +91 -0
- data/lib/topo/provision/generators/templates/context.erb +8 -0
- data/lib/topo/provision/generators/templates/machine_deploy.erb +11 -0
- data/lib/topo/provision/generators/templates/machine_stop.erb +5 -0
- data/lib/topo/provision/generators/templates/node_group_action.erb +6 -0
- data/lib/topo/provision/generators/templates/node_group_deploy.erb +5 -0
- data/lib/topo/provision/generators/templates/resource_deploy.erb +5 -0
- data/lib/topo/provision/generators/templates/resource_undeploy.erb +5 -0
- data/lib/topo/provision/topology_generator.rb +84 -0
- data/lib/topo/provision/vagrant/generator.rb +33 -0
- data/lib/topo/provision/version.rb +5 -0
- data/lib/topo/topology.rb +61 -0
- data/lib/topo/utils/output.rb +31 -0
- data/lib/topo/utils/parsegen.rb +101 -0
- metadata +126 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Christine Draper (<christine_draper@thirdwaveinsights.com>)
|
3
|
+
# Copyright:: Copyright (c) 2015 ThirdWave Insights LLC
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
|
20
|
+
module Topo
|
21
|
+
module Output
|
22
|
+
def divert_stdout
|
23
|
+
previous_stdout, $stdout = $stdout, StringIO.new
|
24
|
+
yield
|
25
|
+
$stdout.string
|
26
|
+
ensure
|
27
|
+
# Restore the previous value of stdout
|
28
|
+
$stdout = previous_stdout
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Christine Draper (<christine_draper@thirdwaveinsights.com>)
|
3
|
+
# Copyright:: Copyright (c) 2015 ThirdWave Insights LLC
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
#
|
20
|
+
# This module contains functions useful for parsing, converting and generating
|
21
|
+
#
|
22
|
+
|
23
|
+
module Topo
|
24
|
+
module ParseGen
|
25
|
+
def value_from_path(hash, path)
|
26
|
+
path.reduce(hash) do |val, key|
|
27
|
+
val.kind_of?(Hash) ? val[key] : nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# convert keys to symbols (deep)
|
32
|
+
# NOTE: recurses into hashes but not into arrays
|
33
|
+
def convert_keys_to_sym(hash)
|
34
|
+
new_hash = {}
|
35
|
+
hash.each do |key, val|
|
36
|
+
new_hash[key.to_sym] = val
|
37
|
+
end
|
38
|
+
new_hash
|
39
|
+
end
|
40
|
+
|
41
|
+
# convert keys to symbols (deep)
|
42
|
+
# NOTE: recurses into hashes but not into arrays
|
43
|
+
def convert_keys_to_sym_deep(hash)
|
44
|
+
new_hash = {}
|
45
|
+
hash.each do |key, val|
|
46
|
+
new_hash[key.to_sym] = val.kind_of?(Hash) ? convert_keys_to_sym_deep(val) : val
|
47
|
+
end
|
48
|
+
new_hash
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# find and return dependencies (names) in topo_refs
|
53
|
+
def topo_refs(hash, depends_on=Set.new)
|
54
|
+
if hash.kind_of? Hash
|
55
|
+
hash.each do |key, val|
|
56
|
+
if key == "topo_ref"
|
57
|
+
depends_on.add val['name']
|
58
|
+
else
|
59
|
+
topo_refs(val, depends_on)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
elsif hash.kind_of? Array
|
63
|
+
hash.each do |val|
|
64
|
+
topo_refs(val, depends_on)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
depends_on
|
68
|
+
end
|
69
|
+
|
70
|
+
# Convert lazy attributes to a string
|
71
|
+
def lazy_attribute_to_s (hash)
|
72
|
+
str = ""
|
73
|
+
hash.each do |key, val|
|
74
|
+
str += ', ' if str != ""
|
75
|
+
if val.kind_of?(Hash)
|
76
|
+
if val.key?("topo_ref") && val.keys.length == 1
|
77
|
+
# this is a topology reference so expand it
|
78
|
+
str += "'#{key}' => " + expand_ref(val['topo_ref'])
|
79
|
+
else
|
80
|
+
str += lazy_attribute_to_s(val)
|
81
|
+
end
|
82
|
+
else
|
83
|
+
str += "'#{key}' => " + val.inspect
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
str
|
88
|
+
end
|
89
|
+
|
90
|
+
# Expand a particular reference into either a node search
|
91
|
+
# In future, may need to search resource type data bag, e.g. using
|
92
|
+
# topo_search_data_bag_fn = Proc.new { |bag, id, path| (search(bag, "id:#{id}", :filter_result => { 'val' => path }).first)['data']['val'] }
|
93
|
+
#
|
94
|
+
def expand_ref(ref)
|
95
|
+
path = ref['path']
|
96
|
+
# Wanted to use the following and define a proc, but does not work for some resources
|
97
|
+
"topo_search_node_fn.call(#{ref['name'].inspect}, #{path})"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: topo-provision
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- christine_draper
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mixlib-cli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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
|
+
description: Write a longer description. Optional.
|
56
|
+
email:
|
57
|
+
- christine_draper@thirdwaveinsights.com
|
58
|
+
executables:
|
59
|
+
- topo-provision
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- bin/topo-provision
|
66
|
+
- lib/topo/converter.rb
|
67
|
+
- lib/topo/converter/cloudformation/converter.rb
|
68
|
+
- lib/topo/exporter.rb
|
69
|
+
- lib/topo/loader.rb
|
70
|
+
- lib/topo/provision.rb
|
71
|
+
- lib/topo/provision/aws/generator.rb
|
72
|
+
- lib/topo/provision/aws/generators/aws_auto_scaling_group.rb
|
73
|
+
- lib/topo/provision/aws/generators/aws_launch_configuration.rb
|
74
|
+
- lib/topo/provision/aws/generators/context.rb
|
75
|
+
- lib/topo/provision/aws/generators/load_balancer.rb
|
76
|
+
- lib/topo/provision/aws/generators/machine.rb
|
77
|
+
- lib/topo/provision/aws/generators/machine_image.rb
|
78
|
+
- lib/topo/provision/aws/generators/node_group.rb
|
79
|
+
- lib/topo/provision/cli.rb
|
80
|
+
- lib/topo/provision/generator.rb
|
81
|
+
- lib/topo/provision/generators/chef_node.rb
|
82
|
+
- lib/topo/provision/generators/context.rb
|
83
|
+
- lib/topo/provision/generators/load_balancer.rb
|
84
|
+
- lib/topo/provision/generators/machine.rb
|
85
|
+
- lib/topo/provision/generators/machine_image.rb
|
86
|
+
- lib/topo/provision/generators/node_group.rb
|
87
|
+
- lib/topo/provision/generators/resource.rb
|
88
|
+
- lib/topo/provision/generators/templates/context.erb
|
89
|
+
- lib/topo/provision/generators/templates/machine_deploy.erb
|
90
|
+
- lib/topo/provision/generators/templates/machine_stop.erb
|
91
|
+
- lib/topo/provision/generators/templates/node_group_action.erb
|
92
|
+
- lib/topo/provision/generators/templates/node_group_deploy.erb
|
93
|
+
- lib/topo/provision/generators/templates/resource_deploy.erb
|
94
|
+
- lib/topo/provision/generators/templates/resource_undeploy.erb
|
95
|
+
- lib/topo/provision/topology_generator.rb
|
96
|
+
- lib/topo/provision/vagrant/generator.rb
|
97
|
+
- lib/topo/provision/version.rb
|
98
|
+
- lib/topo/topology.rb
|
99
|
+
- lib/topo/utils/output.rb
|
100
|
+
- lib/topo/utils/parsegen.rb
|
101
|
+
homepage: ''
|
102
|
+
licenses:
|
103
|
+
- Apache License (2.0)
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.4.4
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Write a short summary. Required.
|
125
|
+
test_files: []
|
126
|
+
has_rdoc:
|