Class: CORL::Action::Keypair

Inherits:
Plugin::CloudAction show all
Includes:
Mixin::Action::Keypair
Defined in:
lib/CORL/action/keypair.rb

Instance Method Summary collapse

Methods included from Mixin::Action::Keypair

#keypair, #keypair=, #keypair_clean, #keypair_config, #keypair_ignore

Methods inherited from Plugin::CloudAction

#ensure_network, #ensure_node, #execute_remote, #init_network, #namespace, #node_config, #node_exec, #node_ignore, #validate

Instance Method Details

#configureObject


Settings



11
12
13
14
15
16
17
18
# File 'lib/CORL/action/keypair.rb', line 11

def configure
  super do
    codes :key_failure
    
    register :json, :bool, true
    keypair_config
  end
end

#executeObject


Operations



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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

#ignoreObject




22
23
24
# File 'lib/CORL/action/keypair.rb', line 22

def ignore
  node_ignore
end