Class: Chef::Knife::CloudstackKeypairList

Inherits:
Chef::Knife
  • Object
show all
Includes:
CloudstackBase
Defined in:
lib/chef/knife/cloudstack_keypair_list.rb

Instance Method Summary collapse

Methods included from CloudstackBase

#connection, included, #locate_config_value, #msg_pair, #validate!

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chef/knife/cloudstack_keypair_list.rb', line 29

def run
  $stdout.sync = true

  validate!

  sshkeypair_list = [
    ui.color('Name', :bold),
    ui.color('Fingerprint', :bold),
    ui.color('Private Key', :bold)
  ]
  response = connection.list_ssh_key_pairs['listsshkeypairsresponse']
    if sshkeypairs = response['sshkeypair']
      sshkeypairs.each do |sshkeypair|
        sshkeypair_list << sshkeypair['name'].to_s
        sshkeypair_list << sshkeypair['fingerprint'].to_s
        sshkeypair_list << sshkeypair['privatekey'].to_s
      end
    end
  puts ui.list(sshkeypair_list, :columns_across, 3)

end