Class: Coral::Plugin::Machine

Inherits:
Base show all
Defined in:
lib/coral_core/plugin/machine.rb

Direct Known Subclasses

Machine::Fog

Instance Attribute Summary

Attributes inherited from Core

#ui

Instance Method Summary collapse

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

#parse

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(options = {})
  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(options = {})
  if created?
    
  end
  return true
end

#created?Boolean


Checks

Returns:

  • (Boolean)


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(options = {})   
  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(options = {})
  if running?
    config = Config.ensure(options)
    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

#hostnameObject


Property accessors / modifiers



26
27
28
# File 'lib/coral_core/plugin/machine.rb', line 26

def hostname
  return get(:hostname, '')
end

#private_ipObject




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(options = {})
  if running?
    config = Config.ensure(options)
    
    # 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_ipObject




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(options = {})
  if created?
    
  end
  return true
end

#running?Boolean


Returns:

  • (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(options = {})
  unless running?
    
  end
  return true
end

#stateObject




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(options = {})
  if running?
    
  end
  return true
end