Module: CloudstackClient::SshKeyPair
- Defined in:
- lib/cloudstack-client/commands/ssh_key_pair.rb
Instance Method Summary collapse
-
#create_ssh_key_pair(name, args = {}) ⇒ Object
Create ssh key pairs.
-
#delete_ssh_key_pair(name, args = {}) ⇒ Object
Delete ssh key pairs.
-
#list_ssh_key_pairs(args = {}) ⇒ Object
Lists ssh key pairs.
Instance Method Details
#create_ssh_key_pair(name, args = {}) ⇒ Object
Create ssh key pairs.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cloudstack-client/commands/ssh_key_pair.rb', line 44 def create_ssh_key_pair(name, args = {}) params = { 'command' => 'createSSHKeyPair', 'name' => name } if args[:project] project = get_project(args[:project]) unless project puts "Error: project #{args[:project]} not found." exit 1 end params['projectid'] = project['id'] end if args[:account] account = list_accounts({name: args[:account]}).first unless account puts "Error: Account #{args[:account]} not found." exit 1 end params['domainid'] = account["domainid"] params['account'] = args[:account] end params['publickey'] = args[:public_key] if args[:public_key] json = send_request(params)['keypair'] end |
#delete_ssh_key_pair(name, args = {}) ⇒ Object
Delete ssh key pairs.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cloudstack-client/commands/ssh_key_pair.rb', line 76 def delete_ssh_key_pair(name, args = {}) params = { 'command' => 'deleteSSHKeyPair', 'name' => name } if args[:project] project = get_project(args[:project]) unless project puts "Error: project #{args[:project]} not found." exit 1 end params['projectid'] = project['id'] end if args[:account] account = list_accounts({name: args[:account]}).first unless account puts "Error: Account #{args[:account]} not found." exit 1 end params['domainid'] = account["domainid"] params['account'] = args[:account] end json = send_request(params) end |
#list_ssh_key_pairs(args = {}) ⇒ Object
Lists ssh key pairs.
9 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 |
# File 'lib/cloudstack-client/commands/ssh_key_pair.rb', line 9 def list_ssh_key_pairs(args = {}) params = { 'command' => 'listSSHKeyPairs', 'isrecursive' => true } params['listall'] = true if args[:listall] params['name'] = args[:name] if args[:name] if args[:project] project = get_project(args[:project]) unless project puts "Error: project #{args[:project]} not found." exit 1 end params['projectid'] = project['id'] end if args[:account] account = list_accounts({name: args[:account]}).first unless account puts "Error: Account #{args[:account]} not found." exit 1 end params['domainid'] = account["domainid"] params['account'] = args[:account] end json = send_request(params) json['sshkeypair'] || [] end |