class Chef::Knife::CloudstackKeypairList

Public Instance Methods

run() click to toggle source
# 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