foreman_maintain 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/definitions/checks/candlepin/validate_db.rb +16 -0
- data/definitions/checks/disk/performance.rb +67 -0
- data/definitions/features/candlepin_database.rb +62 -0
- data/definitions/features/downstream.rb +5 -6
- data/definitions/features/foreman_database.rb +11 -8
- data/definitions/features/foreman_proxy.rb +1 -1
- data/definitions/features/katello_service.rb +21 -9
- data/definitions/procedures/foreman_tasks/delete.rb +9 -6
- data/definitions/procedures/katello_service/restart.rb +2 -2
- data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +1 -0
- data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +1 -0
- data/lib/foreman_maintain.rb +1 -0
- data/lib/foreman_maintain/cli/base.rb +6 -0
- data/lib/foreman_maintain/concerns/base_database.rb +33 -0
- data/lib/foreman_maintain/concerns/system_helpers.rb +4 -0
- data/lib/foreman_maintain/param.rb +19 -1
- data/lib/foreman_maintain/upgrade_runner.rb +1 -1
- data/lib/foreman_maintain/utils/command_runner.rb +1 -0
- data/lib/foreman_maintain/utils/disk.rb +1 -0
- data/lib/foreman_maintain/utils/disk/device.rb +6 -2
- data/lib/foreman_maintain/utils/disk/stats.rb +25 -0
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +7 -3
- data/definitions/checks/disk_speed_minimal.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e9f70b0ee10a6f3d86da947c29b44f28425fe3d
|
4
|
+
data.tar.gz: 25c1ffb8b8b12ff26a2ee7cad07f407b7586f276
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab4457e9ea8319b82ac952b5d389bd2156d384076d2d36db0150b51a04127b62393617327118d715ebb468bcf104ceaefda96cb86d641a0da8724d4ae29cb632
|
7
|
+
data.tar.gz: 4d59d274a7f28c85f4c315766e276890fb9c5285225fd02dcf5aef62e495b08343e8becfcdd7cbb39ddf916b6be38180692dba4ffc83ff9f83fddc9570c12e80
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Subcommands:
|
|
18
18
|
|
19
19
|
upgrade Upgrade related commands
|
20
20
|
list-versions List versions this system is upgradable to
|
21
|
-
check --target-version TARGET_VERSION Run pre-upgrade checks for
|
21
|
+
check --target-version TARGET_VERSION Run pre-upgrade checks for upgrading to specified version
|
22
22
|
run --target-version TARGET_VERSION Run the full upgrade
|
23
23
|
[--phase=phase TARGET_VERSION] Run just a specific phase of the upgrade
|
24
24
|
```
|
@@ -56,7 +56,7 @@ of the system:
|
|
56
56
|
at the current version, while this phase runs.
|
57
57
|
|
58
58
|
* **pre-migrations** - these steps perform changes on the system before
|
59
|
-
the actual upgrade
|
59
|
+
the actual upgrade starts. An example is disabling access to the system from
|
60
60
|
external sources, a.k.a. maintenance mode or disabling sync plans during the run.
|
61
61
|
|
62
62
|
After this phase ends, the system is still running the old version, and it's possible
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Checks::Candlepin
|
2
|
+
class ValidateDb < ForemanMaintain::Check
|
3
|
+
metadata do
|
4
|
+
description 'Check to validate candlepin database'
|
5
|
+
tags :pre_upgrade
|
6
|
+
|
7
|
+
confine do
|
8
|
+
feature(:candlepin_database) && feature(:candlepin_database).validate_available_in_cpdb?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
feature(:candlepin_database).execute_cpdb_validate_cmd
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Checks
|
2
|
+
module Disk
|
3
|
+
class Performance < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :disk_performance
|
6
|
+
description 'Check for recommended disk speed of pulp, mongodb, pgsql dir.'
|
7
|
+
tags :pre_upgrade
|
8
|
+
preparation_steps { Procedures::Packages::Install.new(:packages => %w[hdparm fio]) }
|
9
|
+
|
10
|
+
confine do
|
11
|
+
feature(:pulp)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
EXPECTED_IO = 80
|
16
|
+
DEFAULT_UNIT = 'MB/sec'.freeze
|
17
|
+
DEFAULT_DIRS = ['/var/lib/pulp', '/var/lib/mongodb', '/var/lib/pgsql'].freeze
|
18
|
+
|
19
|
+
attr_reader :stats
|
20
|
+
|
21
|
+
def run
|
22
|
+
@stats = ForemanMaintain::Utils::Disk::Stats.new
|
23
|
+
with_spinner(description) do |spinner|
|
24
|
+
io_obj, success = compute_disk_speed(spinner)
|
25
|
+
spinner.update('Finished')
|
26
|
+
puts "\n"
|
27
|
+
puts stats.stdout
|
28
|
+
|
29
|
+
assert(success, io_obj.slow_disk_error_msg)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def check_only_single_device?
|
34
|
+
DEFAULT_DIRS.map do |dir|
|
35
|
+
ForemanMaintain::Utils::Disk::Device.new(dir).name
|
36
|
+
end.uniq.length <= 1
|
37
|
+
end
|
38
|
+
|
39
|
+
def dirs_to_check
|
40
|
+
return DEFAULT_DIRS.first(1) if check_only_single_device?
|
41
|
+
DEFAULT_DIRS
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def compute_disk_speed(spinner)
|
47
|
+
success = true
|
48
|
+
io_obj = ForemanMaintain::Utils::Disk::NilDevice.new
|
49
|
+
|
50
|
+
dirs_to_check.each do |dir|
|
51
|
+
io_obj = ForemanMaintain::Utils::Disk::Device.new(dir)
|
52
|
+
|
53
|
+
spinner.update("[Speed check In-Progress] device: #{io_obj.name}")
|
54
|
+
stats << io_obj
|
55
|
+
|
56
|
+
next if io_obj.read_speed >= EXPECTED_IO
|
57
|
+
|
58
|
+
success = false
|
59
|
+
logger.info "Slow disk detected #{dir}: #{io_obj.performance}."
|
60
|
+
break
|
61
|
+
end
|
62
|
+
|
63
|
+
[io_obj, success]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class Features::CandlepinDatabase < ForemanMaintain::Feature
|
2
|
+
CANDLEPIN_DB_CONFIG = '/etc/candlepin/candlepin.conf'.freeze
|
3
|
+
|
4
|
+
include ForemanMaintain::Concerns::BaseDatabase
|
5
|
+
|
6
|
+
metadata do
|
7
|
+
label :candlepin_database
|
8
|
+
|
9
|
+
confine do
|
10
|
+
file_exists?(CANDLEPIN_DB_CONFIG)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def configuration
|
15
|
+
@configuration || load_configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_available_in_cpdb?
|
19
|
+
check_option_using_cpdb_help('validate')
|
20
|
+
end
|
21
|
+
|
22
|
+
def check_option_using_cpdb_help(option_name, parent_cmd = '')
|
23
|
+
parent_cmd = '/usr/share/candlepin/cpdb' if parent_cmd.empty?
|
24
|
+
help_cmd = "#{parent_cmd} --help | grep -c '\\-\\-#{option_name} '"
|
25
|
+
execute?(help_cmd)
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute_cpdb_validate_cmd
|
29
|
+
main_cmd = cpdb_validate_cmd
|
30
|
+
unless main_cmd.empty?
|
31
|
+
main_cmd += format_shell_args(
|
32
|
+
'-u' => configuration['username'], '-p' => configuration[%(password)]
|
33
|
+
)
|
34
|
+
execute!(main_cmd, :hidden_patterns => [configuration['password']])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def load_configuration
|
41
|
+
raw_config = File.read(CANDLEPIN_DB_CONFIG)
|
42
|
+
full_config = Hash[raw_config.scan(/(^[^#\n][^=]*)=(.*)/)]
|
43
|
+
uri = %r{://(([^/:]*):?([^/]*))/(.*)}.match(full_config['org.quartz.dataSource.myDS.URL'])
|
44
|
+
@configuration = {
|
45
|
+
'username' => full_config['org.quartz.dataSource.myDS.user'],
|
46
|
+
'password' => full_config['org.quartz.dataSource.myDS.password'],
|
47
|
+
'database' => uri[4],
|
48
|
+
'host' => uri[2],
|
49
|
+
'port' => uri[3] || '5432',
|
50
|
+
'driver' => full_config['org.quartz.dataSource.myDS.driver'],
|
51
|
+
'url' => full_config['org.quartz.dataSource.myDS.URL']
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def cpdb_validate_cmd
|
56
|
+
return '' unless check_option_using_cpdb_help('validate')
|
57
|
+
cmd = '/usr/share/candlepin/cpdb --validate'
|
58
|
+
return cmd unless check_option_using_cpdb_help('verbose', cmd)
|
59
|
+
cmd += ' --verbose'
|
60
|
+
cmd
|
61
|
+
end
|
62
|
+
end
|
@@ -34,16 +34,15 @@ class Features::Downstream < ForemanMaintain::Feature
|
|
34
34
|
def rh_repos(sat_version)
|
35
35
|
sat_version = version(sat_version)
|
36
36
|
rh_version_major = execute!('facter operatingsystemmajrelease')
|
37
|
+
sat_version_full = "#{sat_version.major}.#{sat_version.minor}"
|
37
38
|
|
38
|
-
sat_repo_id = "rhel-#{rh_version_major}-server-satellite-#{
|
39
|
-
|
40
|
-
# Override to use Beta repositories for 6.3 until GA
|
41
|
-
if sat_version.to_s == '6.3'
|
42
|
-
sat_repo_id = "rhel-server-#{rh_version_major}-satellite-6-beta-rpms"
|
43
|
-
end
|
39
|
+
sat_repo_id = "rhel-#{rh_version_major}-server-satellite-#{sat_version_full}-rpms"
|
40
|
+
sat_tools_repo_id = "rhel-#{rh_version_major}-server-satellite-tools-#{sat_version_full}-rpms"
|
44
41
|
|
45
42
|
["rhel-#{rh_version_major}-server-rpms",
|
46
43
|
"rhel-server-rhscl-#{rh_version_major}-rpms",
|
44
|
+
"rhel-#{rh_version_major}-server-satellite-maintenance-6-rpms",
|
45
|
+
sat_tools_repo_id,
|
47
46
|
sat_repo_id]
|
48
47
|
end
|
49
48
|
|
@@ -1,21 +1,24 @@
|
|
1
1
|
class Features::ForemanDatabase < ForemanMaintain::Feature
|
2
|
+
FOREMAN_DB_CONFIG = '/etc/foreman/database.yml'.freeze
|
3
|
+
|
4
|
+
include ForemanMaintain::Concerns::BaseDatabase
|
5
|
+
|
2
6
|
metadata do
|
3
7
|
label :foreman_database
|
4
8
|
|
5
9
|
confine do
|
6
|
-
|
10
|
+
file_exists?(FOREMAN_DB_CONFIG)
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
10
|
-
def
|
11
|
-
|
14
|
+
def configuration
|
15
|
+
@configuration || load_configuration
|
12
16
|
end
|
13
17
|
|
14
|
-
|
15
|
-
psql(%{COPY (#{sql}) TO STDOUT WITH CSV HEADER})
|
16
|
-
end
|
18
|
+
private
|
17
19
|
|
18
|
-
def
|
19
|
-
|
20
|
+
def load_configuration
|
21
|
+
config = YAML.load(File.read(FOREMAN_DB_CONFIG))
|
22
|
+
@configuration = config['production']
|
20
23
|
end
|
21
24
|
end
|
@@ -20,7 +20,7 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def dhcp_curl_cmd
|
23
|
-
"curl -w '\n%{http_code}'
|
23
|
+
"curl -w '\n%{http_code}' --silent -ks --cert #{cert_path}/client_cert.pem \
|
24
24
|
--key #{cert_path}/client_key.pem \
|
25
25
|
--cacert #{cert_path}/proxy_ca.pem https://$(hostname):9090/dhcp"
|
26
26
|
end
|
@@ -13,7 +13,7 @@ class Features::KatelloService < ForemanMaintain::Feature
|
|
13
13
|
yield if block_given?
|
14
14
|
else
|
15
15
|
begin
|
16
|
-
filters =
|
16
|
+
filters = construct_filters(services)
|
17
17
|
spinner.update 'Stopping katello running services..'
|
18
18
|
execute!("katello-service stop #{filters}")
|
19
19
|
yield if block_given?
|
@@ -28,7 +28,7 @@ class Features::KatelloService < ForemanMaintain::Feature
|
|
28
28
|
if services.empty?
|
29
29
|
spinner.update 'No katello service to start'
|
30
30
|
else
|
31
|
-
filters =
|
31
|
+
filters = construct_filters(services)
|
32
32
|
spinner.update 'Starting katello services..'
|
33
33
|
execute!("katello-service start #{filters}")
|
34
34
|
end
|
@@ -36,7 +36,7 @@ class Features::KatelloService < ForemanMaintain::Feature
|
|
36
36
|
|
37
37
|
def restart(options = {})
|
38
38
|
if options[:only] || options[:exclude]
|
39
|
-
filters =
|
39
|
+
filters = construct_filters(options[:only], options[:exclude])
|
40
40
|
execute!("katello-service restart #{filters}")
|
41
41
|
else
|
42
42
|
execute!('katello-service restart')
|
@@ -59,6 +59,10 @@ class Features::KatelloService < ForemanMaintain::Feature
|
|
59
59
|
logger.error e.message
|
60
60
|
end
|
61
61
|
|
62
|
+
def service_list
|
63
|
+
@service_list ||= katello_service_names.map { |s| s.gsub('.service', '') }
|
64
|
+
end
|
65
|
+
|
62
66
|
private
|
63
67
|
|
64
68
|
def apply_sleep_before_retry(spinner, result)
|
@@ -67,13 +71,18 @@ class Features::KatelloService < ForemanMaintain::Feature
|
|
67
71
|
sleep PING_RETRY_INTERVAL
|
68
72
|
end
|
69
73
|
|
70
|
-
def
|
74
|
+
def construct_filters(only_services, exclude_services = [])
|
71
75
|
filters = ''
|
72
|
-
|
73
|
-
|
76
|
+
unless only_services.empty?
|
77
|
+
if feature(:downstream) && feature(:downstream).current_minor_version <= '6.1'
|
78
|
+
exclude_services.concat(service_list - only_services)
|
79
|
+
exclude_services.uniq!
|
80
|
+
else
|
81
|
+
filters += "--only #{only_services.join(',')}"
|
82
|
+
end
|
74
83
|
end
|
75
|
-
|
76
|
-
filters += "--exclude #{
|
84
|
+
unless exclude_services.empty?
|
85
|
+
filters += "--exclude #{exclude_services.join(',')}"
|
77
86
|
end
|
78
87
|
filters
|
79
88
|
end
|
@@ -98,8 +107,11 @@ class Features::KatelloService < ForemanMaintain::Feature
|
|
98
107
|
find_services_by_state(" -w 'dead'")
|
99
108
|
end
|
100
109
|
|
110
|
+
def katello_service_names
|
111
|
+
@katello_service_names ||= execute("katello-service list|awk '{print $1}'").split(/\n/)
|
112
|
+
end
|
113
|
+
|
101
114
|
def find_services_by_state(state)
|
102
|
-
katello_service_names = execute("katello-service list|awk '{print $1}'").split(/\n/)
|
103
115
|
services_by_state = execute("systemctl --all |grep #{state}|awk '{print $1}'").split(/\n/)
|
104
116
|
(katello_service_names & services_by_state).map { |s| s.gsub('.service', '') }
|
105
117
|
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Procedures::ForemanTasks
|
2
2
|
class Delete < ForemanMaintain::Procedure
|
3
|
+
ALLOWED_STATES_VALUES = %w[old planning pending].freeze
|
4
|
+
|
3
5
|
metadata do
|
4
|
-
param :state,
|
6
|
+
param :state,
|
7
|
+
'In what state should the task be deleted.'\
|
8
|
+
" Possible values are #{ALLOWED_STATES_VALUES.join(', ')}",
|
9
|
+
:required => true, :allowed_values => ALLOWED_STATES_VALUES
|
5
10
|
description 'Delete tasks'
|
6
11
|
end
|
7
12
|
|
@@ -11,7 +16,6 @@ module Procedures::ForemanTasks
|
|
11
16
|
|
12
17
|
if count_tasks_before > 0
|
13
18
|
spinner.update "Backup #{@state} tasks"
|
14
|
-
|
15
19
|
feature(:foreman_tasks).backup_tasks(@state) do |backup_progress|
|
16
20
|
spinner.update backup_progress
|
17
21
|
end
|
@@ -19,11 +23,10 @@ module Procedures::ForemanTasks
|
|
19
23
|
spinner.update "Deleting #{@state} tasks [running]"
|
20
24
|
count_tasks_later = feature(:foreman_tasks).delete(@state)
|
21
25
|
spinner.update "Deleting #{@state} tasks [DONE]"
|
26
|
+
spinner.update(
|
27
|
+
"Deleted #{@state} stopped and paused tasks: #{count_tasks_before - count_tasks_later}"
|
28
|
+
)
|
22
29
|
end
|
23
|
-
|
24
|
-
spinner.update(
|
25
|
-
"Deleted #{@state} stopped and paused tasks: #{count_tasks_before - count_tasks_later}"
|
26
|
-
)
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
@@ -16,8 +16,8 @@ module Procedures::KatelloService
|
|
16
16
|
|
17
17
|
def runtime_message
|
18
18
|
msg = 'katello-service restart'
|
19
|
-
msg += "--only #{@only.join(',')}" unless @only.empty?
|
20
|
-
msg += "--exclude #{@exclude.join(',')}" unless @exclude.empty?
|
19
|
+
msg += " --only #{@only.join(',')}" unless @only.empty?
|
20
|
+
msg += " --exclude #{@exclude.join(',')}" unless @exclude.empty?
|
21
21
|
msg
|
22
22
|
end
|
23
23
|
end
|
data/lib/foreman_maintain.rb
CHANGED
@@ -16,6 +16,7 @@ module ForemanMaintain
|
|
16
16
|
require 'foreman_maintain/concerns/scenario_metadata'
|
17
17
|
require 'foreman_maintain/concerns/system_helpers'
|
18
18
|
require 'foreman_maintain/concerns/hammer'
|
19
|
+
require 'foreman_maintain/concerns/base_database'
|
19
20
|
require 'foreman_maintain/top_level_modules'
|
20
21
|
require 'foreman_maintain/yaml_storage'
|
21
22
|
require 'foreman_maintain/config'
|
@@ -98,6 +98,8 @@ module ForemanMaintain
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def self.interactive_option
|
101
|
+
delete_duplicate_assumeyes_if_any
|
102
|
+
|
101
103
|
option ['-y', '--assumeyes'], :flag,
|
102
104
|
'Automatically answer yes for all questions'
|
103
105
|
|
@@ -110,6 +112,10 @@ module ForemanMaintain
|
|
110
112
|
option ['-f', '--force'], :flag,
|
111
113
|
'Force steps that would be skipped as they were already run'
|
112
114
|
end
|
115
|
+
|
116
|
+
def self.delete_duplicate_assumeyes_if_any
|
117
|
+
declared_options.delete_if { |opt| opt.handles?('--assumeyes') }
|
118
|
+
end
|
113
119
|
end
|
114
120
|
end
|
115
121
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Concerns
|
3
|
+
module BaseDatabase
|
4
|
+
def configuration
|
5
|
+
raise NotImplementedError
|
6
|
+
end
|
7
|
+
|
8
|
+
def query(sql, config = configuration)
|
9
|
+
parse_csv(query_csv(sql, config))
|
10
|
+
end
|
11
|
+
|
12
|
+
def query_csv(sql, config = configuration)
|
13
|
+
psql(%{COPY (#{sql}) TO STDOUT WITH CSV HEADER}, config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def psql(query, config = configuration)
|
17
|
+
execute("PGPASSWORD='#{config[%(password)]}' #{psql_db_connection_str(config)}",
|
18
|
+
:stdin => query)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ping(config = configuration)
|
22
|
+
psql('SELECT 1 as ping', config)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def psql_db_connection_str(config)
|
28
|
+
"psql -d #{config['database']} -h #{config['host'] || 'localhost'} "\
|
29
|
+
" -p #{config['port'] || '5432'} -U #{config['username']}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -3,13 +3,14 @@ module ForemanMaintain
|
|
3
3
|
attr_reader :name, :description, :options
|
4
4
|
|
5
5
|
def initialize(name, description, options, &block)
|
6
|
-
options.validate_options!(:description, :required, :flag, :array)
|
6
|
+
options.validate_options!(:description, :required, :flag, :array, :allowed_values)
|
7
7
|
@name = name
|
8
8
|
@description = description || options[:description] || ''
|
9
9
|
@options = options
|
10
10
|
@required = @options.fetch(:required, false)
|
11
11
|
@flag = @options.fetch(:flag, false)
|
12
12
|
@block = block
|
13
|
+
@allowed_values = @options.fetch(:allowed_values, [])
|
13
14
|
@array = @options.fetch(:array, false)
|
14
15
|
end
|
15
16
|
|
@@ -34,6 +35,7 @@ module ForemanMaintain
|
|
34
35
|
elsif flag?
|
35
36
|
value = value ? true : false
|
36
37
|
end
|
38
|
+
validate_with_allowed_values(value)
|
37
39
|
value
|
38
40
|
end
|
39
41
|
# rubocop:enable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity
|
@@ -45,5 +47,21 @@ module ForemanMaintain
|
|
45
47
|
value.to_s.split(',').map(&:strip)
|
46
48
|
end
|
47
49
|
end
|
50
|
+
|
51
|
+
def validate_with_allowed_values(value)
|
52
|
+
return if @allowed_values.empty?
|
53
|
+
within_allowed = case value
|
54
|
+
when Array
|
55
|
+
(value - @allowed_values).empty?
|
56
|
+
when Symbol, String
|
57
|
+
@allowed_values.include?(value.to_s)
|
58
|
+
else
|
59
|
+
raise NotImplementedError
|
60
|
+
end
|
61
|
+
return if within_allowed
|
62
|
+
error_msg = "'#{value}' not allowed for #{name} param."
|
63
|
+
raise ForemanMaintain::Error::UsageError,
|
64
|
+
"#{error_msg} Possible values are #{@allowed_values.join(', ')}"
|
65
|
+
end
|
48
66
|
end
|
49
67
|
end
|
@@ -209,7 +209,7 @@ module ForemanMaintain
|
|
209
209
|
response = reporter.ask_decision(<<-MESSAGE.strip_heredoc.strip)
|
210
210
|
The pre-upgrade checks indicate that the system is ready for upgrade.
|
211
211
|
It's recommended to perform a backup at this stage.
|
212
|
-
Confirm to continue with the
|
212
|
+
Confirm to continue with the modification part of the upgrade
|
213
213
|
MESSAGE
|
214
214
|
if [:no, :quit].include?(response)
|
215
215
|
ask_to_quit
|
@@ -26,6 +26,10 @@ module ForemanMaintain
|
|
26
26
|
Expected disk speed: #{expected_io} #{default_unit}."
|
27
27
|
end
|
28
28
|
|
29
|
+
def performance
|
30
|
+
"#{read_speed} #{unit}"
|
31
|
+
end
|
32
|
+
|
29
33
|
private
|
30
34
|
|
31
35
|
def init_io_device
|
@@ -46,11 +50,11 @@ module ForemanMaintain
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def default_unit
|
49
|
-
Checks::
|
53
|
+
Checks::Disk::Performance::DEFAULT_UNIT
|
50
54
|
end
|
51
55
|
|
52
56
|
def expected_io
|
53
|
-
Checks::
|
57
|
+
Checks::Disk::Performance::EXPECTED_IO
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Utils
|
3
|
+
module Disk
|
4
|
+
class Stats
|
5
|
+
attr_accessor :data
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@data = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def <<(io_obj)
|
12
|
+
data[io_obj.dir] = io_obj.performance
|
13
|
+
end
|
14
|
+
|
15
|
+
def stdout
|
16
|
+
if data.keys.length > 1
|
17
|
+
data.map { |dir, perf| "#{dir} : #{perf}" }.join("\n")
|
18
|
+
else
|
19
|
+
"Disk speed : #{data.values.first}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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.1.
|
4
|
+
version: 0.1.3
|
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: 2018-01-
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -111,7 +111,8 @@ files:
|
|
111
111
|
- bin/passenger-recycler
|
112
112
|
- config/foreman_maintain.yml.example
|
113
113
|
- config/foreman_maintain.yml.packaging
|
114
|
-
- definitions/checks/
|
114
|
+
- definitions/checks/candlepin/validate_db.rb
|
115
|
+
- definitions/checks/disk/performance.rb
|
115
116
|
- definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb
|
116
117
|
- definitions/checks/foreman_tasks/invalid/check_old.rb
|
117
118
|
- definitions/checks/foreman_tasks/invalid/check_pending_state.rb
|
@@ -120,6 +121,7 @@ files:
|
|
120
121
|
- definitions/checks/foreman_tasks/not_running.rb
|
121
122
|
- definitions/checks/hammer_ping.rb
|
122
123
|
- definitions/checks/system_registration.rb
|
124
|
+
- definitions/features/candlepin_database.rb
|
123
125
|
- definitions/features/downstream.rb
|
124
126
|
- definitions/features/foreman_1_11_x.rb
|
125
127
|
- definitions/features/foreman_1_7_x.rb
|
@@ -167,6 +169,7 @@ files:
|
|
167
169
|
- lib/foreman_maintain/cli/health_command.rb
|
168
170
|
- lib/foreman_maintain/cli/transform_clamp_options.rb
|
169
171
|
- lib/foreman_maintain/cli/upgrade_command.rb
|
172
|
+
- lib/foreman_maintain/concerns/base_database.rb
|
170
173
|
- lib/foreman_maintain/concerns/finders.rb
|
171
174
|
- lib/foreman_maintain/concerns/hammer.rb
|
172
175
|
- lib/foreman_maintain/concerns/logger.rb
|
@@ -200,6 +203,7 @@ files:
|
|
200
203
|
- lib/foreman_maintain/utils/disk/io/block_device.rb
|
201
204
|
- lib/foreman_maintain/utils/disk/io/file_system.rb
|
202
205
|
- lib/foreman_maintain/utils/disk/nil_device.rb
|
206
|
+
- lib/foreman_maintain/utils/disk/stats.rb
|
203
207
|
- lib/foreman_maintain/utils/hammer.rb
|
204
208
|
- lib/foreman_maintain/version.rb
|
205
209
|
- lib/foreman_maintain/yaml_storage.rb
|
@@ -1,57 +0,0 @@
|
|
1
|
-
class Checks::DiskSpeedMinimal < ForemanMaintain::Check
|
2
|
-
metadata do
|
3
|
-
label :disk_io
|
4
|
-
description 'Check for recommended disk speed of pulp, mongodb, pgsql dir.'
|
5
|
-
tags :pre_upgrade
|
6
|
-
|
7
|
-
preparation_steps { Procedures::Packages::Install.new(:packages => %w[hdparm fio]) }
|
8
|
-
|
9
|
-
confine do
|
10
|
-
feature(:katello)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
EXPECTED_IO = 80
|
15
|
-
DEFAULT_UNIT = 'MB/sec'.freeze
|
16
|
-
|
17
|
-
def run
|
18
|
-
with_spinner(description) do |spinner|
|
19
|
-
io_obj, success = compute_disk_speed(spinner)
|
20
|
-
spinner.update('Finished')
|
21
|
-
|
22
|
-
assert(success, io_obj.slow_disk_error_msg)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def check_only_single_device?
|
27
|
-
feature(:katello).data_dirs.map do |dir|
|
28
|
-
ForemanMaintain::Utils::Disk::Device.new(dir).name
|
29
|
-
end.uniq.length <= 1
|
30
|
-
end
|
31
|
-
|
32
|
-
def dirs_to_check
|
33
|
-
return feature(:katello).data_dirs.first(1) if check_only_single_device?
|
34
|
-
feature(:katello).data_dirs
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def compute_disk_speed(spinner)
|
40
|
-
success = true
|
41
|
-
io_obj = ForemanMaintain::Utils::Disk::NilDevice.new
|
42
|
-
|
43
|
-
dirs_to_check.each do |dir|
|
44
|
-
io_obj = ForemanMaintain::Utils::Disk::Device.new(dir)
|
45
|
-
|
46
|
-
spinner.update("[Speed check In-Progress] device: #{io_obj.name}")
|
47
|
-
|
48
|
-
next if io_obj.read_speed >= EXPECTED_IO
|
49
|
-
|
50
|
-
success = false
|
51
|
-
logger.info "Slow disk detected #{dir}: #{io_obj.read_speed} #{io_obj.unit}."
|
52
|
-
break
|
53
|
-
end
|
54
|
-
|
55
|
-
[io_obj, success]
|
56
|
-
end
|
57
|
-
end
|