Class: Coral::Plugin::Machine
- Defined in:
- lib/coral_core/plugin/machine.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
-
#create(options = {}) ⇒ Object
—————————————————————————– Management.
-
#create_image(options = {}) ⇒ Object
—.
-
#created? ⇒ Boolean
—————————————————————————– Checks.
-
#destroy(options = {}) ⇒ Object
—.
-
#exec(options = {}) ⇒ Object
—.
-
#hostname ⇒ Object
—————————————————————————– Property accessors / modifiers.
-
#private_ip ⇒ Object
—.
-
#provision(options = {}) ⇒ Object
—.
-
#public_ip ⇒ Object
—.
-
#reload(options = {}) ⇒ Object
—.
-
#running? ⇒ Boolean
—.
-
#start(options = {}) ⇒ Object
—.
-
#state ⇒ Object
—.
-
#stop(options = {}) ⇒ Object
—.
Methods inherited from Base
build_info, ensure_plugin_collection, #initialize, #initialized?, #meta, #method_missing, #name, #name=, #normalize, #plugin_directory, #plugin_file, #plugin_instance_name, #plugin_parent, #plugin_parent=, #plugin_provider, #plugin_type, #set_meta, translate
Methods inherited from Core
#initialize, #inspect, #logger, logger, logger=, ui
Methods inherited from Config
#[], #[]=, array, #array, #clear, #defaults, #delete, ensure, #export, #filter, filter, #get, #get_array, #get_hash, #hash, hash, #import, init, #init, init_flat, #initialize, #set, #string, string, string_map, #string_map, #symbol, symbol, symbol_map, #symbol_map, test, #test
Methods included from Mixin::ConfigOptions
#clear_options, #contexts, #get_options, #set_options
Methods included from Mixin::ConfigCollection
#all_properties, #clear_properties, #delete_property, #get_property, #save_properties, #set_property
Methods included from Mixin::Lookup
#hiera, #hiera_config, #initialized?, #lookup, #lookup_array, #lookup_hash, #normalize
Methods included from Mixin::ConfigOps
Constructor Details
This class inherits a constructor from Coral::Plugin::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Coral::Plugin::Base
Instance Method Details
#create(options = {}) ⇒ Object
Management
51 52 53 54 55 56 |
# File 'lib/coral_core/plugin/machine.rb', line 51 def create( = {}) unless created? end return true end |
#create_image(options = {}) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/coral_core/plugin/machine.rb', line 140 def create_image( = {}) if created? end return true end |
#created? ⇒ Boolean
Checks
13 14 15 |
# File 'lib/coral_core/plugin/machine.rb', line 13 def created? return false end |
#destroy(options = {}) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/coral_core/plugin/machine.rb', line 87 def destroy( = {}) if created? end return true end |
#exec(options = {}) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/coral_core/plugin/machine.rb', line 96 def exec( = {}) if running? config = Config.ensure() if commands = config.delete(:commands) commands.each do |command| Util::Shell.exec!(command, config) do |line| yield(line) if block_given? end end end end return true end |
#hostname ⇒ Object
Property accessors / modifiers
26 27 28 |
# File 'lib/coral_core/plugin/machine.rb', line 26 def hostname return get(:hostname, '') end |
#private_ip ⇒ Object
44 45 46 |
# File 'lib/coral_core/plugin/machine.rb', line 44 def private_ip return get(:private_ip, nil) end |
#provision(options = {}) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/coral_core/plugin/machine.rb', line 112 def provision( = {}) if running? config = Config.ensure() # TODO: Abstract this out so it does not depend on Puppet functionality. puppet = config.delete(:puppet, :puppet) # puppet (community) or puppetlabs (enterprise) command = Coral.command({ :command => :puppet, :flags => config.delete(:puppet_flags, ''), :subcommand => { :command => config.delete(:puppet_op, :apply), :flags => config.delete(:puppet_op_flags, ''), :data => config.delete(:puppet_op_data, {}).merge({ 'modulepath=' => array(config.delete(:puppet_modules, "/etc/#{puppet}/modules")).join(':') }), :args => config.delete(:puppet_manifest, "/etc/#{puppet}/manifests/site.pp") } }, config.get(:provider, :shell)) config[:commands] = [ command.to_s ] return exec(config) end return true end |
#public_ip ⇒ Object
38 39 40 |
# File 'lib/coral_core/plugin/machine.rb', line 38 def public_ip return get(:public_ip, nil) end |
#reload(options = {}) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/coral_core/plugin/machine.rb', line 78 def reload( = {}) if created? end return true end |
#running? ⇒ Boolean
19 20 21 |
# File 'lib/coral_core/plugin/machine.rb', line 19 def running? return ( created? && false ) end |
#start(options = {}) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/coral_core/plugin/machine.rb', line 60 def start( = {}) unless running? end return true end |
#state ⇒ Object
32 33 34 |
# File 'lib/coral_core/plugin/machine.rb', line 32 def state return get(:state, nil) end |
#stop(options = {}) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/coral_core/plugin/machine.rb', line 69 def stop( = {}) if running? end return true end |