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/core.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
class Core < Config
|
4
|
-
|
5
|
-
#-----------------------------------------------------------------------------
|
6
|
-
# Properties
|
7
|
-
|
8
|
-
@@ui = Util::Interface.new("coral")
|
9
|
-
|
10
|
-
#-----------------------------------------------------------------------------
|
11
|
-
# Constructor / Destructor
|
12
|
-
|
13
|
-
def initialize(data = {}, defaults = {}, force = true)
|
14
|
-
super(data, defaults, force)
|
15
|
-
|
16
|
-
@ui = Util::Interface.new(export)
|
17
|
-
end
|
18
|
-
|
19
|
-
#---
|
20
|
-
|
21
|
-
def inspect
|
22
|
-
"#<#{self.class}: >"
|
23
|
-
end
|
24
|
-
|
25
|
-
#-----------------------------------------------------------------------------
|
26
|
-
# Accessor / Modifiers
|
27
|
-
|
28
|
-
attr_accessor :ui
|
29
|
-
|
30
|
-
#---
|
31
|
-
|
32
|
-
def self.ui
|
33
|
-
return @@ui
|
34
|
-
end
|
35
|
-
|
36
|
-
#---
|
37
|
-
|
38
|
-
def self.logger
|
39
|
-
return @@ui.logger
|
40
|
-
end
|
41
|
-
|
42
|
-
#---
|
43
|
-
|
44
|
-
def self.logger=logger
|
45
|
-
self.class.logger = logger
|
46
|
-
end
|
47
|
-
|
48
|
-
#---
|
49
|
-
|
50
|
-
def logger
|
51
|
-
return self.class.logger
|
52
|
-
end
|
53
|
-
|
54
|
-
#-----------------------------------------------------------------------------
|
55
|
-
# General utilities
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module Coral
|
2
|
-
class PuppetEvent < Event
|
3
|
-
|
4
|
-
#-----------------------------------------------------------------------------
|
5
|
-
# Properties
|
6
|
-
|
7
|
-
TYPE = :puppet
|
8
|
-
|
9
|
-
#-----------------------------------------------------------------------------
|
10
|
-
# Constructor / Destructor
|
11
|
-
|
12
|
-
def initialize(options = {})
|
13
|
-
options[:type] = TYPE
|
14
|
-
|
15
|
-
super(options)
|
16
|
-
|
17
|
-
if options.has_key?(:string)
|
18
|
-
items = options[:string].split(':')
|
19
|
-
self.element = items[0]
|
20
|
-
self.operation = items[1]
|
21
|
-
self.message = items[2]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
#-----------------------------------------------------------------------------
|
26
|
-
# Property accessors / modifiers
|
27
|
-
|
28
|
-
def element
|
29
|
-
return property(:element, '', :string)
|
30
|
-
end
|
31
|
-
|
32
|
-
#---
|
33
|
-
|
34
|
-
def element=element
|
35
|
-
set_property(:element, string(element))
|
36
|
-
end
|
37
|
-
|
38
|
-
#---
|
39
|
-
|
40
|
-
def operation
|
41
|
-
return property(:operation, '', :string)
|
42
|
-
end
|
43
|
-
|
44
|
-
#---
|
45
|
-
|
46
|
-
def operation=operation
|
47
|
-
set_property(:operation, string(operation))
|
48
|
-
end
|
49
|
-
|
50
|
-
#--
|
51
|
-
|
52
|
-
def message
|
53
|
-
return property(:message, '', :string)
|
54
|
-
end
|
55
|
-
|
56
|
-
#---
|
57
|
-
|
58
|
-
def message=message
|
59
|
-
set_property(:message, string(message))
|
60
|
-
end
|
61
|
-
|
62
|
-
#-----------------------------------------------------------------------------
|
63
|
-
# Import / Export
|
64
|
-
|
65
|
-
def export
|
66
|
-
return "#{type}:#{element}:#{operation}:#{message}"
|
67
|
-
end
|
68
|
-
|
69
|
-
#-----------------------------------------------------------------------------
|
70
|
-
# Event handling
|
71
|
-
|
72
|
-
def check(source)
|
73
|
-
if source.match(/notice:\s+(.+?):\s+(.+)\s*/i)
|
74
|
-
source_element = $1
|
75
|
-
source_operation = ''
|
76
|
-
source_message = $2
|
77
|
-
|
78
|
-
source_elements = source_element.split('/')
|
79
|
-
source_operation = source_elements.pop.strip unless source_elements.last.match(/[\[\]]/)
|
80
|
-
|
81
|
-
if source_operation
|
82
|
-
source_element = source_elements.join('/').strip
|
83
|
-
|
84
|
-
logger.debug("#{source_element} includes: #{element} -- " + ( source_element.include?(element) ? 'true' : 'false' ))
|
85
|
-
logger.debug("#{source_operation} is: #{operation} -- " + ( source_operation == operation ? 'true' : 'false' ))
|
86
|
-
logger.debug("#{source_message} includes: #{message} -- " + ( source_message.include?(message) ? 'true' : 'false' ))
|
87
|
-
|
88
|
-
if source_element.include?(element) && source_operation == operation && source_message.include?(message)
|
89
|
-
logger.debug("MATCH! -> #{element} - #{operation} - #{message}")
|
90
|
-
return true
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
logger.debug("nothing -> #{element} - #{operation} - #{message}")
|
95
|
-
return false
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
class RegexpEvent < Event
|
4
|
-
|
5
|
-
#-----------------------------------------------------------------------------
|
6
|
-
# Properties
|
7
|
-
|
8
|
-
TYPE = :regexp
|
9
|
-
|
10
|
-
#-----------------------------------------------------------------------------
|
11
|
-
# Constructor / Destructor
|
12
|
-
|
13
|
-
def initialize(options = {})
|
14
|
-
options[:type] = TYPE
|
15
|
-
|
16
|
-
super(options)
|
17
|
-
|
18
|
-
if options.has_key?(:string)
|
19
|
-
self.pattern = options[:string]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
#-----------------------------------------------------------------------------
|
24
|
-
# Property accessors / modifiers
|
25
|
-
|
26
|
-
def pattern
|
27
|
-
return property(:pattern, '', :string)
|
28
|
-
end
|
29
|
-
|
30
|
-
#---
|
31
|
-
|
32
|
-
def pattern=pattern
|
33
|
-
set_property(:pattern, string(pattern))
|
34
|
-
end
|
35
|
-
|
36
|
-
#-----------------------------------------------------------------------------
|
37
|
-
# Import / Export
|
38
|
-
|
39
|
-
def export
|
40
|
-
return "#{type}:#{pattern}"
|
41
|
-
end
|
42
|
-
|
43
|
-
#-----------------------------------------------------------------------------
|
44
|
-
# Event handling
|
45
|
-
|
46
|
-
def check(source)
|
47
|
-
if source.match(/#{pattern}/)
|
48
|
-
logger.debug("MATCH! -> #{pattern} matched #{source}")
|
49
|
-
return true
|
50
|
-
end
|
51
|
-
logger.debug("nothing -> #{pattern} - #{source}")
|
52
|
-
return false
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/coral_core/event.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
class Event < Core
|
4
|
-
|
5
|
-
#-----------------------------------------------------------------------------
|
6
|
-
# Constructor / Destructor
|
7
|
-
|
8
|
-
def self.instance!(data = {}, build_hash = false, keep_array = false)
|
9
|
-
group = ( build_hash ? {} : [] )
|
10
|
-
events = build_info(data)
|
11
|
-
|
12
|
-
index = 1
|
13
|
-
events.each do |info|
|
14
|
-
type = info[:type]
|
15
|
-
|
16
|
-
if type && ! type.empty?
|
17
|
-
event = ( block_given? ? yield(type, info) : create(type, info) )
|
18
|
-
|
19
|
-
if event
|
20
|
-
if build_hash
|
21
|
-
group[index] = event
|
22
|
-
else
|
23
|
-
group << event
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
index += 1
|
28
|
-
end
|
29
|
-
if ! build_hash && events.length == 1 && ! keep_array
|
30
|
-
return group.shift
|
31
|
-
end
|
32
|
-
return group
|
33
|
-
end
|
34
|
-
|
35
|
-
#---
|
36
|
-
|
37
|
-
def self.instance(options = {}, build_hash = false, keep_array = false)
|
38
|
-
return instance!(options, build_hash, keep_array)
|
39
|
-
end
|
40
|
-
|
41
|
-
#---
|
42
|
-
|
43
|
-
def initialize(options = {})
|
44
|
-
config = Config.ensure(options)
|
45
|
-
|
46
|
-
super(config)
|
47
|
-
|
48
|
-
@name = config.get(:name, '')
|
49
|
-
@delegate = config.get(:delegate, nil)
|
50
|
-
@properties = config.options
|
51
|
-
end
|
52
|
-
|
53
|
-
#-----------------------------------------------------------------------------
|
54
|
-
# Property accessors / modifiers
|
55
|
-
|
56
|
-
attr_accessor :name
|
57
|
-
|
58
|
-
#---
|
59
|
-
|
60
|
-
def type
|
61
|
-
return string(@properties[:type])
|
62
|
-
end
|
63
|
-
|
64
|
-
#---
|
65
|
-
|
66
|
-
def set_properties(data)
|
67
|
-
return @delegate.set_properties(data) if @delegate
|
68
|
-
|
69
|
-
@properties = hash(data)
|
70
|
-
return self
|
71
|
-
end
|
72
|
-
|
73
|
-
#---
|
74
|
-
|
75
|
-
def property(name, default = '', format = false)
|
76
|
-
name = name.to_sym
|
77
|
-
|
78
|
-
property = default
|
79
|
-
property = filter(@properties[name], format) if @properties.has_key?(name)
|
80
|
-
return property
|
81
|
-
end
|
82
|
-
|
83
|
-
#---
|
84
|
-
|
85
|
-
def set_property(name, value)
|
86
|
-
return @delegate.set_property(name, value) if @delegate
|
87
|
-
|
88
|
-
@properties[name] = value
|
89
|
-
return self
|
90
|
-
end
|
91
|
-
|
92
|
-
#-----------------------------------------------------------------------------
|
93
|
-
# Import / Export
|
94
|
-
|
95
|
-
def export
|
96
|
-
return type
|
97
|
-
end
|
98
|
-
|
99
|
-
#-----------------------------------------------------------------------------
|
100
|
-
# Event handling
|
101
|
-
|
102
|
-
def check(source)
|
103
|
-
return false
|
104
|
-
end
|
105
|
-
|
106
|
-
#-----------------------------------------------------------------------------
|
107
|
-
# Utilities
|
108
|
-
|
109
|
-
def self.build_info!(data = {})
|
110
|
-
events = []
|
111
|
-
|
112
|
-
if data.is_a?(String)
|
113
|
-
data = data.split(/\s*,\s*/)
|
114
|
-
elsif data.is_a?(Hash)
|
115
|
-
data = [ data ]
|
116
|
-
end
|
117
|
-
|
118
|
-
if data.is_a?(Array)
|
119
|
-
data.each do |element|
|
120
|
-
event = {}
|
121
|
-
|
122
|
-
if block_given?
|
123
|
-
event = yield(element)
|
124
|
-
else
|
125
|
-
case element
|
126
|
-
when String
|
127
|
-
event = split_event_string(element)
|
128
|
-
|
129
|
-
when Hash
|
130
|
-
event = element
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
unless event.empty?
|
135
|
-
events << event
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
return events
|
140
|
-
end
|
141
|
-
|
142
|
-
#---
|
143
|
-
|
144
|
-
def self.build_info(data = {})
|
145
|
-
return build_info!(data)
|
146
|
-
end
|
147
|
-
|
148
|
-
#-----------------------------------------------------------------------------
|
149
|
-
|
150
|
-
def self.create(type, info)
|
151
|
-
event = nil
|
152
|
-
begin
|
153
|
-
event = Module.const_get("Coral").const_get("#{type.capitalize}Event").new(info)
|
154
|
-
rescue
|
155
|
-
end
|
156
|
-
return event
|
157
|
-
end
|
158
|
-
|
159
|
-
#-----------------------------------------------------------------------------
|
160
|
-
|
161
|
-
def self.split_event_string(data)
|
162
|
-
info = {}
|
163
|
-
components = data.split(':')
|
164
|
-
info[:type] = components.shift
|
165
|
-
info[:string] = components.join(':')
|
166
|
-
|
167
|
-
return info
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
|
2
|
-
# Should be included via extend
|
3
|
-
#
|
4
|
-
# extend Mixin::ConfigCollection
|
5
|
-
#
|
6
|
-
|
7
|
-
module Coral
|
8
|
-
module Mixin
|
9
|
-
module ConfigCollection
|
10
|
-
#-----------------------------------------------------------------------------
|
11
|
-
# Configuration collection interface
|
12
|
-
|
13
|
-
def all_properties
|
14
|
-
return Config::Collection.all
|
15
|
-
end
|
16
|
-
|
17
|
-
#---
|
18
|
-
|
19
|
-
def get_property(name)
|
20
|
-
return Config::Collection.get(name)
|
21
|
-
end
|
22
|
-
|
23
|
-
#---
|
24
|
-
|
25
|
-
def set_property(name, value)
|
26
|
-
Config::Collection.set(name, value)
|
27
|
-
return self
|
28
|
-
end
|
29
|
-
|
30
|
-
#---
|
31
|
-
|
32
|
-
def delete_property(name)
|
33
|
-
Config::Collection.delete(name)
|
34
|
-
return self
|
35
|
-
end
|
36
|
-
|
37
|
-
#---
|
38
|
-
|
39
|
-
def clear_properties
|
40
|
-
Config::Collection.clear
|
41
|
-
return self
|
42
|
-
end
|
43
|
-
|
44
|
-
#---
|
45
|
-
|
46
|
-
def save_properties
|
47
|
-
Config::Collection.save
|
48
|
-
return self
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
|
2
|
-
# Should be included via extend
|
3
|
-
#
|
4
|
-
# extend Mixin::ConfigOps
|
5
|
-
#
|
6
|
-
|
7
|
-
module Coral
|
8
|
-
module Mixin
|
9
|
-
module ConfigOps
|
10
|
-
#-----------------------------------------------------------------------------
|
11
|
-
# Parsing
|
12
|
-
|
13
|
-
def parse(statement, options = {})
|
14
|
-
config = Config.ensure(options)
|
15
|
-
|
16
|
-
# statement = 'common->php::apache::memory_limit = 32M'
|
17
|
-
# statement = 'identity -> test -> users::user[admin][shell]'
|
18
|
-
# statement = 'servers->development->dev.loc->facts[server_environment]=vagrant'
|
19
|
-
# statement = 'cloud->settings[debug][puppet][options] = ["--debug"]'
|
20
|
-
|
21
|
-
reference, new_value = statement.split(/\=/)
|
22
|
-
new_value = new_value.join('=').strip if new_value && new_value.is_a?(Array)
|
23
|
-
|
24
|
-
config_elements = reference.gsub(/\s+/, '').split(/\-\>/)
|
25
|
-
property = config_elements.pop
|
26
|
-
config_file = config_elements.pop
|
27
|
-
|
28
|
-
if config_directory = config.get(:directory, nil)
|
29
|
-
config_path = File.join(repo.directory, config_directory, *config_elements)
|
30
|
-
else
|
31
|
-
config_path = File.join(repo.directory, *config_elements)
|
32
|
-
end
|
33
|
-
|
34
|
-
return nil unless property && config_file
|
35
|
-
|
36
|
-
config_file = "#{config_file}." + config.get(:ext, 'json')
|
37
|
-
property = property.gsub(/\]$/, '').split(/\]?\[/)
|
38
|
-
data = open(config_path, config_file, config)
|
39
|
-
|
40
|
-
return {
|
41
|
-
:path => config_path,
|
42
|
-
:file => config_file,
|
43
|
-
:property => property,
|
44
|
-
:conf => data,
|
45
|
-
:current_value => (data ? data.get(property) : nil),
|
46
|
-
:new_value => eval(new_value)
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|