Module: ForemanMaintain
- Defined in:
- lib/foreman_maintain.rb,
lib/foreman_maintain/cli.rb,
lib/foreman_maintain/check.rb,
lib/foreman_maintain/error.rb,
lib/foreman_maintain/param.rb,
lib/foreman_maintain/config.rb,
lib/foreman_maintain/runner.rb,
lib/foreman_maintain/context.rb,
lib/foreman_maintain/feature.rb,
lib/foreman_maintain/version.rb,
lib/foreman_maintain/cli/base.rb,
lib/foreman_maintain/core_ext.rb,
lib/foreman_maintain/detector.rb,
lib/foreman_maintain/reporter.rb,
lib/foreman_maintain/scenario.rb,
lib/foreman_maintain/procedure.rb,
lib/foreman_maintain/csv_parser.rb,
lib/foreman_maintain/executable.rb,
lib/foreman_maintain/utils/bash.rb,
lib/foreman_maintain/utils/backup.rb,
lib/foreman_maintain/yaml_storage.rb,
lib/foreman_maintain/upgrade_runner.rb,
lib/foreman_maintain/concerns/hammer.rb,
lib/foreman_maintain/concerns/logger.rb,
lib/foreman_maintain/concerns/finders.rb,
lib/foreman_maintain/dependency_graph.rb,
lib/foreman_maintain/runner/execution.rb,
lib/foreman_maintain/utils/disk/stats.rb,
lib/foreman_maintain/concerns/metadata.rb,
lib/foreman_maintain/concerns/reporter.rb,
lib/foreman_maintain/utils/disk/device.rb,
lib/foreman_maintain/cli/backup_command.rb,
lib/foreman_maintain/cli/health_command.rb,
lib/foreman_maintain/cli/restore_command.rb,
lib/foreman_maintain/cli/service_command.rb,
lib/foreman_maintain/cli/upgrade_command.rb,
lib/foreman_maintain/utils/curl_response.rb,
lib/foreman_maintain/cli/advanced_command.rb,
lib/foreman_maintain/utils/command_runner.rb,
lib/foreman_maintain/utils/disk/io_device.rb,
lib/foreman_maintain/utils/system_helpers.rb,
lib/foreman_maintain/reporter/cli_reporter.rb,
lib/foreman_maintain/utils/disk/nil_device.rb,
lib/foreman_maintain/concerns/base_database.rb,
lib/foreman_maintain/concerns/system_helpers.rb,
lib/foreman_maintain/concerns/system_service.rb,
lib/foreman_maintain/runner/stored_execution.rb,
lib/foreman_maintain/concerns/scenario_metadata.rb,
lib/foreman_maintain/cli/transform_clamp_options.rb,
lib/foreman_maintain/cli/advanced/procedure_command.rb,
lib/foreman_maintain/cli/advanced/procedure/run_command.rb,
lib/foreman_maintain/cli/advanced/prebuild_bash_completion.rb,
lib/foreman_maintain/cli/advanced/procedure/by_tag_command.rb,
lib/foreman_maintain/cli/advanced/procedure/abstract_by_tag_command.rb,
lib/foreman_maintain/cli/advanced/procedure/abstract_procedure_command.rb
Defined Under Namespace
Modules: Cli, Concerns, CoreExt, Error, Utils
Classes: CSVParser, Check, Config, Context, DependencyGraph, Detector, Executable, Feature, HammerConfigurationError, Param, Procedure, Reporter, Runner, Scenario, UpgradeRunner, YamlStorage
Constant Summary
collapse
- LOGGER_LEVEL_MAPPING =
{
'debug' => ::Logger::DEBUG,
'info' => ::Logger::INFO,
'warn' => ::Logger::WARN,
'error' => ::Logger::ERROR,
'fatal' => ::Logger::FATAL,
'unknown' => ::Logger::UNKNOWN
}.freeze
- VERSION =
'0.3.1'.freeze
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
41
42
43
|
# File 'lib/foreman_maintain.rb', line 41
def config
@config
end
|
.logger ⇒ Object
Returns the value of attribute logger.
41
42
43
|
# File 'lib/foreman_maintain.rb', line 41
def logger
@logger
end
|
Class Method Details
.allowed_available_procedures(*args) ⇒ Object
113
114
115
116
|
# File 'lib/foreman_maintain.rb', line 113
def allowed_available_procedures(*args)
procedures = detector.available_procedures(*args)
procedures.select(&:advanced_run?)
end
|
.available_checks(*args) ⇒ Object
105
106
107
|
# File 'lib/foreman_maintain.rb', line 105
def available_checks(*args)
detector.available_checks(*args)
end
|
.available_features(*args) ⇒ Object
97
98
99
|
# File 'lib/foreman_maintain.rb', line 97
def available_features(*args)
detector.available_features(*args)
end
|
.available_procedures(*args) ⇒ Object
109
110
111
|
# File 'lib/foreman_maintain.rb', line 109
def available_procedures(*args)
detector.available_procedures(*args)
end
|
.available_scenarios(*args) ⇒ Object
101
102
103
|
# File 'lib/foreman_maintain.rb', line 101
def available_scenarios(*args)
detector.available_scenarios(*args)
end
|
.cache ⇒ Object
85
86
87
|
# File 'lib/foreman_maintain.rb', line 85
def cache
ObjectCache.instance
end
|
.config_file ⇒ Object
71
72
73
|
# File 'lib/foreman_maintain.rb', line 71
def config_file
config.config_file
end
|
.detector ⇒ Object
89
90
91
|
# File 'lib/foreman_maintain.rb', line 89
def detector
@detector ||= Detector.new
end
|
.init_logger ⇒ Object
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/foreman_maintain.rb', line 118
def init_logger
filename = File.expand_path("#{config.log_dir}/foreman-maintain.log")
log_fsize = config.log_file_size.to_i * 1024
@logger = Logger.new(filename, 10, log_fsize).tap do |logger|
logger.level = LOGGER_LEVEL_MAPPING[config.log_level] || Logger::DEBUG
logger.datetime_format = '%Y-%m-%d %H:%M:%S%z '
end
pickup_log_messages
end
|
.load_definitions ⇒ Object
75
76
77
78
79
80
81
82
83
|
# File 'lib/foreman_maintain.rb', line 75
def load_definitions
$LOAD_PATH.concat(config.definitions_dirs)
config.definitions_dirs.each do |definitions_dir|
file_paths = File.expand_path(File.join(definitions_dir, '**', '*.rb'))
Dir.glob(file_paths).each { |f| require f }
end
end
|
.pickup_log_messages ⇒ Object
131
132
133
134
135
|
# File 'lib/foreman_maintain.rb', line 131
def pickup_log_messages
return if config.pre_setup_log_messages.empty?
config.pre_setup_log_messages.each { |msg| logger.info msg }
config.pre_setup_log_messages.clear
end
|
.reporter ⇒ Object
93
94
95
|
# File 'lib/foreman_maintain.rb', line 93
def reporter
@reporter ||= ForemanMaintain::Reporter::CLIReporter.new
end
|
.setup(options = {}) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/foreman_maintain.rb', line 52
def setup(options = {})
self.config = Config.new(options)
load_definitions
init_logger
update_path
end
|
.storage(label = :default) ⇒ Object
137
138
139
140
141
|
# File 'lib/foreman_maintain.rb', line 137
def storage(label = :default)
ForemanMaintain::YamlStorage.load(label)
rescue StandardError => e
logger.error "Invalid Storage label i.e #{label}. Error - #{e.message}"
end
|
.update_path ⇒ Object
Appending PATH with expected paths needed for commands we run
61
62
63
64
65
66
67
68
69
|
# File 'lib/foreman_maintain.rb', line 61
def update_path
paths = ['/sbin']
existing_paths = ENV['PATH'].split(':')
paths -= existing_paths
if paths.any?
paths = paths.join(':').chomp(':')
ENV['PATH'] = "#{ENV['PATH']}:#{paths}"
end
end
|