35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/chef/knife/cosmic_keypair_delete.rb', line 35
def run
validate_base_options
Chef::Log.debug("Validate keypair name")
keypairname = locate_config_value(:name) || @name_args.first
unless /^[a-zA-Z0-9][a-zA-Z0-9\-\_]*$/.match(keypairname) then
ui.error "Invalid keypairname. Please specify a short name for the keypair"
exit 1
end
params = {
'command' => 'deleteSSHKeyPair',
'name' => keypairname,
}
json = connection.send_request(params)
unless json['success'] == 'true' then
ui.error("Unable to delete SSH Keypair")
exit 1
end
print "#{ui.color("Deleted the SSH Keypair: #{keypairname}", :magenta)}\n"
end
|