Class: ForemanMaintain::Check

Constant Summary

Constants included from ForemanMaintain::Concerns::Metadata

ForemanMaintain::Concerns::Metadata::MAX_PREPARATION_STEPS_DEPTH

Constants included from ForemanMaintain::Concerns::OsFacts

ForemanMaintain::Concerns::OsFacts::FALLBACK_OS_RELEASE_FILE, ForemanMaintain::Concerns::OsFacts::OS_RELEASE_FILE

Instance Attribute Summary collapse

Attributes inherited from Executable

#options

Instance Method Summary collapse

Methods included from ForemanMaintain::Concerns::Finders

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

Methods included from ForemanMaintain::Concerns::Metadata

#advanced_run?, #description, included, #label, #label_dashed, #metadata, #params, #preparation_steps, #run_once?, #runtime_message, #tags

Methods included from ForemanMaintain::Concerns::SystemHelpers

#check_max_version, #check_min_version, #command_present?, #directory_empty?, #execute, #execute!, #execute?, #execute_runner, #execute_with_status, #file_exists?, #file_nonzero?, #find_dir_containing_file, #find_package, #find_symlinks, #foreman_plugin_name, #format_shell_args, #hammer_package, #hammer_plugin_name, #hostname, included, #package_manager, #package_version, #packages_action, #parse_csv, #parse_json, #proxy_plugin_name, #repository_manager, #ruby_prefix, #server?, #shellescape, #systemd_installed?, #version

Methods included from ForemanMaintain::Concerns::OsFacts

#centos?, #cpu_cores, #deb_major_version, #debian?, #debian_or_ubuntu?, #el8?, #el?, #el_major_version, #el_short_name, #facts, #memory, #os_id, #os_id_like_list, #os_name, #os_release_file, #os_version, #os_version_codename, #os_version_id, #rhel?, #ubuntu?, #ubuntu_major_version

Methods included from ForemanMaintain::Concerns::Logger

#logger

Methods inherited from Executable

#abort!, #after_initialize, #ensure_instance, ensure_instance, #eql?, #executed?, #execution, #fail!, #hash, #initialize, #inspect, #matches_hash?, #necessary?, #next_steps, #say, #set_abort, #set_fail, #set_info_warn, #set_param_variable, #set_skip, #set_status, #set_warn, #setup_execution_state, #setup_params, #skip, #to_hash, #update_from_hash, #warn!

Constructor Details

This class inherits a constructor from ForemanMaintain::Executable

Instance Attribute Details

#associated_featureObject

Returns the value of attribute associated_feature.



8
9
10
# File 'lib/foreman_maintain/check.rb', line 8

def associated_feature
  @associated_feature
end

Instance Method Details

#__run__(execution) ⇒ Object

internal method called by executor



39
40
41
42
43
44
45
# File 'lib/foreman_maintain/check.rb', line 39

def __run__(execution)
  super
rescue Error::Fail => e
  set_fail(e.message)
rescue Error::Warn => e
  set_warn(e.message)
end

#assert(condition, error_message, options = {}) ⇒ Object

run condition and mark the check as failed when not passing

Options

  • +:next_steps* - one or more procedures that can be followed to address

    the failure, will be offered to the user when running
    in interactive mode
    
  • +:warn* - issue warning instead of failure: this is less strict check,

    that could be considered as non-critical for continuing with the scenario
    


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/foreman_maintain/check.rb', line 20

def assert(condition, error_message, options = {})
  options = options.validate_options!(:next_steps, :warn)
  unless condition
    next_steps = Array(options.fetch(:next_steps, []))
    self.next_steps.concat(next_steps)
    if options[:warn]
      warn!(error_message)
    else
      fail!(error_message)
    end
  end
end

#runObject

public method to be overriden

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/foreman_maintain/check.rb', line 34

def run
  raise NotImplementedError
end