foreman_maintain 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/definitions/checks/foreman_tasks/not_paused.rb +1 -1
- data/definitions/checks/foreman_tasks/not_running.rb +1 -1
- data/definitions/features/downstream.rb +4 -9
- data/definitions/procedures/foreman_tasks/delete.rb +1 -1
- data/definitions/procedures/foreman_tasks/resume.rb +1 -1
- data/definitions/procedures/foreman_tasks/ui_investigate.rb +1 -1
- data/definitions/procedures/hammer_setup.rb +1 -1
- data/definitions/procedures/maintenance_mode/disable.rb +1 -1
- data/definitions/procedures/maintenance_mode/enable.rb +1 -1
- data/definitions/scenarios/upgrade_to_satellite_6_2.rb +5 -5
- data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +5 -5
- data/definitions/scenarios/upgrade_to_satellite_6_3.rb +5 -5
- data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +5 -5
- data/lib/foreman_maintain.rb +1 -1
- data/lib/foreman_maintain/cli.rb +31 -8
- data/lib/foreman_maintain/cli/advanced/procedure/abstract_by_tag_command.rb +11 -2
- data/lib/foreman_maintain/cli/advanced/procedure/abstract_procedure_command.rb +1 -0
- data/lib/foreman_maintain/cli/advanced/procedure/by_tag_command.rb +1 -1
- data/lib/foreman_maintain/cli/base.rb +8 -4
- data/lib/foreman_maintain/cli/health_command.rb +1 -0
- data/lib/foreman_maintain/cli/transform_clamp_options.rb +2 -1
- data/lib/foreman_maintain/cli/upgrade_command.rb +12 -0
- data/lib/foreman_maintain/concerns/metadata.rb +1 -1
- data/lib/foreman_maintain/reporter/cli_reporter.rb +7 -6
- data/lib/foreman_maintain/runner.rb +12 -5
- data/lib/foreman_maintain/upgrade_runner.rb +25 -2
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain/yaml_storage.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7df7b95f8a1a9903c19af1e5b49ccfa40008e73
|
4
|
+
data.tar.gz: 70e9f58bfac04116906fb43b19b37c1cd93dc1df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0aa83732512f0daa0d549d805c5ad354df123ac54731e7650912f928bde6ab7ef82a9c59e15da33df4dbf2f3e40ef5a68ebee3e5d028e3290a23c7f7d7a0a2a
|
7
|
+
data.tar.gz: 6b311731eff01767e2aac5ed8cccd45e9e49f019b292e7bde6b59a28300816426f2dcd260549dfe5a716104d5076eda0873562d0ae7483686f015ad563305224
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Foreman Maintenance [![Build Status](https://travis-ci.org/theforeman/foreman_maintain.svg?branch=master)](https://travis-ci.org/theforeman/foreman_maintain)
|
1
|
+
# Foreman Maintenance [![Build Status](https://travis-ci.org/theforeman/foreman_maintain.svg?branch=master)](https://travis-ci.org/theforeman/foreman_maintain) <a href="https://codeclimate.com/github/theforeman/foreman_maintain"><img src="https://codeclimate.com/github/theforeman/foreman_maintain/badges/gpa.svg" /></a>
|
2
2
|
|
3
3
|
`foreman_maintain` aims to provide various features that helps keeping the
|
4
4
|
Foreman/Satellite up and running. It supports multiple versions and subparts
|
@@ -347,6 +347,14 @@ foreman-maintain console
|
|
347
347
|
foreman-maintain config
|
348
348
|
```
|
349
349
|
|
350
|
+
## How to contribute?
|
351
|
+
|
352
|
+
Generally, follow the [Foreman guidelines](https://theforeman.org/contribute.html). For code-related contributions, fork this project and send a pull request with all changes. Some things to keep in mind:
|
353
|
+
* [Follow the rules](https://theforeman.org/contribute.html#SubmitPatches) about commit message style and create a [Redmine issue](http://projects.theforeman.org/projects/foreman-maintain/issues/new). Doing this right will help reviewers to get your contribution merged faster.
|
354
|
+
* We have a [development handbook](https://theforeman.org/handbook.html) to help developers understand how Foreman developers code.
|
355
|
+
* All of our pull requests run the full test suite in our [Travis CI system](https://travis-ci.org/theforeman/foreman_maintain). Please include tests in your pull requests for any additions or changes in functionality
|
356
|
+
|
357
|
+
|
350
358
|
## License
|
351
359
|
|
352
360
|
This project is licensed under the GPLv3+
|
@@ -2,7 +2,7 @@ module Checks::ForemanTasks
|
|
2
2
|
class NotRunning < ForemanMaintain::Check
|
3
3
|
metadata do
|
4
4
|
for_feature :foreman_tasks
|
5
|
-
description '
|
5
|
+
description 'Check for running tasks'
|
6
6
|
tags :pre_upgrade
|
7
7
|
after :foreman_tasks_not_paused
|
8
8
|
before :check_old_foreman_tasks
|
@@ -33,15 +33,10 @@ class Features::Downstream < ForemanMaintain::Feature
|
|
33
33
|
|
34
34
|
def rh_repos(sat_version)
|
35
35
|
sat_version = version(sat_version)
|
36
|
-
|
37
|
-
|
38
|
-
"rhel
|
39
|
-
|
40
|
-
|
41
|
-
def rh_version
|
42
|
-
return @rh_version if defined? @rh_version
|
43
|
-
release_package = execute!('rpm -qf /etc/redhat-release')
|
44
|
-
@rh_version = rpm_version(release_package, 'RELEASE')
|
36
|
+
rh_version_major = execute!('facter operatingsystemmajrelease')
|
37
|
+
["rhel-#{rh_version_major}-server-rpms",
|
38
|
+
"rhel-server-rhscl-#{rh_version_major}-rpms",
|
39
|
+
"rhel-#{rh_version_major}-server-satellite-#{sat_version.major}.#{sat_version.minor}-rpms"]
|
45
40
|
end
|
46
41
|
|
47
42
|
def version_from_source
|
@@ -13,7 +13,7 @@ module Scenarios::Satellite_6_2
|
|
13
13
|
|
14
14
|
class PreUpgradeCheck < Abstract
|
15
15
|
upgrade_metadata do
|
16
|
-
description '
|
16
|
+
description 'Checks before upgrading to Satellite 6.2'
|
17
17
|
tags :pre_upgrade_checks
|
18
18
|
run_strategy :fail_slow
|
19
19
|
end
|
@@ -26,7 +26,7 @@ module Scenarios::Satellite_6_2
|
|
26
26
|
|
27
27
|
class PreMigrations < Abstract
|
28
28
|
upgrade_metadata do
|
29
|
-
description '
|
29
|
+
description 'Procedures before migrating to Satellite 6.2'
|
30
30
|
tags :pre_migrations
|
31
31
|
end
|
32
32
|
|
@@ -37,7 +37,7 @@ module Scenarios::Satellite_6_2
|
|
37
37
|
|
38
38
|
class Migrations < Abstract
|
39
39
|
upgrade_metadata do
|
40
|
-
description '
|
40
|
+
description 'Migration scripts to Satellite 6.2'
|
41
41
|
tags :migrations
|
42
42
|
end
|
43
43
|
|
@@ -50,7 +50,7 @@ module Scenarios::Satellite_6_2
|
|
50
50
|
|
51
51
|
class PostMigrations < Abstract
|
52
52
|
upgrade_metadata do
|
53
|
-
description '
|
53
|
+
description 'Procedures after migrating to Satellite 6.2'
|
54
54
|
tags :post_migrations
|
55
55
|
end
|
56
56
|
|
@@ -61,7 +61,7 @@ module Scenarios::Satellite_6_2
|
|
61
61
|
|
62
62
|
class PostUpgradeChecks < Abstract
|
63
63
|
upgrade_metadata do
|
64
|
-
description '
|
64
|
+
description 'Checks after upgrading to Satellite 6.2'
|
65
65
|
tags :post_upgrade_checks
|
66
66
|
run_strategy :fail_slow
|
67
67
|
end
|
@@ -13,7 +13,7 @@ module Scenarios::Satellite_6_2_z
|
|
13
13
|
|
14
14
|
class PreUpgradeCheck < Abstract
|
15
15
|
upgrade_metadata do
|
16
|
-
description '
|
16
|
+
description 'Checks before upgrading to Satellite 6.2.z'
|
17
17
|
tags :pre_upgrade_checks
|
18
18
|
run_strategy :fail_slow
|
19
19
|
end
|
@@ -26,7 +26,7 @@ module Scenarios::Satellite_6_2_z
|
|
26
26
|
|
27
27
|
class PreMigrations < Abstract
|
28
28
|
upgrade_metadata do
|
29
|
-
description '
|
29
|
+
description 'Procedures before migrating to Satellite 6.2.z'
|
30
30
|
tags :pre_migrations
|
31
31
|
end
|
32
32
|
|
@@ -37,7 +37,7 @@ module Scenarios::Satellite_6_2_z
|
|
37
37
|
|
38
38
|
class Migrations < Abstract
|
39
39
|
upgrade_metadata do
|
40
|
-
description '
|
40
|
+
description 'Migration scripts to Satellite 6.2.z'
|
41
41
|
tags :migrations
|
42
42
|
end
|
43
43
|
|
@@ -49,7 +49,7 @@ module Scenarios::Satellite_6_2_z
|
|
49
49
|
|
50
50
|
class PostMigrations < Abstract
|
51
51
|
upgrade_metadata do
|
52
|
-
description '
|
52
|
+
description 'Procedures after migrating to Satellite 6.2.z'
|
53
53
|
tags :post_migrations
|
54
54
|
end
|
55
55
|
|
@@ -60,7 +60,7 @@ module Scenarios::Satellite_6_2_z
|
|
60
60
|
|
61
61
|
class PostUpgradeChecks < Abstract
|
62
62
|
upgrade_metadata do
|
63
|
-
description '
|
63
|
+
description 'Checks after upgrading to Satellite 6.2.z'
|
64
64
|
tags :post_upgrade_checks
|
65
65
|
run_strategy :fail_slow
|
66
66
|
end
|
@@ -13,7 +13,7 @@ module Scenarios::Satellite_6_3
|
|
13
13
|
|
14
14
|
class PreUpgradeCheck < Abstract
|
15
15
|
upgrade_metadata do
|
16
|
-
description '
|
16
|
+
description 'Checks before upgrading to Satellite 6.3'
|
17
17
|
tags :pre_upgrade_checks
|
18
18
|
run_strategy :fail_slow
|
19
19
|
end
|
@@ -26,7 +26,7 @@ module Scenarios::Satellite_6_3
|
|
26
26
|
|
27
27
|
class PreMigrations < Abstract
|
28
28
|
upgrade_metadata do
|
29
|
-
description '
|
29
|
+
description 'Procedures before migrating to Satellite 6.3'
|
30
30
|
tags :pre_migrations
|
31
31
|
end
|
32
32
|
|
@@ -37,7 +37,7 @@ module Scenarios::Satellite_6_3
|
|
37
37
|
|
38
38
|
class Migrations < Abstract
|
39
39
|
upgrade_metadata do
|
40
|
-
description '
|
40
|
+
description 'Migration scripts to Satellite 6.3'
|
41
41
|
tags :migrations
|
42
42
|
end
|
43
43
|
|
@@ -50,7 +50,7 @@ module Scenarios::Satellite_6_3
|
|
50
50
|
|
51
51
|
class PostMigrations < Abstract
|
52
52
|
upgrade_metadata do
|
53
|
-
description '
|
53
|
+
description 'Procedures after migrating to Satellite 6.3'
|
54
54
|
tags :post_migrations
|
55
55
|
end
|
56
56
|
|
@@ -61,7 +61,7 @@ module Scenarios::Satellite_6_3
|
|
61
61
|
|
62
62
|
class PostUpgradeChecks < Abstract
|
63
63
|
upgrade_metadata do
|
64
|
-
description '
|
64
|
+
description 'Checks after upgrading to Satellite 6.3'
|
65
65
|
tags :post_upgrade_checks
|
66
66
|
run_strategy :fail_slow
|
67
67
|
end
|
@@ -13,7 +13,7 @@ module Scenarios::Satellite_6_3_z
|
|
13
13
|
|
14
14
|
class PreUpgradeCheck < Abstract
|
15
15
|
upgrade_metadata do
|
16
|
-
description '
|
16
|
+
description 'Checks before upgrading to Satellite 6.3.z'
|
17
17
|
tags :pre_upgrade_checks
|
18
18
|
run_strategy :fail_slow
|
19
19
|
end
|
@@ -26,7 +26,7 @@ module Scenarios::Satellite_6_3_z
|
|
26
26
|
|
27
27
|
class PreMigrations < Abstract
|
28
28
|
upgrade_metadata do
|
29
|
-
description '
|
29
|
+
description 'Procedures before migrating to Satellite 6.3.z'
|
30
30
|
tags :pre_migrations
|
31
31
|
end
|
32
32
|
|
@@ -37,7 +37,7 @@ module Scenarios::Satellite_6_3_z
|
|
37
37
|
|
38
38
|
class Migrations < Abstract
|
39
39
|
upgrade_metadata do
|
40
|
-
description '
|
40
|
+
description 'Migration scripts to Satellite 6.3.z'
|
41
41
|
tags :migrations
|
42
42
|
end
|
43
43
|
|
@@ -49,7 +49,7 @@ module Scenarios::Satellite_6_3_z
|
|
49
49
|
|
50
50
|
class PostMigrations < Abstract
|
51
51
|
upgrade_metadata do
|
52
|
-
description '
|
52
|
+
description 'Procedures after migrating to Satellite 6.3.z'
|
53
53
|
tags :post_migrations
|
54
54
|
end
|
55
55
|
|
@@ -60,7 +60,7 @@ module Scenarios::Satellite_6_3_z
|
|
60
60
|
|
61
61
|
class PostUpgradeChecks < Abstract
|
62
62
|
upgrade_metadata do
|
63
|
-
description '
|
63
|
+
description 'Checks after upgrading to Satellite 6.3.z'
|
64
64
|
tags :post_upgrade_checks
|
65
65
|
run_strategy :fail_slow
|
66
66
|
end
|
data/lib/foreman_maintain.rb
CHANGED
@@ -108,7 +108,7 @@ module ForemanMaintain
|
|
108
108
|
config.pre_setup_log_messages.clear
|
109
109
|
end
|
110
110
|
|
111
|
-
def storage(label)
|
111
|
+
def storage(label = :default)
|
112
112
|
ForemanMaintain::YamlStorage.load(label)
|
113
113
|
rescue => e
|
114
114
|
logger.error "Invalid Storage label i.e #{label}. Error - #{e.message}"
|
data/lib/foreman_maintain/cli.rb
CHANGED
@@ -19,19 +19,42 @@ module ForemanMaintain
|
|
19
19
|
logger.info("Running foreman-maintain command with arguments #{arguments.inspect}")
|
20
20
|
begin
|
21
21
|
super
|
22
|
-
exit_code = 0
|
22
|
+
@exit_code = 0
|
23
|
+
rescue Error::UsageError => e
|
24
|
+
process_usage_error(e)
|
23
25
|
rescue StandardError => e
|
24
|
-
|
25
|
-
raise e
|
26
|
-
end
|
27
|
-
puts e.message
|
28
|
-
logger.error(e)
|
29
|
-
exit_code = 1
|
26
|
+
process_standard_error(e)
|
30
27
|
end
|
31
|
-
|
28
|
+
|
29
|
+
return @exit_code
|
32
30
|
ensure
|
31
|
+
log_exit_code_info(@exit_code)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def log_exit_code_info(exit_code)
|
33
37
|
logger.info("foreman-maintain command finished with #{exit_code}")
|
34
38
|
end
|
39
|
+
|
40
|
+
def process_standard_error(error)
|
41
|
+
if error.is_a?(Clamp::HelpWanted) ||
|
42
|
+
error.is_a?(ArgumentError) ||
|
43
|
+
error.is_a?(Clamp::UsageError)
|
44
|
+
raise error
|
45
|
+
end
|
46
|
+
|
47
|
+
puts error.message
|
48
|
+
logger.error(error)
|
49
|
+
|
50
|
+
@exit_code = 1
|
51
|
+
end
|
52
|
+
|
53
|
+
def process_usage_error(error)
|
54
|
+
log_exit_code_info(1)
|
55
|
+
puts error.message
|
56
|
+
exit!
|
57
|
+
end
|
35
58
|
end
|
36
59
|
end
|
37
60
|
end
|
@@ -25,12 +25,21 @@ module ForemanMaintain
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def execute
|
28
|
+
run_scenario(scenario(invocation_path))
|
29
|
+
exit runner.exit_code
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def scenario(invocation_path)
|
28
35
|
tag = underscorize(invocation_path.split.last).to_sym
|
29
36
|
scenario = ForemanMaintain::Scenario.new
|
37
|
+
|
30
38
|
ForemanMaintain.available_procedures(:tags => tag).sort_by(&:label).each do |procedure|
|
31
|
-
scenario.add_step(procedure.new(
|
39
|
+
scenario.add_step(procedure.new(get_params_for(procedure)))
|
32
40
|
end
|
33
|
-
|
41
|
+
|
42
|
+
scenario
|
34
43
|
end
|
35
44
|
end
|
36
45
|
end
|
@@ -5,6 +5,8 @@ module ForemanMaintain
|
|
5
5
|
class Base < Clamp::Command
|
6
6
|
include Concerns::Finders
|
7
7
|
|
8
|
+
attr_reader :runner
|
9
|
+
|
8
10
|
def self.dashize(string)
|
9
11
|
string.to_s.tr('_', '-')
|
10
12
|
end
|
@@ -38,10 +40,12 @@ module ForemanMaintain
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def run_scenario(scenarios)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
@runner ||=
|
44
|
+
ForemanMaintain::Runner.new(reporter, scenarios,
|
45
|
+
:assumeyes => assumeyes?,
|
46
|
+
:whitelist => whitelist || [],
|
47
|
+
:force => force?)
|
48
|
+
runner.run
|
45
49
|
end
|
46
50
|
|
47
51
|
def available_checks
|
@@ -6,7 +6,19 @@ module ForemanMaintain
|
|
6
6
|
:required => false
|
7
7
|
end
|
8
8
|
|
9
|
+
def current_target_version
|
10
|
+
current_target_version = ForemanMaintain::UpgradeRunner.current_target_version
|
11
|
+
if current_target_version && target_version && target_version != current_target_version
|
12
|
+
raise Error::UsageError,
|
13
|
+
"Can't set target version #{target_version}, "\
|
14
|
+
"#{current_target_version} already in progress"
|
15
|
+
end
|
16
|
+
@target_version = current_target_version if current_target_version
|
17
|
+
return true if current_target_version
|
18
|
+
end
|
19
|
+
|
9
20
|
def validate_target_version!
|
21
|
+
return if current_target_version
|
10
22
|
unless UpgradeRunner.available_targets.include?(target_version)
|
11
23
|
message_start = if target_version
|
12
24
|
"Can't upgrade to #{target_version}"
|
@@ -277,24 +277,25 @@ module ForemanMaintain
|
|
277
277
|
recommend = []
|
278
278
|
steps_with_error = scenario.steps_with_error(:whitelisted => false)
|
279
279
|
unless steps_with_error.empty?
|
280
|
-
message << <<-MESSAGE.strip_heredoc
|
280
|
+
message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
|
281
281
|
The following steps ended up in failing state:
|
282
282
|
|
283
|
-
|
283
|
+
%s
|
284
284
|
MESSAGE
|
285
|
-
|
285
|
+
whitelist_labels = steps_with_error.map(&:label_dashed).join(',')
|
286
|
+
recommend << format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
286
287
|
Resolve the failed steps and rerun
|
287
288
|
the command. In case the failures are false positives,
|
288
|
-
use --whitelist="
|
289
|
+
use --whitelist="%s"
|
289
290
|
MESSAGE
|
290
291
|
end
|
291
292
|
|
292
293
|
steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
|
293
294
|
unless steps_with_warning.empty?
|
294
|
-
message << <<-MESSAGE.strip_heredoc
|
295
|
+
message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_warning, "\n", 2))
|
295
296
|
The following steps ended up in warning state:
|
296
297
|
|
297
|
-
|
298
|
+
%s
|
298
299
|
MESSAGE
|
299
300
|
|
300
301
|
recommend << <<-MESSAGE.strip_heredoc
|
@@ -36,17 +36,16 @@ module ForemanMaintain
|
|
36
36
|
def run_scenario(scenario, confirm = true)
|
37
37
|
return if scenario.steps.empty?
|
38
38
|
raise 'The runner is already in quit state' if quit?
|
39
|
+
|
39
40
|
if confirm
|
40
41
|
confirm_scenario(scenario)
|
41
42
|
return if quit?
|
42
43
|
end
|
43
|
-
|
44
|
-
|
45
|
-
@reporter.before_scenario_starts(scenario)
|
46
|
-
run_steps(scenario, scenario.steps)
|
47
|
-
@reporter.after_scenario_finishes(scenario)
|
44
|
+
|
45
|
+
execute_scenario_steps(scenario)
|
48
46
|
ensure
|
49
47
|
@last_scenario = scenario unless scenario.steps.empty?
|
48
|
+
@exit_code = 1 if scenario.failed?
|
50
49
|
end
|
51
50
|
|
52
51
|
def whitelisted_step?(step)
|
@@ -84,6 +83,14 @@ module ForemanMaintain
|
|
84
83
|
|
85
84
|
private
|
86
85
|
|
86
|
+
def execute_scenario_steps(scenario)
|
87
|
+
scenario.before_scenarios.flatten.each { |before_scenario| run_scenario(before_scenario) }
|
88
|
+
return if quit? # the before scenarios caused the stop of the execution
|
89
|
+
@reporter.before_scenario_starts(scenario)
|
90
|
+
run_steps(scenario, scenario.steps)
|
91
|
+
@reporter.after_scenario_finishes(scenario)
|
92
|
+
end
|
93
|
+
|
87
94
|
def run_steps(scenario, steps)
|
88
95
|
@steps_to_run = ForemanMaintain::DependencyGraph.sort(steps)
|
89
96
|
while !@quit && !@steps_to_run.empty?
|
@@ -13,13 +13,15 @@ module ForemanMaintain
|
|
13
13
|
include Concerns::Finders
|
14
14
|
|
15
15
|
def available_targets
|
16
|
+
# when some upgrade is in progress, we don't allow upgrade to different version
|
17
|
+
return [current_target_version] if current_target_version
|
16
18
|
versions_to_tags.inject([]) do |available_targets, (version, tag)|
|
17
19
|
if !find_scenarios(:tags => [tag]).empty?
|
18
20
|
available_targets << version
|
19
21
|
else
|
20
22
|
available_targets
|
21
23
|
end
|
22
|
-
end
|
24
|
+
end.sort
|
23
25
|
end
|
24
26
|
|
25
27
|
def versions_to_tags
|
@@ -37,6 +39,18 @@ module ForemanMaintain
|
|
37
39
|
def clear_register
|
38
40
|
versions_to_tags.lear
|
39
41
|
end
|
42
|
+
|
43
|
+
def current_target_version
|
44
|
+
ForemanMaintain.storage[:upgrade_target_version]
|
45
|
+
end
|
46
|
+
|
47
|
+
def current_target_version=(value)
|
48
|
+
ForemanMaintain.storage.update_and_save(:upgrade_target_version => value)
|
49
|
+
end
|
50
|
+
|
51
|
+
def clear_current_target_version
|
52
|
+
ForemanMaintain.storage.update_and_save(:upgrade_target_version => nil)
|
53
|
+
end
|
40
54
|
end
|
41
55
|
|
42
56
|
attr_reader :version, :tag, :phase
|
@@ -59,6 +73,7 @@ module ForemanMaintain
|
|
59
73
|
end
|
60
74
|
|
61
75
|
def run
|
76
|
+
self.class.current_target_version = @version
|
62
77
|
PHASES.each do |phase|
|
63
78
|
return run_rollback if quit?
|
64
79
|
if skip?(phase)
|
@@ -70,6 +85,14 @@ module ForemanMaintain
|
|
70
85
|
unless quit?
|
71
86
|
finish_upgrade
|
72
87
|
end
|
88
|
+
ensure
|
89
|
+
update_current_target_version
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_current_target_version
|
93
|
+
if phase == :pre_upgrade_checks || @finished
|
94
|
+
UpgradeRunner.clear_current_target_version
|
95
|
+
end
|
73
96
|
end
|
74
97
|
|
75
98
|
def run_rollback
|
@@ -124,7 +147,7 @@ module ForemanMaintain
|
|
124
147
|
@reporter.before_scenario_starts(scenario)
|
125
148
|
@reporter.puts <<-MESSAGE.strip_heredoc
|
126
149
|
Skipping #{skipped_phase} phase as it was already run before.
|
127
|
-
To enforce to run the phase, use `upgrade run --phase #{
|
150
|
+
To enforce to run the phase, use `upgrade run --phase #{skipped_phase}`
|
128
151
|
MESSAGE
|
129
152
|
@reporter.after_scenario_finishes(scenario)
|
130
153
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
213
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.
|
214
|
+
rubygems_version: 2.5.2
|
215
215
|
signing_key:
|
216
216
|
specification_version: 4
|
217
217
|
summary: Foreman maintenance tool belt
|