coral_core 0.2.30 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,277 +0,0 @@
|
|
1
|
-
|
2
|
-
# Should be included via extend
|
3
|
-
#
|
4
|
-
# extend Mixin::Macro::PluginInterface
|
5
|
-
#
|
6
|
-
|
7
|
-
coral_require(File.dirname(__FILE__), :object_interface)
|
8
|
-
|
9
|
-
#---
|
10
|
-
|
11
|
-
module Coral
|
12
|
-
module Mixin
|
13
|
-
module Macro
|
14
|
-
module PluginInterface
|
15
|
-
|
16
|
-
include Mixin::Macro::ObjectInterface
|
17
|
-
|
18
|
-
#-----------------------------------------------------------------------------
|
19
|
-
# Plugin collections
|
20
|
-
|
21
|
-
def plugin_collection(_type, _method_options = {})
|
22
|
-
_method_config = Config.ensure(_method_options)
|
23
|
-
_method_config.set(:plugin, true)
|
24
|
-
|
25
|
-
_plural = _method_config.init(:plural, "#{_type}s").get(:plural)
|
26
|
-
_search_proc = _method_config.get(:search_proc)
|
27
|
-
_single_instance = _method_config.get(:single_instance, false)
|
28
|
-
_plugin_type = _method_config.get(:plugin_type, _type)
|
29
|
-
|
30
|
-
@@object_types[_type] = _method_config
|
31
|
-
|
32
|
-
#---------------------------------------------------------------------------
|
33
|
-
|
34
|
-
object_utilities
|
35
|
-
|
36
|
-
#---
|
37
|
-
|
38
|
-
unless respond_to? :each_plugin!
|
39
|
-
define_method :each_plugin! do |plugin_types = nil, providers = nil|
|
40
|
-
providers = [ providers ] if providers && ! providers.is_a?(Array)
|
41
|
-
|
42
|
-
filter_proc = Proc.new {|type, config| config[:plugin] }
|
43
|
-
each_object_type!(plugin_types, filter_proc) do |type, plural, options|
|
44
|
-
send(plural).each do |provider, plugins|
|
45
|
-
unless providers && ! providers.include?(provider)
|
46
|
-
if plugins.is_a?(Hash)
|
47
|
-
plugins.each do |name, plugin|
|
48
|
-
yield(type, provider, plugin)
|
49
|
-
end
|
50
|
-
else
|
51
|
-
yield(type, provider, plugin)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
#---
|
60
|
-
|
61
|
-
define_method "each_#{_type}!" do |providers = nil|
|
62
|
-
each_plugin!(_type, providers) do |type, provider, plugin|
|
63
|
-
yield(type, provider, plugin)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
#---------------------------------------------------------------------------
|
68
|
-
|
69
|
-
if _single_instance
|
70
|
-
define_method "#{_type}_config" do |provider|
|
71
|
-
Config.new(get([ _type, provider ], {}))
|
72
|
-
end
|
73
|
-
|
74
|
-
#---
|
75
|
-
|
76
|
-
define_method "#{_type}_setting" do |provider, property, default = nil, format = false|
|
77
|
-
get([ _type, provider, property ], default, format)
|
78
|
-
end
|
79
|
-
|
80
|
-
#---------------------------------------------------------------------------
|
81
|
-
else
|
82
|
-
define_method "#{_type}_config" do |provider, name = nil|
|
83
|
-
Config.new( name ? get([ _plural, provider, name ], {}) : get(_plural, provider, {}) )
|
84
|
-
end
|
85
|
-
|
86
|
-
#---
|
87
|
-
|
88
|
-
define_method "#{_type}_setting" do |provider, name, property, default = nil, format = false|
|
89
|
-
get([ _plural, provider, name, property ], default, format)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
#---------------------------------------------------------------------------
|
94
|
-
|
95
|
-
define_method "#{_plural}" do |provider = nil|
|
96
|
-
( provider ? _get([ _plural, provider ], {}) : _get(_plural, {}) )
|
97
|
-
end
|
98
|
-
|
99
|
-
#---
|
100
|
-
|
101
|
-
define_method "init_#{_plural}" do |providers = nil|
|
102
|
-
data = hash(_search_proc.call) if _search_proc
|
103
|
-
data = get_hash(_plural) unless data
|
104
|
-
|
105
|
-
providers = [ providers ] if providers && ! providers.is_a?(Array)
|
106
|
-
|
107
|
-
symbol_map(data).each do |provider, instance_settings|
|
108
|
-
if ! providers || providers.include?(provider)
|
109
|
-
if _single_instance
|
110
|
-
plugin = Coral.plugin(_plugin_type, provider, instance_settings)
|
111
|
-
plugin.plugin_parent = self
|
112
|
-
|
113
|
-
_set([ _plural, provider ], plugin)
|
114
|
-
else
|
115
|
-
instance_settings.each do |name, options|
|
116
|
-
if name != :settings
|
117
|
-
options[:name] = name
|
118
|
-
plugin = Coral.plugin(_plugin_type, provider, options)
|
119
|
-
plugin.plugin_parent = self
|
120
|
-
|
121
|
-
_set([ _plural, provider, name ], plugin)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
#---
|
130
|
-
|
131
|
-
define_method "set_#{_plural}" do |data = {}|
|
132
|
-
data = Config.ensure(data).export
|
133
|
-
|
134
|
-
send("clear_#{_plural}")
|
135
|
-
set(_plural, data)
|
136
|
-
|
137
|
-
data.each do |provider, instance_settings|
|
138
|
-
if _single_instance
|
139
|
-
plugin = Coral.plugin(_plugin_type, provider, instance_settings)
|
140
|
-
plugin.plugin_parent = self
|
141
|
-
|
142
|
-
_set([ _plural, provider ], plugin)
|
143
|
-
else
|
144
|
-
instance_settings.each do |name, options|
|
145
|
-
options[:name] = name
|
146
|
-
plugin = Coral.plugin(_plugin_type, provider, options)
|
147
|
-
plugin.plugin_parent = self
|
148
|
-
|
149
|
-
_set([ _plural, provider, name ], plugin)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
self
|
154
|
-
end
|
155
|
-
|
156
|
-
#---
|
157
|
-
|
158
|
-
define_method "clear_#{_plural}" do
|
159
|
-
_get(_plural).keys.each do |name|
|
160
|
-
send("delete_#{_type}", name)
|
161
|
-
end
|
162
|
-
self
|
163
|
-
end
|
164
|
-
|
165
|
-
#---------------------------------------------------------------------------
|
166
|
-
|
167
|
-
if _single_instance
|
168
|
-
define_method "#{_type}" do |provider|
|
169
|
-
_get([ _plural, provider ])
|
170
|
-
end
|
171
|
-
|
172
|
-
#---
|
173
|
-
|
174
|
-
define_method "set_#{_type}" do |provider, options = {}|
|
175
|
-
options = Config.ensure(options).export
|
176
|
-
|
177
|
-
set([ _plural, provider ], options)
|
178
|
-
|
179
|
-
plugin = Coral.plugin(_plugin_type, provider, options)
|
180
|
-
plugin.plugin_parent = self
|
181
|
-
|
182
|
-
_set([ _plural, provider ], plugin)
|
183
|
-
self
|
184
|
-
end
|
185
|
-
|
186
|
-
#---
|
187
|
-
|
188
|
-
define_method "set_#{_type}_setting" do |provider, property, value = nil|
|
189
|
-
set([ _plural, provider, property ], value)
|
190
|
-
self
|
191
|
-
end
|
192
|
-
|
193
|
-
#---
|
194
|
-
|
195
|
-
define_method "delete_#{_type}" do |provider|
|
196
|
-
plugin = send(_type, provider)
|
197
|
-
|
198
|
-
delete([ _plural, provider ])
|
199
|
-
_delete([ _plural, provider ])
|
200
|
-
|
201
|
-
Coral.remove_plugin(plugin)
|
202
|
-
self
|
203
|
-
end
|
204
|
-
|
205
|
-
#---
|
206
|
-
|
207
|
-
define_method "delete_#{_type}_setting" do |provider, property|
|
208
|
-
delete([ _plural, provider, property ])
|
209
|
-
self
|
210
|
-
end
|
211
|
-
|
212
|
-
#---
|
213
|
-
|
214
|
-
define_method "search_#{_type}" do |provider, keys, default = '', format = false|
|
215
|
-
plugin_config = send("#{_type}_config", provider)
|
216
|
-
search_object(plugin_config, keys, default, format)
|
217
|
-
end
|
218
|
-
|
219
|
-
#---------------------------------------------------------------------------
|
220
|
-
else
|
221
|
-
define_method "#{_type}" do |provider, name|
|
222
|
-
_get([ _plural, provider, name ])
|
223
|
-
end
|
224
|
-
|
225
|
-
#---
|
226
|
-
|
227
|
-
define_method "set_#{_type}" do |provider, name, options = {}|
|
228
|
-
options = Config.ensure(options).export
|
229
|
-
|
230
|
-
set([ _plural, provider, name ], options)
|
231
|
-
|
232
|
-
options[:name] = name
|
233
|
-
plugin = Coral.plugin(_plugin_type, provider, options)
|
234
|
-
plugin.plugin_parent = self
|
235
|
-
|
236
|
-
_set([ _plural, provider, name ], plugin)
|
237
|
-
self
|
238
|
-
end
|
239
|
-
|
240
|
-
#---
|
241
|
-
|
242
|
-
define_method "set_#{_type}_setting" do |provider, name, property, value = nil|
|
243
|
-
set([ _plural, provider, name, property ], value)
|
244
|
-
self
|
245
|
-
end
|
246
|
-
|
247
|
-
#---
|
248
|
-
|
249
|
-
define_method "delete_#{_type}" do |provider, name|
|
250
|
-
plugin = send(_type, provider, name)
|
251
|
-
|
252
|
-
delete([ _plural, provider, name ])
|
253
|
-
_delete([ _plural, provider, name ])
|
254
|
-
|
255
|
-
Coral.remove_plugin(plugin)
|
256
|
-
self
|
257
|
-
end
|
258
|
-
|
259
|
-
#---
|
260
|
-
|
261
|
-
define_method "delete_#{_type}_setting" do |provider, name, property|
|
262
|
-
delete([ _plural, provider, name, property ])
|
263
|
-
self
|
264
|
-
end
|
265
|
-
|
266
|
-
#---
|
267
|
-
|
268
|
-
define_method "search_#{_type}" do |provider, name, keys, default = '', format = false|
|
269
|
-
plugin_config = send("#{_type}_config", provider, name)
|
270
|
-
search_object(plugin_config, keys, default, format)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
|
2
|
-
# Should be included via include
|
3
|
-
#
|
4
|
-
# include Mixin::Settings
|
5
|
-
#
|
6
|
-
|
7
|
-
module Coral
|
8
|
-
module Mixin
|
9
|
-
module Settings
|
10
|
-
|
11
|
-
def settings(name)
|
12
|
-
return get_hash([ :settings, name ])
|
13
|
-
end
|
14
|
-
|
15
|
-
#---
|
16
|
-
|
17
|
-
def set_settings(name, settings = {})
|
18
|
-
return set([ :settings, name ], settings)
|
19
|
-
end
|
20
|
-
|
21
|
-
#---
|
22
|
-
|
23
|
-
def delete_settings(name)
|
24
|
-
return delete([ :settings, name ])
|
25
|
-
end
|
26
|
-
|
27
|
-
#---
|
28
|
-
|
29
|
-
def setting(name, key, default = '', format = false)
|
30
|
-
return get([ :settings, name, key ], default, format)
|
31
|
-
end
|
32
|
-
|
33
|
-
#---
|
34
|
-
|
35
|
-
def set_setting(name, key, value = '')
|
36
|
-
return set([ :settings, name, key ], value)
|
37
|
-
end
|
38
|
-
|
39
|
-
#---
|
40
|
-
|
41
|
-
def delete_setting(name, key)
|
42
|
-
return delete([ :settings, name, key ])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,208 +0,0 @@
|
|
1
|
-
|
2
|
-
# Should be included via include
|
3
|
-
#
|
4
|
-
# include Mixin::SubConfig
|
5
|
-
#
|
6
|
-
|
7
|
-
module Coral
|
8
|
-
module Mixin
|
9
|
-
module SubConfig
|
10
|
-
|
11
|
-
#-----------------------------------------------------------------------------
|
12
|
-
# Initialization
|
13
|
-
|
14
|
-
def init_subconfig(reset = false)
|
15
|
-
return if @subconfig_initialized && ! reset
|
16
|
-
|
17
|
-
unless @config
|
18
|
-
@config = Config.new
|
19
|
-
end
|
20
|
-
|
21
|
-
@subconfig_initialized = true
|
22
|
-
end
|
23
|
-
protected :init_subconfig
|
24
|
-
|
25
|
-
#-----------------------------------------------------------------------------
|
26
|
-
# Propety accessors / modifiers
|
27
|
-
|
28
|
-
def name
|
29
|
-
return _get(:name)
|
30
|
-
end
|
31
|
-
|
32
|
-
#---
|
33
|
-
|
34
|
-
def name=name
|
35
|
-
_set(:name, string(name))
|
36
|
-
end
|
37
|
-
|
38
|
-
#---
|
39
|
-
|
40
|
-
def config
|
41
|
-
return @config
|
42
|
-
end
|
43
|
-
|
44
|
-
#---
|
45
|
-
|
46
|
-
def config=config
|
47
|
-
@config = config
|
48
|
-
end
|
49
|
-
|
50
|
-
#---
|
51
|
-
|
52
|
-
def directory
|
53
|
-
init_subconfig
|
54
|
-
|
55
|
-
if config.is_a?(Config::Project)
|
56
|
-
return config.project.directory
|
57
|
-
else
|
58
|
-
return nil
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
#---
|
63
|
-
|
64
|
-
def directory=directory
|
65
|
-
init_subconfig
|
66
|
-
|
67
|
-
if config.is_a?(Config::Project)
|
68
|
-
config.set_location(directory)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
#-----------------------------------------------------------------------------
|
73
|
-
|
74
|
-
def _get(keys, default = nil, format = false)
|
75
|
-
return fetch(@properties, array(keys).flatten, default, format)
|
76
|
-
end
|
77
|
-
protected :_get
|
78
|
-
|
79
|
-
#---
|
80
|
-
|
81
|
-
def get(keys, default = nil, format = false)
|
82
|
-
init_subconfig
|
83
|
-
return config.get(keys, default, format)
|
84
|
-
end
|
85
|
-
|
86
|
-
#---
|
87
|
-
|
88
|
-
def _init(keys, default = nil)
|
89
|
-
return _set(keys, _get(keys, default))
|
90
|
-
end
|
91
|
-
protected :_init
|
92
|
-
|
93
|
-
#---
|
94
|
-
|
95
|
-
def _set(keys, value = '')
|
96
|
-
modify(@properties, array(keys).flatten, value)
|
97
|
-
return self
|
98
|
-
end
|
99
|
-
protected :_set
|
100
|
-
|
101
|
-
#---
|
102
|
-
|
103
|
-
def set(keys, value = '')
|
104
|
-
init_subconfig
|
105
|
-
config.set(keys, value)
|
106
|
-
return self
|
107
|
-
end
|
108
|
-
|
109
|
-
#---
|
110
|
-
|
111
|
-
def _delete(keys, default = nil)
|
112
|
-
existing = modify(@properties, array(keys).flatten, nil)
|
113
|
-
return existing[:value] if existing[:value]
|
114
|
-
return default
|
115
|
-
end
|
116
|
-
protected :_delete
|
117
|
-
|
118
|
-
#---
|
119
|
-
|
120
|
-
def delete(keys, default = nil)
|
121
|
-
init_subconfig
|
122
|
-
config.delete(keys, default)
|
123
|
-
return self
|
124
|
-
end
|
125
|
-
|
126
|
-
#---
|
127
|
-
|
128
|
-
def _clear
|
129
|
-
@properties = {}
|
130
|
-
return self
|
131
|
-
end
|
132
|
-
protected :_clear
|
133
|
-
|
134
|
-
#---
|
135
|
-
|
136
|
-
def clear
|
137
|
-
init_subconfig
|
138
|
-
config.clear
|
139
|
-
return self
|
140
|
-
end
|
141
|
-
|
142
|
-
#-----------------------------------------------------------------------------
|
143
|
-
# Import / Export
|
144
|
-
|
145
|
-
def _import(properties, options = {})
|
146
|
-
return import_base(properties, options)
|
147
|
-
end
|
148
|
-
protected :_import
|
149
|
-
|
150
|
-
#---
|
151
|
-
|
152
|
-
def import(properties, options = {})
|
153
|
-
init_subconfig
|
154
|
-
config.import(properties, options)
|
155
|
-
return self
|
156
|
-
end
|
157
|
-
|
158
|
-
#---
|
159
|
-
|
160
|
-
def _defaults(defaults, options = {})
|
161
|
-
config = new(options).set(:import_type, :default)
|
162
|
-
return import_base(defaults, config)
|
163
|
-
end
|
164
|
-
protected :_defaults
|
165
|
-
|
166
|
-
#---
|
167
|
-
|
168
|
-
def defaults(defaults, options = {})
|
169
|
-
init_subconfig
|
170
|
-
config.defaults(defaults, options)
|
171
|
-
return self
|
172
|
-
end
|
173
|
-
|
174
|
-
#---
|
175
|
-
|
176
|
-
def _export
|
177
|
-
return @properties
|
178
|
-
end
|
179
|
-
protected :_export
|
180
|
-
|
181
|
-
#---
|
182
|
-
|
183
|
-
def export
|
184
|
-
init_subconfig
|
185
|
-
return config.export
|
186
|
-
end
|
187
|
-
|
188
|
-
#-----------------------------------------------------------------------------
|
189
|
-
# Configuration loading saving
|
190
|
-
|
191
|
-
def load(options = {})
|
192
|
-
if config.respond_to?(:load)
|
193
|
-
config.load(options)
|
194
|
-
end
|
195
|
-
return self
|
196
|
-
end
|
197
|
-
|
198
|
-
#---
|
199
|
-
|
200
|
-
def save(options = {})
|
201
|
-
if config.respond_to?(:save)
|
202
|
-
config.save(options)
|
203
|
-
end
|
204
|
-
return self
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|