class CORL::Action::Keypair

Public Instance Methods

configure() click to toggle source
# File lib/CORL/action/keypair.rb, line 11
def configure
  super do
    codes :key_failure
    
    register :json, :bool, true
    keypair_config
  end
end
execute() click to toggle source
# File lib/CORL/action/keypair.rb, line 29
def execute
  super do |node, network|
    if keys = keypair
      ui.info("\n", { :prefix => false })
      ui_group(Util::Console.cyan("#{keys.type.upcase} SSH keypair")) do |ui|
        ui.info("-----------------------------------------------------")
      
        if settings[:json]
          private_key = Util::Console.blue(Util::Data.to_json(keys.encrypted_key, true))
          ssh_key     = keys.ssh_key.gsub(/^ssh\-[a-z]+\s+/, '')           
          ssh_key     = Util::Console.green(Util::Data.to_json(ssh_key, true))
        else
          private_key = Util::Console.blue(keys.encrypted_key)
          ssh_key     = Util::Console.green(keys.ssh_key)       
        end
        
        ui.info("SSH private key:\n#{private_key}")
        ui.info("SSH public key:\n#{ssh_key}")
        ui.info("\n", { :prefix => false }) 
      end          
    else
      myself.status = code.key_failure  
    end
  end
end
ignore() click to toggle source
# File lib/CORL/action/keypair.rb, line 22
def ignore
  node_ignore
end