Class: Chef::Knife::EucaServerDelete

Inherits:
Chef::Knife show all
Includes:
EucaBase
Defined in:
lib/chef/knife/euca_server_delete.rb

Instance Method Summary collapse

Methods included from EucaBase

#connection, included, #locate_config_value, #public_ip

Instance Method Details

#msg(label, value) ⇒ Object



51
52
53
54
55
# File 'lib/chef/knife/euca_server_delete.rb', line 51

def msg(label, value)
  if value && !value.empty?
    puts "#{ui.color(label, :cyan)}: #{value}"
  end
end

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chef/knife/euca_server_delete.rb', line 29

def run
  @name_args.each do |instance_id|
    server = connection.servers.get(instance_id)

    msg("Instance ID", server.id)
    msg("Flavor", server.flavor_id)
    msg("Image", server.image_id)
    msg("Availability Zone", server.availability_zone)
    msg("Security Groups", server.groups.join(", "))
    msg("SSH Key", server.key_name)
    msg("Public DNS Name", server.dns_name)
    msg("Private DNS Name", server.private_dns_name)

    puts "\n"
    confirm("Do you really want to delete this server")

    server.destroy

    ui.warn("Deleted server #{server.id}")
  end
end