Module: Coral
- Defined in:
- lib/coral_core.rb,
lib/coral_core/core.rb,
lib/coral_core/event.rb,
lib/coral/machine/fog.rb,
lib/coral_core/config.rb,
lib/coral_core/plugin.rb,
lib/coral/command/shell.rb,
lib/coral_core/resource.rb,
lib/coral_core/template.rb,
lib/coral_core/util/cli.rb,
lib/coral_core/util/git.rb,
lib/coral/node/rackspace.rb,
lib/coral_core/util/data.rb,
lib/coral_core/util/disk.rb,
lib/coral/network/default.rb,
lib/coral_core/repository.rb,
lib/coral_core/util/shell.rb,
lib/coral_core/plugin/node.rb,
lib/coral_core/plugin_base.rb,
lib/coral_core/mixin/lookup.rb,
lib/coral_core/util/process.rb,
lib/coral_core/template/json.rb,
lib/coral_core/template/yaml.rb,
lib/coral_core/config/options.rb,
lib/coral_core/config/project.rb,
lib/coral_core/mixin/settings.rb,
lib/coral_core/plugin/command.rb,
lib/coral_core/plugin/machine.rb,
lib/coral_core/plugin/network.rb,
lib/coral_core/util/interface.rb,
lib/coral_core/mixin/config_ops.rb,
lib/coral_core/mixin/sub_config.rb,
lib/coral_core/template/wrapper.rb,
lib/coral_core/config/collection.rb,
lib/coral_core/event/puppet_event.rb,
lib/coral_core/event/regexp_event.rb,
lib/coral_core/mixin/config_options.rb,
lib/coral_core/template/environment.rb,
lib/coral_core/mixin/config_collection.rb,
lib/coral_core/mixin/macro/object_interface.rb,
lib/coral_core/mixin/macro/plugin_interface.rb
Overview
Defined Under Namespace
Modules: Command, Machine, Mixin, Network, Node, Plugin, Resource, Template, Util Classes: Config, Core, Event, Git, PuppetEvent, RegexpEvent, Repository
Constant Summary collapse
- VERSION =
File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
- @@config_file =
'coral.json'
- @@initialized =
Initialization
false
Class Method Summary collapse
-
.class_const(name, separator = '::') ⇒ Object
—.
-
.class_name(name, separator = '::', want_array = FALSE) ⇒ Object
—————————————————————————– Utilities.
-
.command(options, provider = nil) ⇒ Object
—.
-
.commands(data, build_hash = false, keep_array = false) ⇒ Object
—.
-
.config_file ⇒ Object
—.
-
.config_file=(file_name) ⇒ Object
—————————————————————————–.
-
.get_plugin(type, name) ⇒ Object
—.
- .initialize ⇒ Object
-
.initialized? ⇒ Boolean
—.
-
.logger ⇒ Object
—.
-
.machine(options = {}, provider = nil) ⇒ Object
—.
-
.machines(data, build_hash = false, keep_array = false) ⇒ Object
—.
-
.network(name, options = {}, provider = nil) ⇒ Object
—————————————————————————– Core plugin type facade.
-
.networks(data, build_hash = false, keep_array = false) ⇒ Object
—.
-
.node(name, options = {}, provider = nil) ⇒ Object
—.
-
.nodes(data, build_hash = false, keep_array = false) ⇒ Object
—.
-
.plugin(type, provider, options = {}) ⇒ Object
—————————————————————————– Plugins.
-
.plugins(type, data, build_hash = false, keep_array = false) ⇒ Object
—.
-
.remove_plugin(plugin) ⇒ Object
—.
-
.run ⇒ Object
—————————————————————————– External execution.
-
.sha1(data) ⇒ Object
—.
-
.ui ⇒ Object
—————————————————————————–.
Class Method Details
.class_const(name, separator = '::') ⇒ Object
352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/coral_core.rb', line 352 def self.class_const(name, separator = '::') components = class_name(name, separator, TRUE) constant = Object components.each do |component| constant = constant.const_defined?(component) ? constant.const_get(component) : constant.const_missing(component) end return constant end |
.class_name(name, separator = '::', want_array = FALSE) ⇒ Object
Utilities
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/coral_core.rb', line 330 def self.class_name(name, separator = '::', want_array = FALSE) components = [] case name when String, Symbol components = name.to_s.split(separator) when Array components = name end components.collect! do |value| value.to_s.strip.capitalize end if want_array return components end return components.join(separator) end |
.command(options, provider = nil) ⇒ Object
302 303 304 |
# File 'lib/coral_core.rb', line 302 def self.command(, provider = nil) return plugin(:command, provider, ) end |
.commands(data, build_hash = false, keep_array = false) ⇒ Object
308 309 310 |
# File 'lib/coral_core.rb', line 308 def self.commands(data, build_hash = false, keep_array = false) return plugins(:command, data, build_hash, keep_array) end |
.config_file ⇒ Object
173 174 175 |
# File 'lib/coral_core.rb', line 173 def self.config_file return @@config_file end |
.config_file=(file_name) ⇒ Object
167 168 169 |
# File 'lib/coral_core.rb', line 167 def self.config_file=file_name @@config_file = file_name end |
.get_plugin(type, name) ⇒ Object
248 249 250 |
# File 'lib/coral_core.rb', line 248 def self.get_plugin(type, name) return Plugin.get_instance(type, name) end |
.initialize ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/coral_core.rb', line 182 def self.initialize unless @@initialized Config.set_property('time', Time.now.to_i) begin # Include Coral plugins Puppet::Node::Environment.new.modules.each do |mod| lib_path = File.join(mod.path, 'lib', 'coral') Plugin.register(lib_path) end rescue end Plugin.initialize @@initialized = true end end |
.initialized? ⇒ Boolean
203 204 205 |
# File 'lib/coral_core.rb', line 203 def self.initialized? return @@initialized end |
.logger ⇒ Object
161 162 163 |
# File 'lib/coral_core.rb', line 161 def self.logger return Core.logger end |
.machine(options = {}, provider = nil) ⇒ Object
289 290 291 292 |
# File 'lib/coral_core.rb', line 289 def self.machine( = {}, provider = nil) plugin = plugin(:machine, provider, ) return plugin end |
.machines(data, build_hash = false, keep_array = false) ⇒ Object
296 297 298 |
# File 'lib/coral_core.rb', line 296 def self.machines(data, build_hash = false, keep_array = false) return plugins(:machine, data, build_hash, keep_array) end |
.network(name, options = {}, provider = nil) ⇒ Object
Core plugin type facade
261 262 263 264 265 |
# File 'lib/coral_core.rb', line 261 def self.network(name, = {}, provider = nil) plugin = plugin(:network, provider, ) plugin.name = name return plugin end |
.networks(data, build_hash = false, keep_array = false) ⇒ Object
269 270 271 |
# File 'lib/coral_core.rb', line 269 def self.networks(data, build_hash = false, keep_array = false) return plugins(:network, data, build_hash, keep_array) end |
.node(name, options = {}, provider = nil) ⇒ Object
275 276 277 278 279 |
# File 'lib/coral_core.rb', line 275 def self.node(name, = {}, provider = nil) plugin = plugin(:node, provider, ) plugin.name = name return plugin end |
.nodes(data, build_hash = false, keep_array = false) ⇒ Object
283 284 285 |
# File 'lib/coral_core.rb', line 283 def self.nodes(data, build_hash = false, keep_array = false) return plugins(:node, data, build_hash, keep_array) end |
.plugin(type, provider, options = {}) ⇒ Object
Plugins
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/coral_core.rb', line 210 def self.plugin(type, provider, = {}) default_provider = Plugin.type_default(type) if .is_a?(Hash) || .is_a?(Coral::Config) config = Config.ensure() provider = config.get(:provider, provider) name = config.get(:name, ( provider ? provider : default_provider )) = config.export end provider = default_provider unless provider # Sanity checking (see plugins) existing_instance = Plugin.get_instance(type, name) if name return existing_instance if existing_instance return Plugin.create_instance(type, provider, ) end |
.plugins(type, data, build_hash = false, keep_array = false) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/coral_core.rb', line 228 def self.plugins(type, data, build_hash = false, keep_array = false) group = ( build_hash ? {} : [] ) klass = class_const([ :coral, :plugin, type ]) data = klass.build_info(type, data) if klass.respond_to?(:build_info) data.each do || if plugin = plugin(type, [:provider], ) if build_hash group[plugin.name] = plugin else group << plugin end end end return group.shift if ! build_hash && group.length == 1 && ! keep_array return group end |
.remove_plugin(plugin) ⇒ Object
254 255 256 |
# File 'lib/coral_core.rb', line 254 def self.remove_plugin(plugin) return Plugin.remove_instance(plugin) end |
.run ⇒ Object
External execution
315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/coral_core.rb', line 315 def self.run begin initialize yield rescue Exception => error ui.warn(error.inspect) ui.warn(Util::Data.to_yaml(error.backtrace)) raise end end |