Class: Coral::Plugin::Node
- Defined in:
- lib/coral_core/plugin/node.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
-
#create_image(options = {}) ⇒ Object
—.
-
#create_machine(provider, options = {}) ⇒ Object
—.
-
#delete_setting(property) ⇒ Object
—.
-
#destroy(options = {}) ⇒ Object
—.
-
#exec(commands, options = {}) ⇒ Object
—.
-
#hostname ⇒ Object
—.
-
#machine ⇒ Object
—————————————————————————–.
-
#machine=(machine) ⇒ Object
—.
-
#network ⇒ Object
—————————————————————————– Property accessors / modifiers.
-
#network=(network) ⇒ Object
—.
-
#normalize ⇒ Object
—————————————————————————– Node plugin interface.
-
#private_ip ⇒ Object
—.
-
#provision(options = {}) ⇒ Object
—.
-
#public_ip ⇒ Object
—.
-
#reload(options = {}) ⇒ Object
—.
-
#search(property, default = nil, format = false) ⇒ Object
—.
-
#set_setting(property, value = nil) ⇒ Object
—.
-
#setting(property, default = nil, format = false) ⇒ Object
—.
-
#start(options = {}) ⇒ Object
—————————————————————————– Machine operations.
-
#state ⇒ Object
—.
-
#stop(options = {}) ⇒ Object
—.
Methods inherited from Base
build_info, ensure_plugin_collection, #initialize, #initialized?, #meta, #method_missing, #name, #name=, #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
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_image(options = {}) ⇒ Object
174 175 176 177 |
# File 'lib/coral_core/plugin/node.rb', line 174 def create_image( = {}) return true unless machine && machine.running? return machine.create_image() end |
#create_machine(provider, options = {}) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/coral_core/plugin/node.rb', line 70 def create_machine(provider, = {}) if provider.is_a?(String) || provider.is_a?(Symbol) set(:machine, Coral.machine(, provider)) end return self end |
#delete_setting(property) ⇒ Object
51 52 53 54 |
# File 'lib/coral_core/plugin/node.rb', line 51 def delete_setting(property) network.delete_node_setting(plugin_provider, name, property) return self end |
#destroy(options = {}) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/coral_core/plugin/node.rb', line 129 def destroy( = {}) return true unless machine config = Config.ensure() if machine.created? run = false if config[:force] run = true else choice = nil begin choice = ui.ask("Are you sure you want to remove: #{name}?") run = choice.upcase == "Y" rescue Errors::UIExpectsTTY run = false end end if run return machine.destroy(config) end end return true end |
#exec(commands, options = {}) ⇒ Object
158 159 160 161 162 163 |
# File 'lib/coral_core/plugin/node.rb', line 158 def exec(commands, = {}) return true unless machine && machine.running? config = Config.ensure() return machine.exec(config.import({ :commands => commands })) end |
#hostname ⇒ Object
93 94 95 96 |
# File 'lib/coral_core/plugin/node.rb', line 93 def hostname # Must be set at machine level return machine.hostname if machine return '' end |
#machine ⇒ Object
58 59 60 |
# File 'lib/coral_core/plugin/node.rb', line 58 def machine return get(:machine, nil) end |
#machine=(machine) ⇒ Object
64 65 66 |
# File 'lib/coral_core/plugin/node.rb', line 64 def machine=machine set(:machine, machine) end |
#network ⇒ Object
Property accessors / modifiers
20 21 22 |
# File 'lib/coral_core/plugin/node.rb', line 20 def network return plugin_parent end |
#network=(network) ⇒ Object
26 27 28 |
# File 'lib/coral_core/plugin/node.rb', line 26 def network=network self.plugin_parent = network end |
#normalize ⇒ Object
Node plugin interface
9 10 11 |
# File 'lib/coral_core/plugin/node.rb', line 9 def normalize super end |
#private_ip ⇒ Object
86 87 88 89 |
# File 'lib/coral_core/plugin/node.rb', line 86 def private_ip # Must be set at machine level return machine.private_ip if machine return nil end |
#provision(options = {}) ⇒ Object
167 168 169 170 |
# File 'lib/coral_core/plugin/node.rb', line 167 def provision( = {}) return true unless machine && machine.running? return machine.provision() end |
#public_ip ⇒ Object
79 80 81 82 |
# File 'lib/coral_core/plugin/node.rb', line 79 def public_ip # Must be set at machine level return machine.public_ip if machine return nil end |
#reload(options = {}) ⇒ Object
122 123 124 125 |
# File 'lib/coral_core/plugin/node.rb', line 122 def reload( = {}) return true unless machine && machine.created? return machine.reload() end |
#search(property, default = nil, format = false) ⇒ Object
38 39 40 |
# File 'lib/coral_core/plugin/node.rb', line 38 def search(property, default = nil, format = false) return network.search_node(plugin_provider, name, property, default, format) end |
#set_setting(property, value = nil) ⇒ Object
44 45 46 47 |
# File 'lib/coral_core/plugin/node.rb', line 44 def set_setting(property, value = nil) network.set_node_setting(plugin_provider, name, property, value) return self end |
#setting(property, default = nil, format = false) ⇒ Object
32 33 34 |
# File 'lib/coral_core/plugin/node.rb', line 32 def setting(property, default = nil, format = false) return network.node_setting(plugin_provider, name, property, default, format) end |
#start(options = {}) ⇒ Object
Machine operations
108 109 110 111 |
# File 'lib/coral_core/plugin/node.rb', line 108 def start( = {}) return true unless machine return machine.start() end |
#state ⇒ Object
100 101 102 103 |
# File 'lib/coral_core/plugin/node.rb', line 100 def state # Must be set at machine level return machine.state if machine return nil end |
#stop(options = {}) ⇒ Object
115 116 117 118 |
# File 'lib/coral_core/plugin/node.rb', line 115 def stop( = {}) return true unless machine && machine.running? return machine.stop() end |