Class: ForemanMaintain::Cli::UpgradeCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/foreman_maintain/cli/upgrade_command.rb

Instance Attribute Summary

Attributes inherited from Base

#runner

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#available_checks, #available_procedures, available_tags, #available_tags, completion_map, completion_types, dashize, #dashize, delete_duplicate_assumeyes_if_any, interactive_option, label_option, #label_string, option, #option_wrapper, parameter, #print_check_info, #reporter, #run_scenario, #run_scenarios_and_exit, service_options, subcommand, #tag_string, tags_option, #underscorize

Methods included from ForemanMaintain::Concerns::Logger

#logger

Methods included from ForemanMaintain::Concerns::Finders

#check, #detector, #feature, #find_all_scenarios, #find_procedures, #find_scenarios, #procedure

Class Method Details

.disable_self_upgrade_optionObject



4
5
6
7
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 4

def self.disable_self_upgrade_option
  option '--disable-self-upgrade', :flag, 'Disable automatic self upgrade',
    :default => false
end

Instance Method Details

#allow_self_upgrade?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 17

def allow_self_upgrade?
  !disable_self_upgrade?
end

#try_upgradeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 21

def try_upgrade
  if upgrade_runner.available?
    yield
  else
    instance = ForemanMaintain.detector.feature(:instance)
    msg = <<~BANNER

      There are no upgrades available.
      The current version of #{instance.product_name} is #{instance.current_major_version}.
      Consider using the update command.
    BANNER

    puts msg
    ForemanMaintain::UpgradeRunner::WARNING_EXIT_CODE
  end
end

#upgrade_runnerObject



9
10
11
12
13
14
15
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 9

def upgrade_runner
  return @upgrade_runner if defined? @upgrade_runner
  @upgrade_runner = ForemanMaintain::UpgradeRunner.new(reporter,
    :assumeyes => assumeyes?,
    :whitelist => whitelist || [],
    :force => force?).tap(&:load)
end