corl 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.document +5 -0
  2. data/.gitmodules +4 -0
  3. data/Gemfile +24 -0
  4. data/Gemfile.lock +123 -0
  5. data/LICENSE.txt +674 -0
  6. data/README.rdoc +27 -0
  7. data/Rakefile +78 -0
  8. data/VERSION +1 -0
  9. data/bin/corl +55 -0
  10. data/corl.gemspec +228 -0
  11. data/lib/corl/action/add.rb +69 -0
  12. data/lib/corl/action/bootstrap.rb +83 -0
  13. data/lib/corl/action/clone.rb +40 -0
  14. data/lib/corl/action/create.rb +55 -0
  15. data/lib/corl/action/exec.rb +41 -0
  16. data/lib/corl/action/extract.rb +49 -0
  17. data/lib/corl/action/image.rb +30 -0
  18. data/lib/corl/action/images.rb +55 -0
  19. data/lib/corl/action/lookup.rb +35 -0
  20. data/lib/corl/action/machines.rb +51 -0
  21. data/lib/corl/action/provision.rb +37 -0
  22. data/lib/corl/action/remove.rb +51 -0
  23. data/lib/corl/action/save.rb +53 -0
  24. data/lib/corl/action/seed.rb +115 -0
  25. data/lib/corl/action/spawn.rb +75 -0
  26. data/lib/corl/action/start.rb +37 -0
  27. data/lib/corl/action/stop.rb +30 -0
  28. data/lib/corl/action/update.rb +37 -0
  29. data/lib/corl/command/shell.rb +164 -0
  30. data/lib/corl/configuration/file.rb +386 -0
  31. data/lib/corl/event/puppet.rb +90 -0
  32. data/lib/corl/event/regex.rb +52 -0
  33. data/lib/corl/extension/puppetloader.rb +24 -0
  34. data/lib/corl/machine/fog.rb +310 -0
  35. data/lib/corl/machine/physical.rb +161 -0
  36. data/lib/corl/network/default.rb +26 -0
  37. data/lib/corl/node/aws.rb +90 -0
  38. data/lib/corl/node/fog.rb +198 -0
  39. data/lib/corl/node/google.rb +115 -0
  40. data/lib/corl/node/local.rb +26 -0
  41. data/lib/corl/node/rackspace.rb +89 -0
  42. data/lib/corl/project/git.rb +465 -0
  43. data/lib/corl/project/github.rb +108 -0
  44. data/lib/corl/provisioner/puppetnode/resource.rb +245 -0
  45. data/lib/corl/provisioner/puppetnode/resource_group.rb +205 -0
  46. data/lib/corl/provisioner/puppetnode.rb +407 -0
  47. data/lib/corl/template/environment.rb +73 -0
  48. data/lib/corl/template/json.rb +16 -0
  49. data/lib/corl/template/wrapper.rb +16 -0
  50. data/lib/corl/template/yaml.rb +16 -0
  51. data/lib/corl/translator/json.rb +27 -0
  52. data/lib/corl/translator/yaml.rb +27 -0
  53. data/lib/corl.rb +173 -0
  54. data/lib/corl_core/codes.rb +107 -0
  55. data/lib/corl_core/config/collection.rb +57 -0
  56. data/lib/corl_core/config/options.rb +70 -0
  57. data/lib/corl_core/config.rb +337 -0
  58. data/lib/corl_core/core.rb +59 -0
  59. data/lib/corl_core/corl.rb +254 -0
  60. data/lib/corl_core/errors.rb +84 -0
  61. data/lib/corl_core/facade.rb +126 -0
  62. data/lib/corl_core/gems.rb +72 -0
  63. data/lib/corl_core/manager.rb +425 -0
  64. data/lib/corl_core/mixin/action/commit.rb +58 -0
  65. data/lib/corl_core/mixin/action/keypair.rb +105 -0
  66. data/lib/corl_core/mixin/action/node.rb +129 -0
  67. data/lib/corl_core/mixin/action/project.rb +53 -0
  68. data/lib/corl_core/mixin/action/push.rb +52 -0
  69. data/lib/corl_core/mixin/config/collection.rb +53 -0
  70. data/lib/corl_core/mixin/config/ops.rb +53 -0
  71. data/lib/corl_core/mixin/config/options.rb +39 -0
  72. data/lib/corl_core/mixin/lookup.rb +196 -0
  73. data/lib/corl_core/mixin/macro/object_interface.rb +361 -0
  74. data/lib/corl_core/mixin/macro/plugin_interface.rb +380 -0
  75. data/lib/corl_core/mixin/settings.rb +46 -0
  76. data/lib/corl_core/mixin/sub_config.rb +148 -0
  77. data/lib/corl_core/mod/hash.rb +29 -0
  78. data/lib/corl_core/mod/hiera_backend.rb +63 -0
  79. data/lib/corl_core/plugin/action.rb +381 -0
  80. data/lib/corl_core/plugin/base.rb +374 -0
  81. data/lib/corl_core/plugin/command.rb +98 -0
  82. data/lib/corl_core/plugin/configuration.rb +177 -0
  83. data/lib/corl_core/plugin/event.rb +53 -0
  84. data/lib/corl_core/plugin/extension.rb +12 -0
  85. data/lib/corl_core/plugin/machine.rb +266 -0
  86. data/lib/corl_core/plugin/network.rb +359 -0
  87. data/lib/corl_core/plugin/node.rb +904 -0
  88. data/lib/corl_core/plugin/project.rb +927 -0
  89. data/lib/corl_core/plugin/provisioner.rb +51 -0
  90. data/lib/corl_core/plugin/template.rb +80 -0
  91. data/lib/corl_core/plugin/translator.rb +38 -0
  92. data/lib/corl_core/util/cli.rb +352 -0
  93. data/lib/corl_core/util/data.rb +404 -0
  94. data/lib/corl_core/util/disk.rb +114 -0
  95. data/lib/corl_core/util/git.rb +47 -0
  96. data/lib/corl_core/util/interface.rb +319 -0
  97. data/lib/corl_core/util/liquid.rb +17 -0
  98. data/lib/corl_core/util/package.rb +93 -0
  99. data/lib/corl_core/util/shell.rb +239 -0
  100. data/lib/corl_core/util/ssh.rb +286 -0
  101. data/lib/facter/corl_config_ready.rb +13 -0
  102. data/lib/facter/corl_exists.rb +15 -0
  103. data/lib/facter/corl_network.rb +17 -0
  104. data/lib/hiera/corl_logger.rb +18 -0
  105. data/lib/puppet/indirector/corl.rb +27 -0
  106. data/lib/puppet/indirector/data_binding/corl.rb +6 -0
  107. data/lib/puppet/parser/functions/config_initialized.rb +26 -0
  108. data/lib/puppet/parser/functions/corl_include.rb +44 -0
  109. data/lib/puppet/parser/functions/corl_resources.rb +58 -0
  110. data/lib/puppet/parser/functions/deep_merge.rb +21 -0
  111. data/lib/puppet/parser/functions/ensure.rb +29 -0
  112. data/lib/puppet/parser/functions/file_exists.rb +19 -0
  113. data/lib/puppet/parser/functions/global_array.rb +35 -0
  114. data/lib/puppet/parser/functions/global_hash.rb +35 -0
  115. data/lib/puppet/parser/functions/global_options.rb +23 -0
  116. data/lib/puppet/parser/functions/global_param.rb +43 -0
  117. data/lib/puppet/parser/functions/interpolate.rb +26 -0
  118. data/lib/puppet/parser/functions/is_false.rb +21 -0
  119. data/lib/puppet/parser/functions/is_true.rb +21 -0
  120. data/lib/puppet/parser/functions/module_array.rb +38 -0
  121. data/lib/puppet/parser/functions/module_hash.rb +38 -0
  122. data/lib/puppet/parser/functions/module_options.rb +23 -0
  123. data/lib/puppet/parser/functions/module_param.rb +48 -0
  124. data/lib/puppet/parser/functions/name.rb +21 -0
  125. data/lib/puppet/parser/functions/render.rb +33 -0
  126. data/lib/puppet/parser/functions/value.rb +21 -0
  127. data/locales/en.yml +232 -0
  128. data/spec/corl_core/interface_spec.rb +489 -0
  129. data/spec/corl_mock_input.rb +29 -0
  130. data/spec/corl_test_kernel.rb +22 -0
  131. data/spec/spec_helper.rb +15 -0
  132. metadata +406 -0
