Class: Hotdog::Commands::Up
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Hotdog::Commands::Up
- Defined in:
- lib/hotdog/commands/up.rb
Constant Summary
Constants inherited from BaseCommand
BaseCommand::MASK_DATABASE, BaseCommand::MASK_QUERY, BaseCommand::PERSISTENT_DB
Instance Attribute Summary
Attributes inherited from BaseCommand
#application, #logger, #options
Instance Method Summary collapse
Methods inherited from BaseCommand
#execute, #fixed_string?, #initialize, #parse_options, #reload
Constructor Details
This class inherits a constructor from Hotdog::Commands::BaseCommand
Instance Method Details
#define_options(optparse, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/hotdog/commands/up.rb', line 8 def (optparse, ={}) default_option(, :retry, 5) optparse.on("--retry NUM") do |v| [:retry] = v.to_i end optparse.on("--retry-delay SECONDS") do |v| [:retry_delay] = v.to_i end end |
#run(args = [], options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hotdog/commands/up.rb', line 18 def run(args=[], ={}) scopes = args.map { |arg| if arg.index(":").nil? "host:#{arg}" else arg end } all_downtimes = nil with_retry() do all_downtimes = get_all_downtimes() end cancel_downtimes = all_downtimes.select { |downtime| downtime["active"] and downtime["id"] and scopes.map { |scope| downtime.fetch("scope", []).include?(scope) }.any? } cancel_downtimes.each do |downtime| with_retry() do cancel_downtime(downtime["id"], ) end end hosts = scopes.select { |scope| scope.start_with?("host:") }.map { |scope| scope.slice("host:".length, scope.length) } if 0 < hosts.length # refresh all persistent.db to retrieve information about up'd host remove_db(@db) end end |