Class: SshKeyPair

Inherits:
CloudstackCli::Base show all
Defined in:
lib/cloudstack-cli/commands/ssh_key_pairs.rb

Constant Summary

Constants included from CloudstackCli::Helper

CloudstackCli::Helper::ASYNC_STATES

Instance Attribute Summary

Attributes inherited from CloudstackCli::Base

#config

Instance Method Summary collapse

Methods inherited from CloudstackCli::Base

exit_on_failure?

Methods included from CloudstackCli::Helper

#ask_number, #bootstrap_server, #bootstrap_server_interactive, #create_port_rules, #create_server, #print_job_status, #print_options, #update_job_status, #watch_jobs

Instance Method Details

#create(name) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/cloudstack-cli/commands/ssh_key_pairs.rb', line 24

def create(name)
  pair = client.create_ssh_key_pair(name, options)
  say "Name : #{pair['name']}"
  say "Fingerprint : #{pair['fingerprint']}"
  say "Privatekey:"
  say pair['privatekey']
end

#delete(name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/cloudstack-cli/commands/ssh_key_pairs.rb', line 36

def delete(name)
  if options[:force] || yes?("Delete ssh key pair #{name}?", :yellow)
    if client.delete_ssh_key_pair(name, options)['success'] == "true"
      say("OK", :green)
    else
      say("Failed", :red)
      exit 1
    end
  end
end

#listObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cloudstack-cli/commands/ssh_key_pairs.rb', line 7

def list
  pairs = client.list_ssh_key_pairs(options)
  if pairs.size < 1
    say "No ssh key pairs found."
  else
    table = [["Name", "Fingerprint"]]
    pairs.each do |pair|
      table << [pair['name'], pair['fingerprint']]
    end
    print_table table
  end
end