Sha256: bce6e8c4188fa593d1f26513233bd9f008f87ca5b55018d83c008505dcaea7a1

Contents?: true

Size: 1.96 KB

Versions: 14

Compression:

Stored size: 1.96 KB

Contents

module CORL
module Action
class Ssh < Plugin::CloudAction

  #-----------------------------------------------------------------------------
  # Settings
  
  def configure
    super do
      codes :network_failure
      
      register :ssh_nodes, :array, nil do |values|
        if values.nil?
          warn('corl.actions.bootstrap.errors.ssh_nodes_empty')
          next false 
        end
        
        node_plugins = CORL.loaded_plugins(:node)
        success      = true
        
        values.each do |value|
          if info = CORL.plugin_class(:node).translate_reference(value)
            if ! node_plugins.keys.include?(info[:provider].to_sym) || info[:name].empty?
              warn('corl.actions.bootstrap.errors.ssh_nodes', { :value => value, :node_provider => info[:provider],  :name => info[:name] })
              success = false
            end
          end
        end
        success
      end
      
      config[:node_provider].default = :rackspace
    end
  end
  
  #---
  
  def ignore
    node_ignore - [ :net_provider, :node_provider ]
  end
  
  def arguments
    [ :ssh_nodes ]
  end

  #-----------------------------------------------------------------------------
  # Operations
    
  def execute
    super do |local_node, network|
      if network
        batch_success = network.batch(settings[:ssh_nodes], settings[:node_provider], false) do |node|
          render_options = { :id => node.id, :hostname => node.hostname }
          
          info('corl.actions.ssh.start', render_options)
          success = node.terminal(extended_config(:ssh, {}))
          if success
            info('corl.actions.ssh.success', render_options)
          else
            render_options[:status] = node.status
            error('corl.actions.ssh.failure', render_options)
          end
          success
        end
        myself.status = code.batch_error unless batch_success
      else
        myself.status = code.network_failure
      end
    end
  end
end
end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
corl-0.4.15 lib/CORL/action/ssh.rb
corl-0.4.14 lib/CORL/action/ssh.rb
corl-0.4.13 lib/CORL/action/ssh.rb
corl-0.4.12 lib/CORL/action/ssh.rb
corl-0.4.11 lib/CORL/action/ssh.rb
corl-0.4.10 lib/CORL/action/ssh.rb
corl-0.4.9 lib/CORL/action/ssh.rb
corl-0.4.8 lib/CORL/action/ssh.rb
corl-0.4.7 lib/CORL/action/ssh.rb
corl-0.4.6 lib/CORL/action/ssh.rb
corl-0.4.5 lib/CORL/action/ssh.rb
corl-0.4.4 lib/CORL/action/ssh.rb
corl-0.4.3 lib/CORL/action/ssh.rb
corl-0.4.2 lib/CORL/action/ssh.rb