Sha256: 99ed50f956108fc2a7a276af7a6c8ee6677db8cba6c42e69ea2a66f02857554d
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
class SshKeyPair < CloudstackCli::Base desc "ssh_key_pair list", 'list ssh key pairs' option :listall option :account option :project 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 desc 'ssh_key_pair create NAME', 'create ssh key pair' option :account option :project 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 register NAME', 'register ssh key pair' option :account option :project option :public_key, required: true, desc: "path to public_key file" def register(name) if File.exist?(options[:public_key]) public_key = IO.read(options[:public_key]) else say("Can't open public key #{options[:public_key]}", :red) exit 1 end pair = client.register_ssh_key_pair(name, public_key, 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cloudstack-cli-0.4.3 | lib/cloudstack-cli/commands/ssh_key_pairs.rb |