Class: ForemanMaintain::Cli::UpdateCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/foreman_maintain/cli/update_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_update_optionObject



6
7
8
9
# File 'lib/foreman_maintain/cli/update_command.rb', line 6

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

Instance Method Details

#try_updateObject



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

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

      This version of #{ForemanMaintain.command_name} only supports #{instance.target_version},
      but the installed version of #{instance.product_name} is #{instance.current_major_version}.

      Therefore the update command is not available right now.

      Please install a version of #{ForemanMaintain.command_name} that supports #{instance.current_major_version}
      or perform an upgrade to #{instance.target_version} using the upgrade command.
    BANNER

    puts msg
    ForemanMaintain::UpdateRunner::WARNING_EXIT_CODE
  end
end

#update_runnerObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/foreman_maintain/cli/update_command.rb', line 11

def update_runner
  update_runner = ForemanMaintain::UpdateRunner.new(
    reporter,
    :assumeyes => assumeyes?,
    :whitelist => whitelist || [],
    :force => force?
  )
  update_runner.load
  update_runner
end