class Chef::Knife::OneandoneSshKeyCreate

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/oneandone_ssh_key_create.rb, line 32
def run
  $stdout.sync = true

  validate(config[:name], '-n NAME')

  init_client

  ssh_key = OneAndOne::SshKey.new
  response = ssh_key.create(name: config[:name], description: config[:description],
                            public_key: config[:public_key])

  if config[:wait]
    ssh_key.wait_for
    formated_output(ssh_key.get, true)
    puts "SSH Key #{response['id']} is #{ui.color('created', :bold)}"
  else
    formated_output(response, true)
    puts "SSH Key #{response['id']} is #{ui.color('being created', :bold)}"
  end
end