class Nucleon::Plugin::Machine

Public Instance Methods

create(options = {}) { |config| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 99
def create(options = {})
  success = true
  
  if created?
    logger.debug("Machine #{plugin_name} already exists")
  else
    logger.debug("Creating #{plugin_provider} machine with: #{options.inspect}")
    config  = Config.ensure(options)
    success = yield(config) if block_given?  
  end
  
  logger.warn("There was an error creating the machine #{plugin_name}") unless success
  success
end
create_image(options = {}) { |config| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 200
def create_image(options = {})
  success = true
  
  if running?
    logger.debug("Creating image of #{plugin_provider} machine with: #{options.inspect}")
    config  = Config.ensure(options)      
    success = yield(config) if block_given?
  else
    logger.debug("Machine #{plugin_name} is not running")  
  end
  
  logger.warn("There was an error creating an image of the machine #{plugin_name}") unless success
  success
end
created?() click to toggle source
# File lib/core/plugin/machine.rb, line 15
def created?
  false
end
destroy(options = {}) { |config| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 256
def destroy(options = {})   
  success = true
  
  if created?
    logger.debug("Destroying #{plugin_provider} machine with: #{options.inspect}")
    config  = Config.ensure(options)
    success = yield(config) if block_given?
  else
    logger.debug("Machine #{plugin_name} does not yet exist")
  end
  
  logger.warn("There was an error destroying the machine #{plugin_name}") unless success
  success
end
download(remote_path, local_path, options = {}) { |config, success| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 116
def download(remote_path, local_path, options = {})
  success = true
  
  if running?
    logger.debug("Downloading #{local_path} from #{remote_path} on #{plugin_provider} machine with: #{options.inspect}")
    config  = Config.ensure(options)      
    success = yield(config, success) if block_given?
  else
    logger.debug("Machine #{plugin_name} is not running")  
  end
  
  logger.warn("There was an error downloading from the machine #{plugin_name}") unless success
  success
end
exec(commands, options = {}) { |config, results| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 150
def exec(commands, options = {})
  results = []
  
  if running?
    logger.info("Executing commands ( #{commands.inspect} ) on machine #{plugin_name}")
    config  = Config.ensure(options)      
    results = yield(config, results) if block_given?
  else
    logger.debug("Machine #{plugin_name} is not running")  
  end
  
  logger.warn("There was an error executing command on the machine #{plugin_name}") unless results
  results
end
hostname() click to toggle source
# File lib/core/plugin/machine.rb, line 44
def hostname
  nil
end
image() click to toggle source
# File lib/core/plugin/machine.rb, line 80
def image
  nil
end
images() click to toggle source
# File lib/core/plugin/machine.rb, line 74
def images
  []
end
load() { || ... } click to toggle source
# File lib/core/plugin/machine.rb, line 87
def load
  success = true
  
  logger.debug("Loading #{plugin_provider} machine: #{plugin_name}")
  success = yield if block_given?  
      
  logger.warn("There was an error loading the machine #{plugin_name}") unless success
  success
end
machine_type() click to toggle source
# File lib/core/plugin/machine.rb, line 68
def machine_type
  nil
end
machine_types() click to toggle source
# File lib/core/plugin/machine.rb, line 62
def machine_types
  []
end
node() click to toggle source
# File lib/core/plugin/machine.rb, line 28
def node
  plugin_parent
end
node=(node) click to toggle source
# File lib/core/plugin/machine.rb, line 32
def node=node
  myself.plugin_parent = node
end
normalize(reload) click to toggle source
# File lib/core/plugin/machine.rb, line 9
def normalize(reload)
end
private_ip() click to toggle source
# File lib/core/plugin/machine.rb, line 56
def private_ip
  nil
end
public_ip() click to toggle source
# File lib/core/plugin/machine.rb, line 50
def public_ip
  nil
end
reload(options = {}) { |config| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 183
def reload(options = {})
  success = true
  
  if created?
    logger.debug("Reloading #{plugin_provider} machine with: #{options.inspect}")
    config  = Config.ensure(options)
    success = yield(config) if block_given?
  else
    logger.debug("Machine #{plugin_name} does not yet exist")
  end
  
  logger.warn("There was an error reloading the machine #{plugin_name}") unless success
  success
end
running?() click to toggle source
# File lib/core/plugin/machine.rb, line 21
def running?
  ( created? && false )
end
start(options = {}) { |config| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 234
def start(options = {})
  success = true
  
  if running?
    logger.debug("Machine #{plugin_name} is already running")  
  else
    logger.debug("Starting #{plugin_provider} machine with: #{options.inspect}")
    
    logger.debug("Machine #{plugin_name} is not running yet")
    if block_given?
      success = yield(config)  
    else
      success = create(options)  
    end            
  end
  
  logger.warn("There was an error starting the machine #{plugin_name}") unless success
  success
end
state() click to toggle source
# File lib/core/plugin/machine.rb, line 38
def state
  nil
end
stop(options = {}) { |config| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 217
def stop(options = {})
  success = true
  
  if running?
    logger.debug("Stopping #{plugin_provider} machine with: #{options.inspect}")
    config  = Config.ensure(options)      
    success = yield(config) if block_given?
  else
    logger.debug("Machine #{plugin_name} is not running")  
  end
  
  logger.warn("There was an error stopping the machine #{plugin_name}") unless success
  success
end
terminal(user, options = {}) { |config| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 167
def terminal(user, options = {})
  status = code.unknown_status
  
  if running?
    logger.debug("Launching #{user} terminal on #{plugin_provider} machine with: #{options.inspect}")
    config = Config.ensure(options)      
    status = yield(config) if block_given?
  else
    logger.debug("Machine #{plugin_name} is not running")  
  end    
  logger.warn("There was an error launching a #{user} terminal on the machine #{plugin_name}") unless status == code.success
  status
end
translate_state(state) click to toggle source
# File lib/core/plugin/machine.rb, line 274
def translate_state(state)
  return string(state).downcase.to_sym if status
  :unknown
end
upload(local_path, remote_path, options = {}) { |config, success| ... } click to toggle source
# File lib/core/plugin/machine.rb, line 133
def upload(local_path, remote_path, options = {})
  success = true
  
  if running?
    logger.debug("Uploading #{local_path} to #{remote_path} on #{plugin_provider} machine with: #{options.inspect}")
    config  = Config.ensure(options)      
    success = yield(config, success) if block_given?
  else
    logger.debug("Machine #{plugin_name} is not running")  
  end
  
  logger.warn("There was an error uploading to the machine #{plugin_name}") unless success
  success
end