Class: Management::Server::Destroy

Inherits:
Command
  • Object
show all
Includes:
Helper
Defined in:
lib/management/commands/server/destroy.rb

Instance Method Summary collapse

Methods included from Helper

#cloud, #config, #get_address, #get_env, #get_script, #get_server, #get_type, #live_servers, #system_verbose

Methods inherited from Command

all, #arg_list, #call_with, #command_name, #fn, #help_string, inherited, maxlen, #true_arity

Instance Method Details

#run(*server_names) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/management/commands/server/destroy.rb', line 11

def run(*server_names)
  servers = server_names.map{|server_name| get_server(server_name)}

  puts "You are about to delete the following servers:"
  puts ['', *servers.map{ |server| " - #{server.name}" }, '', ''].join("\n")

  print "Are you sure you want to do this? Type 'Yes' to continue, or anything else to abort: "
  abort "Aborted." if $stdin.gets.chomp != 'Yes'

  servers.each do |server|
    puts "Destroying #{server.name}..."
    server.destroy
    puts "Done."
  end
end