Class: Kafo::KafoConfigure
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#dashize, #parametrize, #underscore, #with_prefix
Constructor Details
Returns a new instance of KafoConfigure.
[View source]
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/kafo/kafo_configure.rb', line 101
def initialize(*args)
self.class.preset_color_scheme
self.class.logger = Logger.new
self.class.exit_handler = ExitHandler.new
@progress_bar = nil
@config_reload_requested = false
scenario_manager = setup_scenario_manager
self.class.scenario_manager = scenario_manager
scenario_manager.list_available_scenarios if ARGV.include?('--list-scenarios')
scenario_manager.check_enable_scenario
scenario_manager.check_disable_scenario
setup_config(config_file)
self.class.hooking.execute(:pre_migrations)
reload_config
applied_total = self.class.config.run_migrations
request_config_reload if applied_total > 0
if ARGV.include?('--migrations-only')
verbose = ARGV.include?('--verbose') || ARGV.include?('-v')
Logging.setup(verbose: verbose)
self.class.logger.notice('Log buffers flushed')
self.class.exit(0)
end
reload_config
if scenario_manager.configured?
scenario_manager.check_scenario_change(self.class.config_file)
if scenario_manager.scenario_changed?(self.class.config_file) && !self.class.in_help_mode?
prev_config = scenario_manager.load_configuration(scenario_manager.previous_scenario)
prev_config.run_migrations
self.class.config.migrate_configuration(prev_config, :skip => [:log_name])
setup_config(self.class.config_file)
self.class.logger.notice("Due to scenario change the configuration (#{self.class.config_file}) was updated with #{scenario_manager.previous_scenario} and reloaded.")
end
end
super
self.class.hooking.execute(:boot)
set_app_options parse clamp_app_arguments
parse_app_arguments
if ARGV.any? { |option| ['--help', '--full-help'].include? option }
Logging.setup_verbose(level: :error)
else
Logging.setup(verbose: config.app[:verbose])
end
logger.notice("Loading installer configuration. This will take some time.")
self.class.set_color_scheme
self.class.hooking.execute(:init)
set_parameters set_options
end
|
Class Attribute Details
permalink
.check_dirs ⇒ Object
Returns the value of attribute check_dirs.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def check_dirs
@check_dirs
end
|
Returns the value of attribute config.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def config
@config
end
|
permalink
.config_file ⇒ Object
Returns the value of attribute config_file.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def config_file
@config_file
end
|
permalink
.exit_handler ⇒ Object
Returns the value of attribute exit_handler.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def exit_handler
@exit_handler
end
|
permalink
.gem_root ⇒ Object
Returns the value of attribute gem_root.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def gem_root
@gem_root
end
|
49
50
51
|
# File 'lib/kafo/kafo_configure.rb', line 49
def hooking
@hooking ||= Hooking.new
end
|
permalink
.kafo_modules_dir ⇒ Object
Returns the value of attribute kafo_modules_dir.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def kafo_modules_dir
@kafo_modules_dir
end
|
Returns the value of attribute logger.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def logger
@logger
end
|
permalink
.module_dirs ⇒ Object
Returns the value of attribute module_dirs.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def module_dirs
@module_dirs
end
|
permalink
.root_dir ⇒ Object
Returns the value of attribute root_dir.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def root_dir
@root_dir
end
|
permalink
.scenario_manager ⇒ Object
Returns the value of attribute scenario_manager.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def scenario_manager
@scenario_manager
end
|
Returns the value of attribute store.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def store
@store
end
|
Returns the value of attribute verbose.
44
45
46
|
# File 'lib/kafo/kafo_configure.rb', line 44
def verbose
@verbose
end
|
Instance Attribute Details
permalink
#puppet_report ⇒ Object
Returns the value of attribute puppet_report.
39
40
41
|
# File 'lib/kafo/kafo_configure.rb', line 39
def puppet_report
@puppet_report
end
|
Class Method Details
permalink
.exit(code, &block) ⇒ Object
[View source]
59
60
61
|
# File 'lib/kafo/kafo_configure.rb', line 59
def exit(code, &block)
exit_handler.exit(code, &block)
end
|
permalink
.exit_code ⇒ Object
[View source]
63
64
65
|
# File 'lib/kafo/kafo_configure.rb', line 63
def exit_code
self.exit_handler.exit_code
end
|
permalink
.in_help_mode? ⇒ Boolean
[View source]
67
68
69
|
# File 'lib/kafo/kafo_configure.rb', line 67
def in_help_mode?
ARGV.include?('--help') || ARGV.include?('--full-help') || ARGV.include?('-h')
end
|
permalink
.preset_color_scheme ⇒ Object
[View source]
88
89
90
91
92
|
# File 'lib/kafo/kafo_configure.rb', line 88
def preset_color_scheme
match = ARGV.join(' ').match(/--color-of-background[ =](\w+)/)
background = match && match[1]
ColorScheme.new(:background => background, :colors => use_colors?).setup
end
|
[View source]
53
54
55
56
57
|
# File 'lib/kafo/kafo_configure.rb', line 53
def run
return super
rescue SystemExit
self.exit_handler.exit(self.exit_code) end
|
permalink
.set_color_scheme ⇒ Object
[View source]
94
95
96
97
98
|
# File 'lib/kafo/kafo_configure.rb', line 94
def set_color_scheme
ColorScheme.new(
:background => config.app[:color_of_background],
:colors => use_colors?).setup
end
|
permalink
.use_colors? ⇒ Boolean
[View source]
78
79
80
81
82
83
84
85
86
|
# File 'lib/kafo/kafo_configure.rb', line 78
def use_colors?
if config
colors = config.app[:colors]
else
colors = ARGV.include?('--no-colors') ? false : nil
colors = ARGV.include?('--colors') ? true : nil if colors.nil?
end
colors
end
|
Instance Method Details
permalink
#add_module(name) ⇒ Object
[View source]
255
256
257
258
259
|
# File 'lib/kafo/kafo_configure.rb', line 255
def add_module(name)
config.add_module(name)
reset_params_cache
self.module(name)
end
|
[View source]
165
166
167
|
# File 'lib/kafo/kafo_configure.rb', line 165
def config
self.class.config
end
|
permalink
#enabled_params ⇒ Object
[View source]
246
247
248
|
# File 'lib/kafo/kafo_configure.rb', line 246
def enabled_params
params.select { |p| p.module.enabled? }
end
|
[View source]
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# File 'lib/kafo/kafo_configure.rb', line 189
def execute
parse_cli_arguments
if !config.app[:verbose]
@progress_bar = config.app[:colors] ? ProgressBars::Colored.new : ProgressBars::BlackWhite.new
end
if checks_only? || !skip_checks_i_know_better?
logger = Logger.new('checks')
if SystemChecker.check
logger.notice("System checks passed")
else
logger.error("Your system does not meet configuration criteria")
self.class.exit(:invalid_system)
end
end
self.class.exit(0) if checks_only?
self.class.hooking.execute(:pre_validations)
if interactive?
wizard = Wizard.new(self)
wizard.run
else
unless validate_all
puts "Error during configuration, exiting"
self.class.exit(:invalid_values)
end
end
self.class.hooking.execute(:pre_commit)
unless dont_save_answers? || noop?
config.configure_application
store_params
self.class.scenario_manager.link_last_scenario(self.class.config_file) if self.class.scenario_manager.configured?
end
run_installation
return self
rescue SystemExit
return self
end
|
permalink
#exit_code ⇒ Object
[View source]
231
232
233
|
# File 'lib/kafo/kafo_configure.rb', line 231
def exit_code
self.class.exit_code
end
|
[View source]
235
236
237
|
# File 'lib/kafo/kafo_configure.rb', line 235
def help
self.class.help(invocation_path, self)
end
|
[View source]
173
174
175
|
# File 'lib/kafo/kafo_configure.rb', line 173
def logger
self.class.logger
end
|
permalink
#module(name) ⇒ Object
[View source]
265
266
267
|
# File 'lib/kafo/kafo_configure.rb', line 265
def module(name)
modules.detect { |m| m.name == name }
end
|
[View source]
261
262
263
|
# File 'lib/kafo/kafo_configure.rb', line 261
def modules
config.modules.sort
end
|
permalink
#param(mod, name) ⇒ Object
[View source]
269
270
271
|
# File 'lib/kafo/kafo_configure.rb', line 269
def param(mod, name)
config.param(mod, name)
end
|
[View source]
239
240
241
242
243
244
|
# File 'lib/kafo/kafo_configure.rb', line 239
def params
@params ||= modules.map(&:params).flatten
rescue KafoParsers::ModuleName => e
puts e
self.class.exit(:unknown_module)
end
|
permalink
#request_config_reload ⇒ Object
[View source]
273
274
275
|
# File 'lib/kafo/kafo_configure.rb', line 273
def request_config_reload
@config_reload_requested = true
end
|
permalink
#reset_params_cache ⇒ Object
[View source]
250
251
252
253
|
# File 'lib/kafo/kafo_configure.rb', line 250
def reset_params_cache
@params = nil
params
end
|
permalink
#run(*args) ⇒ Object
[View source]
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/kafo/kafo_configure.rb', line 177
def run(*args)
started_at = Time.now
logger.debug("Running installer with args #{args.inspect}")
if config.app[:verbose]
logger.notice("Running installer with log based terminal output at level #{config.app[:verbose_log_level].upcase}.")
logger.notice("Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.")
end
super
ensure
logger.debug("Installer finished in #{Time.now - started_at} seconds")
end
|
[View source]
169
170
171
|
# File 'lib/kafo/kafo_configure.rb', line 169
def store
self.class.store
end
|