Class: Fum::Commands::Repair

Inherits:
Fum::Command show all
Includes:
DNS
Defined in:
lib/fum/commands/repair.rb

Instance Method Summary collapse

Methods included from DNS

#dns, #dns_names_equal, #ensure_trailing_dot, #find_records, #update_zone, #update_zones

Methods inherited from Fum::Command

#initialize, #stage

Methods included from Util

#die

Constructor Details

This class inherits a constructor from Fum::Command

Instance Method Details

#execute(options) ⇒ Object

  • :type



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fum/commands/repair.rb', line 22

def execute(options)
  stage_name = options[:stage_name]
  stage_decl = stage(@application.main_decl, stage_name)

  analyzer = StageAnalyzer.new(stage_decl)

  analyzer.analyze(options)

  degraded = analyzer.env_map.each_value.select { |env| env[:state] == :degraded }

  if degraded.length == 1
    degraded = degraded.shift
    puts "Repairing environment #{degraded[:env].name}."
    update_zones(stage_decl, degraded[:env], options)
    puts "Repair complete."
  else
    puts "Nothing to repair."
  end

end

#parse_optionsObject



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

def parse_options
  opts = Trollop::options do
    banner "usage: repair [options] <stage-id>, where options are:"
    opt :environment, "Environment name to repair", :type => :string
  end
  if ARGV.empty?
    die "Please specify a stage name type to repair."
  end
  opts[:stage_name] = ARGV.shift

  opts
end