Class: ForemanMaintain::Cli::UpgradeCommand
- Inherits:
-
Base
- Object
- Clamp::Command
- Base
- ForemanMaintain::Cli::UpgradeCommand
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, #dashize, dashize, interactive_option, label_option, #label_string, option, #print_check_info, #reporter, #run_scenario, #tag_string, tags_option, #underscorize
#check, #detector, #feature, #find_all_scenarios, #find_checks, #find_procedures, #find_scenarios, #procedure
Class Method Details
.target_version_option ⇒ Object
4
5
6
7
|
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 4
def self.target_version_option
option '--target-version', 'TARGET_VERSION', 'Target version of the upgrade',
:required => false
end
|
Instance Method Details
#current_target_version ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 9
def current_target_version
current_target_version = ForemanMaintain::UpgradeRunner.current_target_version
if current_target_version && target_version && target_version != current_target_version
raise Error::UsageError,
"Can't set target version #{target_version}, "\
"#{current_target_version} already in progress"
end
@target_version = current_target_version if current_target_version
return true if current_target_version
end
|
#print_versions(target_versions) ⇒ Object
46
47
48
|
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 46
def print_versions(target_versions)
target_versions.sort.each { |version| puts version }
end
|
#upgrade_runner ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 37
def upgrade_runner
return @upgrade_runner if defined? @upgrade_runner
validate_target_version!
@upgrade_runner = ForemanMaintain::UpgradeRunner.new(target_version, reporter,
:assumeyes => assumeyes?,
:whitelist => whitelist || [],
:force => force?).tap(&:load)
end
|
#validate_target_version! ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/foreman_maintain/cli/upgrade_command.rb', line 20
def validate_target_version!
return if current_target_version
unless UpgradeRunner.available_targets.include?(target_version)
message_start = if target_version
"Can't upgrade to #{target_version}"
else
'--target-version not specified'
end
message = <<-MESSAGE.strip_heredoc
#{message_start}
Possible target versions are:
MESSAGE
versions = UpgradeRunner.available_targets.join("\n")
raise Error::UsageError, message + versions
end
end
|