Sha256: 19443f867ce21bbc26e1ea9041127e2924d5a05526656b4eeb37d158e3c54e4a

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

class SshKeyPair < CloudstackCli::Base

  desc "ssh_key_pair list", 'list ssh key pairs'
  option :listall
  option :account
  option :project
  def list
    puts self.methods
    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

  desc 'ssh_key_pair create NAME', 'create ssh key pair'
  option :account
  option :project
  option :public_key
  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

  desc 'ssh_key_pair delete NAME', 'delete ssh key pair'
  option :account
  option :project
  option :force, aliases: '-f', desc: "delete without asking"
  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
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cloudstack-cli-0.4.1 lib/cloudstack-cli/commands/ssh_key_pairs.rb
cloudstack-cli-0.4.0 lib/cloudstack-cli/commands/ssh_key_pairs.rb
cloudstack-cli-0.3.11 lib/cloudstack-cli/commands/ssh_key_pairs.rb