@@ -0,0 +1,374 @@
1
+
2
+ module CORL
3
+ module Plugin
4
+ class Base < Core
5
+
6
+ include Mixin::Lookup
7
+
8
+ #---
9
+
10
+ # All Plugin classes should directly or indirectly extend Base
11
+
12
+ def initialize(type, provider, options)
13
+ config = Util::Data.clean(Config.ensure(options))
14
+ name = Util::Data.ensure_value(config.delete(:plugin_name), config.delete(:name, provider))
15
+ @quiet = config.delete(:quiet, false)
16
+
17
+ set_meta(config.delete(:meta, Config.new))
18
+
19
+ # No logging statements aove this line!!
20
+ super(config.import({ :logger => "#{plugin_type}->#{plugin_provider}" }))
21
+ myself.plugin_name = name
22
+
23
+ logger.debug("Set #{plugin_type} plugin #{plugin_name} meta data: #{meta.inspect}")
24
+ logger.debug("Normalizing #{plugin_type} plugin #{plugin_name}")
25
+ normalize
26
+ end
27
+
28
+ #---
29
+
30
+ def method_missing(method, *args, &block)
31
+ return nil
32
+ end
33
+
34
+ #-----------------------------------------------------------------------------
35
+ # Checks
36
+
37
+ def initialized?(options = {})
38
+ return true
39
+ end
40
+
41
+ #---
42
+
43
+ def quiet?
44
+ @quiet
45
+ end
46
+
47
+ #-----------------------------------------------------------------------------
48
+ # Property accessor / modifiers
49
+
50
+ def myself
51
+ return current_actor if respond_to?(:current_actor) # Celluloid enhanced plugin
52
+ self
53
+ end
54
+ alias_method :me, :myself
55
+
56
+ #---
57
+
58
+ def quiet=quiet
59
+ @quiet = quiet
60
+ end
61
+
62
+ #---
63
+
64
+ def meta
65
+ return @meta
66
+ end
67
+
68
+ #---
69
+
70
+ def set_meta(meta)
71
+ @meta = Config.ensure(meta)
72
+ end
73
+
74
+ #---
75
+
76
+ def plugin_name
77
+ return meta.get(:name)
78
+ end
79
+ alias_method :name, :plugin_name
80
+
81
+ def plugin_name=plugin_name
82
+ meta.set(:name, string(plugin_name))
83
+ end
84
+ alias_method :name=, :plugin_name=
85
+
86
+ #---
87
+
88
+ def plugin_type
89
+ return meta.get(:type)
90
+ end
91
+
92
+ #---
93
+
94
+ def plugin_provider
95
+ return meta.get(:provider)
96
+ end
97
+
98
+ #---
99
+
100
+ def plugin_directory
101
+ return meta.get(:directory)
102
+ end
103
+
104
+ #---
105
+
106
+ def plugin_file
107
+ return meta.get(:file)
108
+ end
109
+
110
+ #---
111
+
112
+ def plugin_instance_name
113
+ return meta.get(:instance_name)
114
+ end
115
+
116
+ #---
117
+
118
+ def plugin_parent=parent
119
+ meta.set(:parent, parent) if parent.is_a?(CORL::Plugin::Base)
120
+ end
121
+
122
+ def plugin_parent
123
+ return meta.get(:parent)
124
+ end
125
+
126
+ #-----------------------------------------------------------------------------
127
+ # Status codes
128
+
129
+ def code
130
+ CORL.code
131
+ end
132
+
133
+ def codes(*codes)
134
+ CORL.codes(*codes)
135
+ end
136
+
137
+ #---
138
+
139
+ def status=status
140
+ meta.set(:status, status)
141
+ end
142
+
143
+ def status
144
+ meta.get(:status, code.unknown_status)
145
+ end
146
+
147
+ #-----------------------------------------------------------------------------
148
+ # Plugin operations
149
+
150
+ def normalize
151
+ end
152
+
153
+ #-----------------------------------------------------------------------------
154
+ # Extensions
155
+
156
+ def hook_method(hook)
157
+ "#{plugin_type}_#{plugin_provider}_#{hook}"
158
+ end
159
+
160
+ #---
161
+
162
+ def extension(hook, options = {})
163
+ method = hook_method(hook)
164
+
165
+ logger.debug("Executing plugin hook #{hook} (#{method})")
166
+
167
+ return Manager.connection.exec(method, Config.ensure(options).defaults({ :extension_type => :base }).import({ :plugin => myself })) do |op, results|
168
+ results = yield(op, results) if block_given?
169
+ results
170
+ end
171
+ end
172
+
173
+ #---
174
+
175
+ def extended_config(type, options = {})
176
+ config = Config.ensure(options)
177
+
178
+ logger.debug("Generating #{type} extended configuration from: #{config.export.inspect}")
179
+
180
+ extension("#{type}_config", Config.new(config.export).import({ :extension_type => :config })) do |op, results|
181
+ if op == :reduce
182
+ results.each do |provider, result|
183
+ config.defaults(result)
184
+ end
185
+ nil
186
+ else
187
+ hash(results)
188
+ end
189
+ end
190
+ config.delete(:extension_type)
191
+
192
+ logger.debug("Final extended configuration: #{config.export.inspect}")
193
+ config
194
+ end
195
+
196
+ #---
197
+
198
+ def extension_check(hook, options = {})
199
+ config = Config.ensure(options)
200
+
201
+ logger.debug("Checking extension #{plugin_provider} #{hook} given: #{config.export.inspect}")
202
+
203
+ success = extension(hook, config.import({ :extension_type => :check })) do |op, results|
204
+ if op == :reduce
205
+ ! results.values.include?(false)
206
+ else
207
+ results ? true : false
208
+ end
209
+ end
210
+
211
+ success = success.nil? || success ? true : false
212
+
213
+ logger.debug("Extension #{plugin_provider} #{hook} check result: #{success.inspect}")
214
+ success
215
+ end
216
+
217
+ #---
218
+
219
+ def extension_set(hook, value, options = {})
220
+ config = Config.ensure(options)
221
+
222
+ logger.debug("Setting extension #{plugin_provider} #{hook} value given: #{value.inspect}")
223
+
224
+ extension(hook, config.import({ :value => value, :extension_type => :set })) do |op, results|
225
+ if op == :process
226
+ value = results unless results.nil?
227
+ end
228
+ end
229
+
230
+ logger.debug("Extension #{plugin_provider} #{hook} set value to: #{value.inspect}")
231
+ value
232
+ end
233
+
234
+ #---
235
+
236
+ def extension_collect(hook, options = {})
237
+ config = Config.ensure(options)
238
+ values = []
239
+
240
+ logger.debug("Collecting extension #{plugin_provider} #{hook} values")
241
+
242
+ extension(hook, config.import({ :extension_type => :add })) do |op, results|
243
+ if op == :process
244
+ values << results unless results.nil?
245
+ end
246
+ end
247
+
248
+ logger.debug("Extension #{plugin_provider} #{hook} collected values: #{values.inspect}")
249
+ values
250
+ end
251
+
252
+ #-----------------------------------------------------------------------------
253
+ # Output
254
+
255
+ def render_options
256
+ export
257
+ end
258
+ protected :render_options
259
+
260
+ #---
261
+
262
+ def render(display, options = {})
263
+ ui.info(display.strip, options) unless quiet? || display.strip.empty?
264
+ end
265
+
266
+ #---
267
+
268
+ def info(name, options = {})
269
+ ui.info(I18n.t(name, Util::Data.merge([ Config.ensure(render_options).export, options ], true))) unless quiet?
270
+ end
271
+
272
+ #---
273
+
274
+ def alert(display, options = {})
275
+ ui.warn(display.strip, options) unless quiet? || display.strip.empty?
276
+ end
277
+
278
+ #---
279
+
280
+ def warn(name, options = {})
281
+ ui.warn(I18n.t(name, Util::Data.merge([ Config.ensure(render_options).export, options ], true))) unless quiet?
282
+ end
283
+
284
+ #---
285
+
286
+ def error(name, options = {})
287
+ ui.error(I18n.t(name, Util::Data.merge([ Config.ensure(render_options).export, options ], true))) unless quiet?
288
+ end
289
+
290
+ #---
291
+
292
+ def success(name, options = {})
293
+ ui.success(I18n.t(name, Util::Data.merge([ Config.ensure(render_options).export, options ], true))) unless quiet?
294
+ end
295
+
296
+ #-----------------------------------------------------------------------------
297
+ # Utilities
298
+
299
+ def self.build_info(type, data)
300
+ plugins = []
301
+
302
+ if data.is_a?(Hash)
303
+ data = [ data ]
304
+ end
305
+
306
+ logger.debug("Building plugin list of #{type} from data: #{data.inspect}")
307
+
308
+ if data.is_a?(Array)
309
+ data.each do |info|
310
+ unless Util::Data.empty?(info)
311
+ info = translate(info)
312
+
313
+ if Util::Data.empty?(info[:provider])
314
+ info[:provider] = Manager.connection.type_default(type)
315
+ end
316
+
317
+ logger.debug("Translated plugin info: #{info.inspect}")
318
+
319
+ plugins << info
320
+ end
321
+ end
322
+ end
323
+ return plugins
324
+ end
325
+
326
+ #---
327
+
328
+ def self.translate(data)
329
+ logger.debug("Translating data to internal plugin structure: #{data.inspect}")
330
+ return ( data.is_a?(Hash) ? symbol_map(data) : {} )
331
+ end
332
+
333
+ #---
334
+
335
+ def self.init_plugin_collection
336
+ logger.debug("Initializing plugin collection interface at #{Time.now}")
337
+
338
+ include Celluloid
339
+ include Mixin::Settings
340
+ include Mixin::SubConfig
341
+
342
+ extend Mixin::Macro::PluginInterface
343
+ end
344
+
345
+ #---
346
+
347
+ def safe_exec(return_result = true)
348
+ begin
349
+ result = yield
350
+ return result if return_result
351
+ return true
352
+
353
+ rescue Exception => e
354
+ logger.error(e.inspect)
355
+ logger.error(e.message)
356
+
357
+ ui.error(e.message, { :prefix => false }) if e.message
358
+ end
359
+ return false
360
+ end
361
+
362
+ #---
363
+
364
+ def admin_exec
365
+ if CORL.admin?
366
+ yield if block_given?
367
+ else
368
+ ui.warn("The #{plugin_provider} action must be run as a machine administrator")
369
+ myself.status = code.access_denied
370
+ end
371
+ end
372
+ end
373
+ end
374
+ end
@@ -0,0 +1,98 @@
1
+
2
+ module CORL
3
+ module Plugin
4
+ class Command < Base
5
+
6
+ #-----------------------------------------------------------------------------
7
+ # Command plugin interface
8
+
9
+ def normalize
10
+ super
11
+ end
12
+
13
+ #---
14
+
15
+ def to_s
16
+ return build(export)
17
+ end
18
+
19
+ #-----------------------------------------------------------------------------
20
+ # Property accessor / modifiers
21
+
22
+ def command(default = '')
23
+ return string(get(:command, default))
24
+ end
25
+
26
+ #---
27
+
28
+ def command=command
29
+ set(:command, string(command))
30
+ end
31
+
32
+ #---
33
+
34
+ def args(default = [])
35
+ return array(get(:args, default))
36
+ end
37
+
38
+ #---
39
+
40
+ def args=args
41
+ set(:args, array(args))
42
+ end
43
+
44
+ #---
45
+
46
+ def flags(default = [])
47
+ return array(get(:flags, default))
48
+ end
49
+
50
+ #---
51
+
52
+ def flags=flags
53
+ set(:flags, array(flags))
54
+ end
55
+
56
+ #---
57
+
58
+ def data(default = {})
59
+ return hash(get(:data, default))
60
+ end
61
+
62
+ #---
63
+
64
+ def data=data
65
+ set(:data, hash(data))
66
+ end
67
+
68
+ #---
69
+
70
+ def subcommand=subcommand
71
+ unless Util::Data.empty?(subcommand)
72
+ set(:subcommand, new(hash(subcommand)))
73
+ end
74
+ end
75
+
76
+ #-----------------------------------------------------------------------------
77
+ # Command operations
78
+
79
+ def build(components = {}, overrides = nil, override_key = false)
80
+ logger.debug("Building command with #{components.inspect}")
81
+ logger.debug("Overrides: #{overrides.inspect}")
82
+ logger.debug("Override key: #{override_key}")
83
+
84
+ return '' # Implement in sub classes
85
+ end
86
+
87
+ #---
88
+
89
+ def exec(options = {}, overrides = nil)
90
+ logger.debug("Executing command with #{options.inspect}")
91
+ logger.debug("Overrides: #{overrides.inspect}")
92
+
93
+ # Implement in sub classes (don't forget the yield!)
94
+ return true
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,177 @@
1
+
2
+ module CORL
3
+ module Plugin
4
+ class Configuration < Base
5
+
6
+ include Mixin::SubConfig
7
+
8
+ #-----------------------------------------------------------------------------
9
+ # Configuration plugin interface
10
+
11
+ def normalize
12
+ super
13
+
14
+ logger.debug("Initializing source sub configuration")
15
+ init_subconfig(true)
16
+
17
+ _init(:autoload, true)
18
+ _init(:autosave, false)
19
+ end
20
+
21
+ #-----------------------------------------------------------------------------
22
+ # Checks
23
+
24
+ def can_persist?
25
+ false
26
+ end
27
+
28
+ #-----------------------------------------------------------------------------
29
+ # Property accessors / modifiers
30
+
31
+ def autoload(default = false)
32
+ _get(:autoload, default)
33
+ end
34
+
35
+ def autoload=autoload
36
+ _set(:autoload, test(autoload))
37
+ end
38
+
39
+ #---
40
+
41
+ def autosave(default = false)
42
+ _get(:autosave, default)
43
+ end
44
+
45
+ def autosave=autosave
46
+ _set(:autosave, test(autosave))
47
+ end
48
+
49
+ #-----------------------------------------------------------------------------
50
+
51
+ def set(keys, value = '', options = {})
52
+ super(keys, value)
53
+ save(options) if autosave
54
+ end
55
+
56
+ #---
57
+
58
+ def delete(keys, options = {})
59
+ super(keys)
60
+ save(options) if autosave
61
+ end
62
+
63
+ #---
64
+
65
+ def clear(options = {})
66
+ super
67
+ save(options) if autosave
68
+ end
69
+
70
+ #-----------------------------------------------------------------------------
71
+
72
+ def remote(name)
73
+ nil
74
+ end
75
+
76
+ #---
77
+
78
+ def set_remote(name, location)
79
+ end
80
+
81
+ #-----------------------------------------------------------------------------
82
+ # Import / Export
83
+
84
+ def import(properties, options = {})
85
+ super(properties, options)
86
+ save(options) if autosave
87
+ end
88
+
89
+ #-----------------------------------------------------------------------------
90
+ # Configuration loading / saving
91
+
92
+ def load(options = {})
93
+ method_config = Config.ensure(options)
94
+ success = false
95
+
96
+ if can_persist?
97
+ if extension_check(:load, { :config => method_config })
98
+ logger.info("Loading source configuration")
99
+
100
+ config.clear if method_config.get(:override, false)
101
+
102
+ properties = Config.new
103
+ yield(method_config, properties) if block_given?
104
+
105
+ unless properties.export.empty?
106
+ logger.debug("Source configuration parsed properties: #{properties}")
107
+
108
+ extension(:load_process, { :properties => properties, :config => method_config })
109
+ config.import(properties, method_config)
110
+ end
111
+ success = true
112
+ end
113
+ else
114
+ logger.warn("Loading of source configuration failed")
115
+ end
116
+ success
117
+ end
118
+
119
+ #---
120
+
121
+ def save(options = {})
122
+ method_config = Config.ensure(options)
123
+ success = false
124
+
125
+ if can_persist?
126
+ if extension_check(:save, { :config => method_config })
127
+ logger.info("Saving source configuration")
128
+ logger.debug("Source configuration properties: #{config.export}")
129
+
130
+ success = yield(method_config) if block_given?
131
+ end
132
+ else
133
+ logger.warn("Can not save source configuration")
134
+ end
135
+ success
136
+ end
137
+
138
+ #---
139
+
140
+ def remove(options = {})
141
+ method_config = Config.ensure(options)
142
+ success = false
143
+
144
+ if can_persist?
145
+ if extension_check(:delete, { :config => method_config })
146
+ logger.info("Removing source configuration")
147
+
148
+ config.clear
149
+
150
+ success = yield(method_config) if block_given?
151
+ end
152
+ else
153
+ logger.warn("Can not remove source configuration")
154
+ end
155
+ success
156
+ end
157
+
158
+ #---
159
+
160
+ def attach(type, name, data, options = {})
161
+ method_config = Config.ensure(options)
162
+ new_location = nil
163
+
164
+ if can_persist?
165
+ if extension_check(:attach, { :config => method_config })
166
+ logger.info("Attaching data to source configuration")
167
+
168
+ new_location = yield(method_config) if block_given?
169
+ end
170
+ else
171
+ logger.warn("Can not attach data to source configuration")
172
+ end
173
+ new_location
174
+ end
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,53 @@
1
+
2
+ module CORL
3
+ module Plugin
4
+ class Event < Base
5
+
6
+ #-----------------------------------------------------------------------------
7
+ # Event plugin interface
8
+
9
+
10
+ #-----------------------------------------------------------------------------
11
+ # Property accessor / modifiers
12
+
13
+ #-----------------------------------------------------------------------------
14
+ # Operations
15
+
16
+ def render
17
+ return name
18
+ end
19
+
20
+ #---
21
+
22
+ def check(source)
23
+ # Implement in sub classes
24
+ return true
25
+ end
26
+
27
+ #-----------------------------------------------------------------------------
28
+ # Utilities
29
+
30
+ def self.build_info(type, data)
31
+ data = data.split(/\s*,\s*/) if data.is_a?(String)
32
+ return super(type, data)
33
+ end
34
+
35
+ #---
36
+
37
+ def self.translate(data)
38
+ options = super(data)
39
+
40
+ case data
41
+ when String
42
+ components = data.split(':')
43
+
44
+ options[:provider] = components.shift
45
+ options[:string] = components.join(':')
46
+
47
+ logger.debug("Translating event options: #{options.inspect}")
48
+ end
49
+ return options
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,12 @@
1
+
2
+ module CORL
3
+ module Plugin
4
+ class Extension < Base
5
+
6
+ #-----------------------------------------------------------------------------
7
+ # Extension plugin interface
8
+
9
+ # This plugin type is just a system container for various plugin hooks
10
+ end
11
+ end
12
+ end