Class: Chef::Knife::CloudstackServerDestroy
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::CloudstackServerDestroy
- Includes:
- CloudstackBase
- Defined in:
- lib/chef/knife/cloudstack_server_destroy.rb
Instance Method Summary collapse
Methods included from CloudstackBase
#connection, included, #locate_config_value, #msg_pair, #validate!
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/chef/knife/cloudstack_server_destroy.rb', line 28 def run if @name_args.nil? || @name_args.empty? puts "#{ui.color("Please provide an Instance ID.", :red)}" end @name_args.each do |instance_id| response = connection.list_virtual_machines('name' => instance_id) instance_name = response['listvirtualmachinesresponse']['virtualmachine'].first['name'] instance_ip = response['listvirtualmachinesresponse']['virtualmachine'].first['nic'].first['ipaddress'] real_instance_id = response['listvirtualmachinesresponse']['virtualmachine'].first['id'] puts "#{ui.color("Name", :red)}: #{instance_name}" puts "#{ui.color("Public IP", :red)}: #{instance_ip}" puts "\n" confirm("#{ui.color("Do you really want to destroy this server", :red)}") connection.destroy_virtual_machine(instance_id) ui.warn("Destroyed server #{instance_name}") end end |