Class: Befog::Commands::Remove
- Inherits:
-
Object
- Object
- Befog::Commands::Remove
- Includes:
- Mixins::Command, Mixins::Configurable, Mixins::Help, Mixins::Safely, Mixins::Scope, Mixins::Selectable
- Defined in:
- lib/befog/commands/remove.rb
Instance Attribute Summary
Attributes included from Mixins::Command
Instance Method Summary collapse
Methods included from Mixins::Help
Methods included from Mixins::Selectable
Methods included from Mixins::Safely
Methods included from Mixins::Scope
#_bank, #account_key, #account_secret, #bank, #bank?, #bank_name, #banks, #compute, #flavor, #flavor?, #get_server, #image, #image?, #keypair, #keypair?, #price, #provider, #provider?, #provider_name, #providers, #region, #region?, #security_group, #security_group?, #servers, #servers=
Methods included from Mixins::Configurable
#_configuration, #configuration, #configuration_name, #configuration_path, included, #save
Methods included from Mixins::Command
#command, #error, included, #initialize, #log, #process_options, #usage
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/befog/commands/remove.rb', line 33 def run count = 0 ; threads = [] ; deleted = [] unless [:all] count = [:count].to_i if count <= 0 error "Count must be an integer greater than 0." end end run_for_selected do |id| if [:all] or count > 0 # threads << Thread.new do safely do log "Deprovisioning server #{id} ..." compute.servers.get(id).destroy deleted << id count -= 1 end # end end end $stdout.print "This may take a few minutes .." # sleep 1 while threads.any? { |t| $stdout.print "."; $stdout.flush ; t.alive? } $stdout.print "\n" self.servers -= deleted save end |