foreman_maintain 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +674 -0
- data/README.md +193 -0
- data/bin/foreman-maintain +9 -0
- data/definitions/checks/foreman_tasks_not_paused.rb +14 -0
- data/definitions/checks/foreman_tasks_not_running.rb +10 -0
- data/definitions/features/downstream.rb +17 -0
- data/definitions/features/foreman_1_11_x.rb +7 -0
- data/definitions/features/foreman_1_7_x.rb +7 -0
- data/definitions/features/foreman_database.rb +15 -0
- data/definitions/features/foreman_tasks.rb +22 -0
- data/definitions/features/upstream.rb +7 -0
- data/definitions/procedures/foreman_tasks_resume.rb +13 -0
- data/definitions/scenarios/pre_upgrade_check_foreman_1_14.rb +12 -0
- data/definitions/scenarios/pre_upgrade_check_satellite_6_0_z.rb +12 -0
- data/definitions/scenarios/pre_upgrade_check_satellite_6_1.rb +12 -0
- data/definitions/scenarios/pre_upgrade_check_satellite_6_1_z.rb +12 -0
- data/definitions/scenarios/pre_upgrade_check_satellite_6_2.rb +12 -0
- data/definitions/scenarios/pre_upgrade_check_satellite_6_2_z.rb +12 -0
- data/definitions/scenarios/pre_upgrade_check_satellite_6_3.rb +12 -0
- data/lib/foreman_maintain.rb +54 -0
- data/lib/foreman_maintain/check.rb +34 -0
- data/lib/foreman_maintain/cli.rb +14 -0
- data/lib/foreman_maintain/cli/base.rb +47 -0
- data/lib/foreman_maintain/cli/health_command.rb +39 -0
- data/lib/foreman_maintain/cli/upgrade_command.rb +57 -0
- data/lib/foreman_maintain/concerns/finders.rb +69 -0
- data/lib/foreman_maintain/concerns/logger.rb +13 -0
- data/lib/foreman_maintain/concerns/metadata.rb +124 -0
- data/lib/foreman_maintain/concerns/system_helpers.rb +93 -0
- data/lib/foreman_maintain/config.rb +17 -0
- data/lib/foreman_maintain/detector.rb +146 -0
- data/lib/foreman_maintain/executable.rb +44 -0
- data/lib/foreman_maintain/feature.rb +22 -0
- data/lib/foreman_maintain/logger.rb +11 -0
- data/lib/foreman_maintain/procedure.rb +8 -0
- data/lib/foreman_maintain/reporter.rb +18 -0
- data/lib/foreman_maintain/reporter/cli_reporter.rb +177 -0
- data/lib/foreman_maintain/runner.rb +39 -0
- data/lib/foreman_maintain/runner/execution.rb +74 -0
- data/lib/foreman_maintain/scenario.rb +46 -0
- data/lib/foreman_maintain/top_level_modules.rb +13 -0
- data/lib/foreman_maintain/version.rb +3 -0
- metadata +173 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
# Class responsible for running the scenario
|
3
|
+
class Runner
|
4
|
+
require 'foreman_maintain/runner/execution'
|
5
|
+
def initialize(reporter, scenario)
|
6
|
+
@reporter = reporter
|
7
|
+
@scenario = scenario
|
8
|
+
@executions = []
|
9
|
+
@steps_to_run = @scenario.steps.dup
|
10
|
+
@quit = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
@reporter.before_scenario_starts(@scenario)
|
15
|
+
while !@quit && !@steps_to_run.empty?
|
16
|
+
step = @steps_to_run.shift
|
17
|
+
execution = Execution.new(step, @reporter)
|
18
|
+
execution.run
|
19
|
+
@executions << execution
|
20
|
+
ask_about_offered_steps(step.next_steps)
|
21
|
+
end
|
22
|
+
@reporter.after_scenario_finishes(@scenario)
|
23
|
+
end
|
24
|
+
|
25
|
+
def ask_to_quit
|
26
|
+
@quit = true
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_step(step)
|
30
|
+
@steps_to_run.unshift(step)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def ask_about_offered_steps(steps)
|
36
|
+
@reporter.on_next_steps(self, steps) if steps
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
class Runner
|
3
|
+
# Class representing an execution of a single step in scenario
|
4
|
+
class Execution
|
5
|
+
include Concerns::Logger
|
6
|
+
|
7
|
+
# Step performed as part of the execution
|
8
|
+
attr_reader :step
|
9
|
+
|
10
|
+
# Information about timings, collected automatically
|
11
|
+
attr_reader :started_at, :ended_at
|
12
|
+
|
13
|
+
# One of :pending, :running, :success, :fail, :skipped
|
14
|
+
attr_accessor :status
|
15
|
+
|
16
|
+
# Output of the execution, to be filled by execution step
|
17
|
+
attr_accessor :output
|
18
|
+
|
19
|
+
def initialize(step, reporter)
|
20
|
+
@step = step
|
21
|
+
@reporter = reporter
|
22
|
+
@status = :pending
|
23
|
+
@output = ''
|
24
|
+
end
|
25
|
+
|
26
|
+
def name
|
27
|
+
@step.description
|
28
|
+
end
|
29
|
+
|
30
|
+
def success?
|
31
|
+
@status == :success
|
32
|
+
end
|
33
|
+
|
34
|
+
def fail?
|
35
|
+
@status == :fail
|
36
|
+
end
|
37
|
+
|
38
|
+
def run
|
39
|
+
@status = :running
|
40
|
+
@reporter.before_execution_starts(self)
|
41
|
+
with_metadata_calculation do
|
42
|
+
capture_errors do
|
43
|
+
step.__run__(self)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
# change the state only when not modified
|
47
|
+
@status = :success if @status == :running
|
48
|
+
ensure
|
49
|
+
@reporter.after_execution_finishes(self)
|
50
|
+
end
|
51
|
+
|
52
|
+
def update(line)
|
53
|
+
@reporter.on_execution_update(self, line)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def with_metadata_calculation
|
59
|
+
@started_at = Time.now
|
60
|
+
yield
|
61
|
+
ensure
|
62
|
+
@ended_at = Time.now
|
63
|
+
end
|
64
|
+
|
65
|
+
def capture_errors
|
66
|
+
yield
|
67
|
+
rescue => e
|
68
|
+
@status = :fail
|
69
|
+
@output << e.message
|
70
|
+
logger.error(e)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
class Scenario
|
3
|
+
include Concerns::Logger
|
4
|
+
include Concerns::SystemHelpers
|
5
|
+
include Concerns::Metadata
|
6
|
+
include Concerns::Finders
|
7
|
+
|
8
|
+
attr_reader :steps
|
9
|
+
|
10
|
+
class ChecksScenario < Scenario
|
11
|
+
manual_detection
|
12
|
+
attr_reader :filter_tags
|
13
|
+
|
14
|
+
def initialize(filter_tags)
|
15
|
+
@filter_tags = filter_tags
|
16
|
+
@steps = ForemanMaintain.available_checks(:tags => filter_tags)
|
17
|
+
end
|
18
|
+
|
19
|
+
def description
|
20
|
+
"checks with tags #{tag_string(@filter_tags)}"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def tag_string(tags)
|
26
|
+
tags.map { |tag| "[#{tag}]" }.join(' ')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
@steps = []
|
32
|
+
compose
|
33
|
+
end
|
34
|
+
|
35
|
+
# Override to compose steps for the scenario
|
36
|
+
def compose; end
|
37
|
+
|
38
|
+
def self.inspect
|
39
|
+
"Scenario Class #{metadata[:description]}<#{name}>"
|
40
|
+
end
|
41
|
+
|
42
|
+
def inspect
|
43
|
+
"#{self.class.metadata[:description]}<#{self.class.name}>"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: foreman_maintain
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Nečas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: clamp
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 11.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 11.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mocha
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: |
|
98
|
+
Provides various features that helps keeping the Foreman/Satellite up and
|
99
|
+
running.
|
100
|
+
email: inecas@redhat.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files:
|
104
|
+
- LICENSE
|
105
|
+
- README.md
|
106
|
+
files:
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- bin/foreman-maintain
|
110
|
+
- definitions/checks/foreman_tasks_not_paused.rb
|
111
|
+
- definitions/checks/foreman_tasks_not_running.rb
|
112
|
+
- definitions/features/downstream.rb
|
113
|
+
- definitions/features/foreman_1_11_x.rb
|
114
|
+
- definitions/features/foreman_1_7_x.rb
|
115
|
+
- definitions/features/foreman_database.rb
|
116
|
+
- definitions/features/foreman_tasks.rb
|
117
|
+
- definitions/features/upstream.rb
|
118
|
+
- definitions/procedures/foreman_tasks_resume.rb
|
119
|
+
- definitions/scenarios/pre_upgrade_check_foreman_1_14.rb
|
120
|
+
- definitions/scenarios/pre_upgrade_check_satellite_6_0_z.rb
|
121
|
+
- definitions/scenarios/pre_upgrade_check_satellite_6_1.rb
|
122
|
+
- definitions/scenarios/pre_upgrade_check_satellite_6_1_z.rb
|
123
|
+
- definitions/scenarios/pre_upgrade_check_satellite_6_2.rb
|
124
|
+
- definitions/scenarios/pre_upgrade_check_satellite_6_2_z.rb
|
125
|
+
- definitions/scenarios/pre_upgrade_check_satellite_6_3.rb
|
126
|
+
- lib/foreman_maintain.rb
|
127
|
+
- lib/foreman_maintain/check.rb
|
128
|
+
- lib/foreman_maintain/cli.rb
|
129
|
+
- lib/foreman_maintain/cli/base.rb
|
130
|
+
- lib/foreman_maintain/cli/health_command.rb
|
131
|
+
- lib/foreman_maintain/cli/upgrade_command.rb
|
132
|
+
- lib/foreman_maintain/concerns/finders.rb
|
133
|
+
- lib/foreman_maintain/concerns/logger.rb
|
134
|
+
- lib/foreman_maintain/concerns/metadata.rb
|
135
|
+
- lib/foreman_maintain/concerns/system_helpers.rb
|
136
|
+
- lib/foreman_maintain/config.rb
|
137
|
+
- lib/foreman_maintain/detector.rb
|
138
|
+
- lib/foreman_maintain/executable.rb
|
139
|
+
- lib/foreman_maintain/feature.rb
|
140
|
+
- lib/foreman_maintain/logger.rb
|
141
|
+
- lib/foreman_maintain/procedure.rb
|
142
|
+
- lib/foreman_maintain/reporter.rb
|
143
|
+
- lib/foreman_maintain/reporter/cli_reporter.rb
|
144
|
+
- lib/foreman_maintain/runner.rb
|
145
|
+
- lib/foreman_maintain/runner/execution.rb
|
146
|
+
- lib/foreman_maintain/scenario.rb
|
147
|
+
- lib/foreman_maintain/top_level_modules.rb
|
148
|
+
- lib/foreman_maintain/version.rb
|
149
|
+
homepage: https://github.com/theforeman/foreman_maintain
|
150
|
+
licenses:
|
151
|
+
- GPL-3.0
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.4.5
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Foreman maintenance tool belt
|
173
|
+
test_files: []
|