Class: Chef::Knife::OneandoneSshKeyList

Inherits:
Chef::Knife show all
Includes:
OneandoneBase
Defined in:
lib/chef/knife/oneandone_ssh_key_list.rb

Instance Method Summary collapse

Methods included from OneandoneBase

#formated_output, included, #init_client

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/chef/knife/oneandone_ssh_key_list.rb', line 10

def run
  $stdout.sync = true

  init_client

  response = OneAndOne::SshKey.new.list
  formated_output(response, true)

  ssh_keys = [
    ui.color('ID', :bold),
    ui.color('Name', :bold),
    ui.color('Description', :bold),
    ui.color('State', :bold),
    ui.color('Servers', :bold),
    ui.color('Md5', :bold),
    ui.color('Public Key', :bold),
    ui.color('Creation Date', :bold)
  ]

  response.each do |ssh|
    ssh_keys << ssh['id']
    ssh_keys << ssh['name']
    ssh_keys << (ssh['description'].nil? ? '' : ssh['description'])
    ssh_keys << ssh['state']
    ssh_keys << ssh['servers'].to_s
    ssh_keys << ssh['md5']
    ssh_keys << ssh['public_key']
    ssh_keys << ssh['creation_date']
  end

  puts ui.list(ssh_keys, :uneven_columns_across, 8)
end