coral_core 0.2.30 → 0.4.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/Gemfile +2 -8
- data/Gemfile.lock +15 -86
- data/Rakefile +1 -3
- data/VERSION +1 -1
- data/coral_core.gemspec +12 -102
- metadata +18 -239
- data/lib/coral/command/shell.rb +0 -140
- data/lib/coral/machine/fog.rb +0 -215
- data/lib/coral/network/default.rb +0 -26
- data/lib/coral/node/rackspace.rb +0 -23
- data/lib/coral_core/config/collection.rb +0 -57
- data/lib/coral_core/config/options.rb +0 -70
- data/lib/coral_core/config/project.rb +0 -225
- data/lib/coral_core/config.rb +0 -329
- data/lib/coral_core/core.rb +0 -58
- data/lib/coral_core/event/puppet_event.rb +0 -98
- data/lib/coral_core/event/regexp_event.rb +0 -55
- data/lib/coral_core/event.rb +0 -170
- data/lib/coral_core/mixin/config_collection.rb +0 -52
- data/lib/coral_core/mixin/config_ops.rb +0 -51
- data/lib/coral_core/mixin/config_options.rb +0 -38
- data/lib/coral_core/mixin/lookup.rb +0 -211
- data/lib/coral_core/mixin/macro/object_interface.rb +0 -292
- data/lib/coral_core/mixin/macro/plugin_interface.rb +0 -277
- data/lib/coral_core/mixin/settings.rb +0 -46
- data/lib/coral_core/mixin/sub_config.rb +0 -208
- data/lib/coral_core/mod/hash.rb +0 -29
- data/lib/coral_core/mod/hiera_backend.rb +0 -63
- data/lib/coral_core/plugin/command.rb +0 -95
- data/lib/coral_core/plugin/machine.rb +0 -152
- data/lib/coral_core/plugin/network.rb +0 -24
- data/lib/coral_core/plugin/node.rb +0 -184
- data/lib/coral_core/plugin.rb +0 -261
- data/lib/coral_core/plugin_base.rb +0 -147
- data/lib/coral_core/repository.rb +0 -553
- data/lib/coral_core/resource.rb +0 -243
- data/lib/coral_core/template/environment.rb +0 -72
- data/lib/coral_core/template/json.rb +0 -13
- data/lib/coral_core/template/wrapper.rb +0 -13
- data/lib/coral_core/template/yaml.rb +0 -13
- data/lib/coral_core/template.rb +0 -92
- data/lib/coral_core/util/cli.rb +0 -293
- data/lib/coral_core/util/data.rb +0 -389
- data/lib/coral_core/util/disk.rb +0 -105
- data/lib/coral_core/util/git.rb +0 -40
- data/lib/coral_core/util/interface.rb +0 -190
- data/lib/coral_core/util/process.rb +0 -43
- data/lib/coral_core/util/shell.rb +0 -183
- data/lib/coral_core.rb +0 -375
- data/locales/en.yml +0 -8
- data/spec/coral_core/interface_spec.rb +0 -489
- data/spec/coral_mock_input.rb +0 -29
- data/spec/coral_test_kernel.rb +0 -22
- data/spec/spec_helper.rb +0 -15
data/lib/coral_core/mod/hash.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
#-------------------------------------------------------------------------------
|
3
|
-
# Hash data type alterations
|
4
|
-
|
5
|
-
class Hash
|
6
|
-
def search(search_key, options = {})
|
7
|
-
config = Coral::Config.ensure(options)
|
8
|
-
value = nil
|
9
|
-
|
10
|
-
recurse = config.get(:recurse, false)
|
11
|
-
recurse_level = config.get(:recurse_level, -1)
|
12
|
-
|
13
|
-
self.each do |key, data|
|
14
|
-
if key == search_key
|
15
|
-
value = data
|
16
|
-
|
17
|
-
elsif data.is_a?(Hash) &&
|
18
|
-
recurse && (recurse_level == -1 || recurse_level > 0)
|
19
|
-
|
20
|
-
recurse_level -= 1 unless recurse_level == -1
|
21
|
-
value = value.search(search_key,
|
22
|
-
Coral::Config.new(config).set(:recurse_level, recurse_level)
|
23
|
-
)
|
24
|
-
end
|
25
|
-
break unless value.nil?
|
26
|
-
end
|
27
|
-
return value
|
28
|
-
end
|
29
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'hiera/backend'
|
3
|
-
|
4
|
-
class Hiera
|
5
|
-
module Backend
|
6
|
-
#
|
7
|
-
# NOTE: This function is overridden so we can collect accumulated hiera
|
8
|
-
# parameters and their values on a particular puppet run for reporting
|
9
|
-
# purposes.
|
10
|
-
#
|
11
|
-
# Calls out to all configured backends in the order they
|
12
|
-
# were specified. The first one to answer will win.
|
13
|
-
#
|
14
|
-
# This lets you declare multiple backends, a possible
|
15
|
-
# use case might be in Puppet where a Puppet module declares
|
16
|
-
# default data using in-module data while users can override
|
17
|
-
# using JSON/YAML etc. By layering the backends and putting
|
18
|
-
# the Puppet one last you can override module author data
|
19
|
-
# easily.
|
20
|
-
#
|
21
|
-
# Backend instances are cached so if you need to connect to any
|
22
|
-
# databases then do so in your constructor, future calls to your
|
23
|
-
# backend will not create new instances
|
24
|
-
def lookup(key, default, scope, order_override, resolution_type)
|
25
|
-
@backends ||= {}
|
26
|
-
answer = nil
|
27
|
-
|
28
|
-
Config[:backends].each do |backend|
|
29
|
-
if constants.include?("#{backend.capitalize}_backend") || constants.include?("#{backend.capitalize}_backend".to_sym)
|
30
|
-
@backends[backend] ||= Backend.const_get("#{backend.capitalize}_backend").new
|
31
|
-
new_answer = @backends[backend].lookup(key, scope, order_override, resolution_type)
|
32
|
-
|
33
|
-
if not new_answer.nil?
|
34
|
-
case resolution_type
|
35
|
-
when :array
|
36
|
-
raise Exception, "Hiera type mismatch: expected Array and got #{new_answer.class}" unless new_answer.kind_of? Array or new_answer.kind_of? String
|
37
|
-
answer ||= []
|
38
|
-
answer << new_answer
|
39
|
-
when :hash
|
40
|
-
raise Exception, "Hiera type mismatch: expected Hash and got #{new_answer.class}" unless new_answer.kind_of? Hash
|
41
|
-
answer ||= {}
|
42
|
-
answer = merge_answer(new_answer,answer)
|
43
|
-
else
|
44
|
-
answer = new_answer
|
45
|
-
break
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
answer = resolve_answer(answer, resolution_type) unless answer.nil?
|
52
|
-
answer = parse_string(default, scope) if answer.nil? and default.is_a?(String)
|
53
|
-
|
54
|
-
answer = default if answer.nil?
|
55
|
-
|
56
|
-
Coral::Config.set_property(key, answer) # This is why we override this function!!
|
57
|
-
return answer
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
rescue LoadError
|
63
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Plugin
|
4
|
-
class Command < Base
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Command plugin interface
|
8
|
-
|
9
|
-
def to_s
|
10
|
-
return build(export)
|
11
|
-
end
|
12
|
-
|
13
|
-
#-----------------------------------------------------------------------------
|
14
|
-
# Property accessor / modifiers
|
15
|
-
|
16
|
-
def command(default = '')
|
17
|
-
return string(get(:command, default))
|
18
|
-
end
|
19
|
-
|
20
|
-
#---
|
21
|
-
|
22
|
-
def command=command
|
23
|
-
set(:command, string(command))
|
24
|
-
end
|
25
|
-
|
26
|
-
#---
|
27
|
-
|
28
|
-
def args(default = [])
|
29
|
-
return array(get(:args, default))
|
30
|
-
end
|
31
|
-
|
32
|
-
#---
|
33
|
-
|
34
|
-
def args=args
|
35
|
-
set(:args, array(args))
|
36
|
-
end
|
37
|
-
|
38
|
-
#---
|
39
|
-
|
40
|
-
def flags(default = [])
|
41
|
-
return array(get(:flags, default))
|
42
|
-
end
|
43
|
-
|
44
|
-
#---
|
45
|
-
|
46
|
-
def flags=flags
|
47
|
-
set(:flags, array(flags))
|
48
|
-
end
|
49
|
-
|
50
|
-
#---
|
51
|
-
|
52
|
-
def data(default = {})
|
53
|
-
return hash(get(:data, default))
|
54
|
-
end
|
55
|
-
|
56
|
-
#---
|
57
|
-
|
58
|
-
def data=data
|
59
|
-
set(:data, hash(data))
|
60
|
-
end
|
61
|
-
|
62
|
-
#---
|
63
|
-
|
64
|
-
def subcommand=subcommand
|
65
|
-
unless Util::Data.empty?(subcommand)
|
66
|
-
set(:subcommand, new(hash(subcommand)))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
#-----------------------------------------------------------------------------
|
71
|
-
# Plugin operations
|
72
|
-
|
73
|
-
|
74
|
-
#-----------------------------------------------------------------------------
|
75
|
-
# Command operations
|
76
|
-
|
77
|
-
def build(components = {}, overrides = nil, override_key = false)
|
78
|
-
return '' # Implement in sub classes
|
79
|
-
end
|
80
|
-
|
81
|
-
#---
|
82
|
-
|
83
|
-
def exec!(options = {}, overrides = nil)
|
84
|
-
# Implement in sub classes (don't forget the yield!)
|
85
|
-
return true
|
86
|
-
end
|
87
|
-
|
88
|
-
#---
|
89
|
-
|
90
|
-
def exec(options = {}, overrides = nil)
|
91
|
-
return exec!(options, overrides)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,152 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Plugin
|
4
|
-
class Machine < Base
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Machine plugin interface
|
8
|
-
|
9
|
-
|
10
|
-
#-----------------------------------------------------------------------------
|
11
|
-
# Checks
|
12
|
-
|
13
|
-
def created?
|
14
|
-
return false
|
15
|
-
end
|
16
|
-
|
17
|
-
#---
|
18
|
-
|
19
|
-
def running?
|
20
|
-
return ( created? && false )
|
21
|
-
end
|
22
|
-
|
23
|
-
#-----------------------------------------------------------------------------
|
24
|
-
# Property accessors / modifiers
|
25
|
-
|
26
|
-
def hostname
|
27
|
-
return get(:hostname, '')
|
28
|
-
end
|
29
|
-
|
30
|
-
#---
|
31
|
-
|
32
|
-
def state
|
33
|
-
return get(:state, nil)
|
34
|
-
end
|
35
|
-
|
36
|
-
#---
|
37
|
-
|
38
|
-
def public_ip
|
39
|
-
return get(:public_ip, nil)
|
40
|
-
end
|
41
|
-
|
42
|
-
#---
|
43
|
-
|
44
|
-
def private_ip
|
45
|
-
return get(:private_ip, nil)
|
46
|
-
end
|
47
|
-
|
48
|
-
#-----------------------------------------------------------------------------
|
49
|
-
# Management
|
50
|
-
|
51
|
-
def create(options = {})
|
52
|
-
unless created?
|
53
|
-
|
54
|
-
end
|
55
|
-
return true
|
56
|
-
end
|
57
|
-
|
58
|
-
#---
|
59
|
-
|
60
|
-
def start(options = {})
|
61
|
-
unless running?
|
62
|
-
|
63
|
-
end
|
64
|
-
return true
|
65
|
-
end
|
66
|
-
|
67
|
-
#---
|
68
|
-
|
69
|
-
def stop(options = {})
|
70
|
-
if running?
|
71
|
-
|
72
|
-
end
|
73
|
-
return true
|
74
|
-
end
|
75
|
-
|
76
|
-
#---
|
77
|
-
|
78
|
-
def reload(options = {})
|
79
|
-
if created?
|
80
|
-
|
81
|
-
end
|
82
|
-
return true
|
83
|
-
end
|
84
|
-
|
85
|
-
#---
|
86
|
-
|
87
|
-
def destroy(options = {})
|
88
|
-
if created?
|
89
|
-
|
90
|
-
end
|
91
|
-
return true
|
92
|
-
end
|
93
|
-
|
94
|
-
#---
|
95
|
-
|
96
|
-
def exec(options = {})
|
97
|
-
if running?
|
98
|
-
config = Config.ensure(options)
|
99
|
-
if commands = config.delete(:commands)
|
100
|
-
commands.each do |command|
|
101
|
-
Util::Shell.exec!(command, config) do |line|
|
102
|
-
yield(line) if block_given?
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
return true
|
108
|
-
end
|
109
|
-
|
110
|
-
#---
|
111
|
-
|
112
|
-
def provision(options = {})
|
113
|
-
if running?
|
114
|
-
config = Config.ensure(options)
|
115
|
-
|
116
|
-
# TODO: Abstract this out so it does not depend on Puppet functionality.
|
117
|
-
|
118
|
-
puppet = config.delete(:puppet, :puppet) # puppet (community) or puppetlabs (enterprise)
|
119
|
-
command = Coral.command({
|
120
|
-
:command => :puppet,
|
121
|
-
:flags => config.delete(:puppet_flags, ''),
|
122
|
-
:subcommand => {
|
123
|
-
:command => config.delete(:puppet_op, :apply),
|
124
|
-
:flags => config.delete(:puppet_op_flags, ''),
|
125
|
-
:data => config.delete(:puppet_op_data, {}).merge({
|
126
|
-
'modulepath=' => array(config.delete(:puppet_modules, "/etc/#{puppet}/modules")).join(':')
|
127
|
-
}),
|
128
|
-
:args => config.delete(:puppet_manifest, "/etc/#{puppet}/manifests/site.pp")
|
129
|
-
}
|
130
|
-
}, config.get(:provider, :shell))
|
131
|
-
|
132
|
-
config[:commands] = [ command.to_s ]
|
133
|
-
return exec(config)
|
134
|
-
end
|
135
|
-
return true
|
136
|
-
end
|
137
|
-
|
138
|
-
#---
|
139
|
-
|
140
|
-
def create_image(options = {})
|
141
|
-
if created?
|
142
|
-
|
143
|
-
end
|
144
|
-
return true
|
145
|
-
end
|
146
|
-
|
147
|
-
#-----------------------------------------------------------------------------
|
148
|
-
# Utilities
|
149
|
-
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Plugin
|
4
|
-
class Network < Base
|
5
|
-
|
6
|
-
ensure_plugin_collection
|
7
|
-
|
8
|
-
#-----------------------------------------------------------------------------
|
9
|
-
# Cloud plugin interface
|
10
|
-
|
11
|
-
def normalize
|
12
|
-
@config = Config::Project.new(self._export)
|
13
|
-
super
|
14
|
-
|
15
|
-
init_nodes
|
16
|
-
end
|
17
|
-
|
18
|
-
#-----------------------------------------------------------------------------
|
19
|
-
# Property accessors / modifiers
|
20
|
-
|
21
|
-
plugin_collection :node
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,184 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Plugin
|
4
|
-
class Node < Base
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Node plugin interface
|
8
|
-
|
9
|
-
def normalize
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
#-----------------------------------------------------------------------------
|
14
|
-
# Checks
|
15
|
-
|
16
|
-
|
17
|
-
#-----------------------------------------------------------------------------
|
18
|
-
# Property accessors / modifiers
|
19
|
-
|
20
|
-
def network
|
21
|
-
return plugin_parent
|
22
|
-
end
|
23
|
-
|
24
|
-
#---
|
25
|
-
|
26
|
-
def network=network
|
27
|
-
self.plugin_parent = network
|
28
|
-
end
|
29
|
-
|
30
|
-
#---
|
31
|
-
|
32
|
-
def setting(property, default = nil, format = false)
|
33
|
-
return network.node_setting(plugin_provider, name, property, default, format)
|
34
|
-
end
|
35
|
-
|
36
|
-
#---
|
37
|
-
|
38
|
-
def search(property, default = nil, format = false)
|
39
|
-
return network.search_node(plugin_provider, name, property, default, format)
|
40
|
-
end
|
41
|
-
|
42
|
-
#---
|
43
|
-
|
44
|
-
def set_setting(property, value = nil)
|
45
|
-
network.set_node_setting(plugin_provider, name, property, value)
|
46
|
-
return self
|
47
|
-
end
|
48
|
-
|
49
|
-
#---
|
50
|
-
|
51
|
-
def delete_setting(property)
|
52
|
-
network.delete_node_setting(plugin_provider, name, property)
|
53
|
-
return self
|
54
|
-
end
|
55
|
-
|
56
|
-
#-----------------------------------------------------------------------------
|
57
|
-
|
58
|
-
def machine
|
59
|
-
return get(:machine, nil)
|
60
|
-
end
|
61
|
-
|
62
|
-
#---
|
63
|
-
|
64
|
-
def machine=machine
|
65
|
-
set(:machine, machine)
|
66
|
-
end
|
67
|
-
|
68
|
-
#---
|
69
|
-
|
70
|
-
def create_machine(provider, options = {})
|
71
|
-
if provider.is_a?(String) || provider.is_a?(Symbol)
|
72
|
-
set(:machine, Coral.machine(options, provider))
|
73
|
-
end
|
74
|
-
return self
|
75
|
-
end
|
76
|
-
|
77
|
-
#---
|
78
|
-
|
79
|
-
def public_ip # Must be set at machine level
|
80
|
-
return machine.public_ip if machine
|
81
|
-
return nil
|
82
|
-
end
|
83
|
-
|
84
|
-
#---
|
85
|
-
|
86
|
-
def private_ip # Must be set at machine level
|
87
|
-
return machine.private_ip if machine
|
88
|
-
return nil
|
89
|
-
end
|
90
|
-
|
91
|
-
#---
|
92
|
-
|
93
|
-
def hostname # Must be set at machine level
|
94
|
-
return machine.hostname if machine
|
95
|
-
return ''
|
96
|
-
end
|
97
|
-
|
98
|
-
#---
|
99
|
-
|
100
|
-
def state # Must be set at machine level
|
101
|
-
return machine.state if machine
|
102
|
-
return nil
|
103
|
-
end
|
104
|
-
|
105
|
-
#-----------------------------------------------------------------------------
|
106
|
-
# Machine operations
|
107
|
-
|
108
|
-
def start(options = {})
|
109
|
-
return true unless machine
|
110
|
-
return machine.start(options)
|
111
|
-
end
|
112
|
-
|
113
|
-
#---
|
114
|
-
|
115
|
-
def stop(options = {})
|
116
|
-
return true unless machine && machine.running?
|
117
|
-
return machine.stop(options)
|
118
|
-
end
|
119
|
-
|
120
|
-
#---
|
121
|
-
|
122
|
-
def reload(options = {})
|
123
|
-
return true unless machine && machine.created?
|
124
|
-
return machine.reload(options)
|
125
|
-
end
|
126
|
-
|
127
|
-
#---
|
128
|
-
|
129
|
-
def destroy(options = {})
|
130
|
-
return true unless machine
|
131
|
-
|
132
|
-
config = Config.ensure(options)
|
133
|
-
|
134
|
-
if machine.created?
|
135
|
-
run = false
|
136
|
-
|
137
|
-
if config[:force]
|
138
|
-
run = true
|
139
|
-
else
|
140
|
-
choice = nil
|
141
|
-
begin
|
142
|
-
choice = ui.ask("Are you sure you want to remove: #{name}?")
|
143
|
-
run = choice.upcase == "Y"
|
144
|
-
rescue Errors::UIExpectsTTY
|
145
|
-
run = false
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
if run
|
150
|
-
return machine.destroy(config)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
return true
|
154
|
-
end
|
155
|
-
|
156
|
-
#---
|
157
|
-
|
158
|
-
def exec(commands, options = {})
|
159
|
-
return true unless machine && machine.running?
|
160
|
-
|
161
|
-
config = Config.ensure(options)
|
162
|
-
return machine.exec(config.import({ :commands => commands }))
|
163
|
-
end
|
164
|
-
|
165
|
-
#---
|
166
|
-
|
167
|
-
def provision(options = {})
|
168
|
-
return true unless machine && machine.running?
|
169
|
-
return machine.provision(options)
|
170
|
-
end
|
171
|
-
|
172
|
-
#---
|
173
|
-
|
174
|
-
def create_image(options = {})
|
175
|
-
return true unless machine && machine.running?
|
176
|
-
return machine.create_image(options)
|
177
|
-
end
|
178
|
-
|
179
|
-
#-----------------------------------------------------------------------------
|
180
|
-
# Utilities
|
181
|
-
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|