Class: TidyCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/dew/commands/tidy.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



30
31
32
33
34
# File 'lib/dew/commands/tidy.rb', line 30

def execute
  Inform.warning("--noop passed, no changes will be made!") if noop?
  tidy_environments if clean_environments?
  tidy_amis if clean_amis?
end

#tidy_amisObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/dew/commands/tidy.rb', line 19

def tidy_amis
  Inform.info("Tidying up AMIS...")
  amis = Cloud.compute.images.all
  amis = amis.select {|a| a.name =~ /^cuke-/}
  amis.each do |ami|
    Inform.info("Destroying ami #{ami.name}") do
      ami.deregister unless noop?
    end
  end
end

#tidy_environmentsObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dew/commands/tidy.rb', line 7

def tidy_environments
  Inform.info("Tidying up Environments...")
  names = Cloud.valid_servers.collect(&:tags).collect { |h| h['Environment'] if h['Environment'] }
  names << Cloud.rds.servers.all.select {|a| a.state == 'available'}.map(&:id)
  names = names.flatten.uniq
  names = names.grep /^cuke-/
  names.each do |name|
    Inform.info("Destroying environment #{name}")
    Environment.get(name).destroy unless noop?
  end
end