foreman_maintain 1.10.3 → 1.12.0
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/definitions/checks/container/podman_login.rb +30 -0
- data/definitions/checks/iop_advisor/db_up.rb +33 -0
- data/definitions/checks/iop_inventory/db_up.rb +33 -0
- data/definitions/checks/iop_remediations/db_up.rb +33 -0
- data/definitions/checks/iop_vmaas/db_up.rb +33 -0
- data/definitions/checks/iop_vulnerability/db_up.rb +33 -0
- data/definitions/features/containers.rb +8 -0
- data/definitions/features/iop.rb +46 -0
- data/definitions/features/iop_advisor_database.rb +45 -0
- data/definitions/features/iop_inventory_database.rb +45 -0
- data/definitions/features/iop_remediations_database.rb +45 -0
- data/definitions/features/iop_vmaas_database.rb +45 -0
- data/definitions/features/iop_vulnerability_database.rb +45 -0
- data/definitions/procedures/backup/online/iop_advisor_db.rb +20 -0
- data/definitions/procedures/backup/online/iop_inventory_db.rb +20 -0
- data/definitions/procedures/backup/online/iop_remediations_db.rb +21 -0
- data/definitions/procedures/backup/online/iop_vmaas_db.rb +20 -0
- data/definitions/procedures/backup/online/iop_vulnerability_db.rb +21 -0
- data/definitions/procedures/restore/drop_databases.rb +46 -1
- data/definitions/procedures/restore/iop_advisor_dump.rb +27 -0
- data/definitions/procedures/restore/iop_inventory_dump.rb +27 -0
- data/definitions/procedures/restore/iop_remediations_dump.rb +27 -0
- data/definitions/procedures/restore/iop_vmaas_dump.rb +25 -0
- data/definitions/procedures/restore/iop_vulnerability_dump.rb +27 -0
- data/definitions/reports/advisor_on_prem_remediations.rb +33 -0
- data/definitions/reports/alternate_content_sources.rb +46 -0
- data/definitions/reports/content.rb +54 -0
- data/definitions/reports/image_mode_hosts.rb +50 -0
- data/definitions/reports/inventory.rb +25 -1
- data/definitions/reports/networking.rb +78 -0
- data/definitions/reports/platform.rb +1 -1
- data/definitions/scenarios/backup.rb +10 -0
- data/definitions/scenarios/restore.rb +25 -0
- data/definitions/scenarios/satellite_upgrade.rb +1 -0
- data/definitions/scenarios/update.rb +1 -0
- data/lib/foreman_maintain/cli/report_command.rb +112 -10
- data/lib/foreman_maintain/concerns/downstream.rb +5 -0
- data/lib/foreman_maintain/utils/backup.rb +5 -0
- data/lib/foreman_maintain/utils/service/systemd.rb +2 -2
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +31 -3
@@ -3,23 +3,125 @@ module ForemanMaintain
|
|
3
3
|
class ReportCommand < Base
|
4
4
|
extend Concerns::Finders
|
5
5
|
|
6
|
+
def generate_report
|
7
|
+
scenario = run_scenario(Scenarios::Report::Generate.new({}, [:reports])).first
|
8
|
+
|
9
|
+
# description can be used too
|
10
|
+
report_data = scenario.steps.map(&:data).compact.reduce(&:merge).transform_keys(&:to_s)
|
11
|
+
report_data['version'] = 1
|
12
|
+
report_data
|
13
|
+
end
|
14
|
+
|
15
|
+
def save_report(report, file)
|
16
|
+
if file
|
17
|
+
File.write(file, report)
|
18
|
+
else
|
19
|
+
puts report
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
6
23
|
option '--output', 'FILE', 'Output the generate report into FILE'
|
7
24
|
subcommand 'generate', 'Generates the usage reports' do
|
8
25
|
def execute
|
9
|
-
|
10
|
-
|
11
|
-
# description can be used too
|
12
|
-
report_data = scenario.steps.map(&:data).compact.reduce(&:merge).transform_keys(&:to_s)
|
13
|
-
report_data['version'] = 1
|
26
|
+
report_data = generate_report
|
14
27
|
yaml = report_data.to_yaml
|
15
|
-
|
16
|
-
|
17
|
-
else
|
18
|
-
puts yaml
|
19
|
-
end
|
28
|
+
save_report(yaml, @output)
|
29
|
+
|
20
30
|
exit runner.exit_code
|
21
31
|
end
|
22
32
|
end
|
33
|
+
|
34
|
+
option '--input', 'FILE', 'Input the report from FILE'
|
35
|
+
option '--output', 'FILE', 'Output the condense report into FILE'
|
36
|
+
option '--max-age', 'HOURS', 'Max age of the report in hours'
|
37
|
+
subcommand 'condense',
|
38
|
+
'Generate a JSON formatted report with condensed data from the original report.' do
|
39
|
+
def execute
|
40
|
+
data = if fresh_enough?(@input, @max_age)
|
41
|
+
YAML.load_file(@input)
|
42
|
+
else
|
43
|
+
generate_report
|
44
|
+
end
|
45
|
+
|
46
|
+
report = condense_report(data)
|
47
|
+
report = prefix_keys(report)
|
48
|
+
save_report(JSON.dump(report), @output)
|
49
|
+
end
|
50
|
+
|
51
|
+
def condense_report(data)
|
52
|
+
result = {}
|
53
|
+
%w[advisor_on_prem_remediations_count rhel_ai_workload_host_count].each do |key|
|
54
|
+
result[key] = data[key] || 0
|
55
|
+
end
|
56
|
+
result.merge!(aggregate_host_count(data))
|
57
|
+
result.merge!(aggregate_image_mode_host_count(data))
|
58
|
+
result.merge!(aggregate_networking_metrics(data))
|
59
|
+
result
|
60
|
+
end
|
61
|
+
|
62
|
+
# Aggregates the host count numbers. The goal is to distinguish
|
63
|
+
# - RHEL hosts
|
64
|
+
# - RedHat family but not RHEL hosts
|
65
|
+
# - Other hosts
|
66
|
+
def aggregate_host_count(data)
|
67
|
+
result = {}
|
68
|
+
rhel_count = data['hosts_by_os_count|RedHat'] || 0
|
69
|
+
rh_count = data['hosts_by_family_count|Redhat'] || 0
|
70
|
+
result['host_rhel_count'] = rhel_count
|
71
|
+
result['host_redhat_count'] = rh_count - rhel_count
|
72
|
+
result['host_other_count'] = data.select do |k, _|
|
73
|
+
k.start_with?('hosts_by_os_count')
|
74
|
+
end.values.sum - rhel_count - rh_count
|
75
|
+
result
|
76
|
+
end
|
77
|
+
|
78
|
+
def aggregate_image_mode_host_count(data)
|
79
|
+
count = data.select { |k, _| k.start_with?('image_mode_hosts_by_os_count') }.values.sum
|
80
|
+
{ 'image_mode_host_count' => count }
|
81
|
+
end
|
82
|
+
|
83
|
+
def aggregate_networking_metrics(data)
|
84
|
+
ipv6 = any_positive?(data, %w[subnet_ipv6_count hosts_with_ipv6only_interface_count
|
85
|
+
foreman_interfaces_ipv6only_count])
|
86
|
+
# Deployment is considered to run in dualstack mode if:
|
87
|
+
# - Foreman has both ipv6 and ipv4 addresses on a single interface
|
88
|
+
# - or if any host in Foreman has both ipv6 and ipv4 addresses on a single interface
|
89
|
+
dualstack = any_positive?(data, %w[hosts_with_dualstack_interface_count
|
90
|
+
foreman_interfaces_dualstack_count])
|
91
|
+
|
92
|
+
# - or if there are both ipv4 and ipv6 subnets defined
|
93
|
+
dualstack |= all_positive?(data, %w[subnet_ipv4_count subnet_ipv6_count])
|
94
|
+
|
95
|
+
# - or if any host in Foreman has an interface with only an ipv4 address
|
96
|
+
# as well as another interface with ipv6 address
|
97
|
+
dualstack |= all_positive?(data, %w[hosts_with_ipv4only_interface_count
|
98
|
+
hosts_with_ipv6only_interface_count])
|
99
|
+
|
100
|
+
# - or if Foreman has an interface with only an ipv4 address
|
101
|
+
# as well as another interface with ipv6 address
|
102
|
+
dualstack |= all_positive?(data,
|
103
|
+
%w[foreman_interfaces_ipv4only_count foreman_interfaces_ipv6only_count])
|
104
|
+
|
105
|
+
{ 'use_dualstack' => dualstack, 'use_ipv6' => ipv6 }
|
106
|
+
end
|
107
|
+
|
108
|
+
def all_positive?(source, keys)
|
109
|
+
source.values_at(*keys).map { |x| x || 0 }.all?(&:positive?)
|
110
|
+
end
|
111
|
+
|
112
|
+
def any_positive?(source, keys)
|
113
|
+
source.values_at(*keys).map { |x| x || 0 }.any?(&:positive?)
|
114
|
+
end
|
115
|
+
|
116
|
+
def prefix_keys(data)
|
117
|
+
data.transform_keys { |key| 'foreman.' + key }
|
118
|
+
end
|
119
|
+
|
120
|
+
def fresh_enough?(input, max_age)
|
121
|
+
@input && File.exist?(input) &&
|
122
|
+
(@max_age.nil? || (Time.now - File.stat(input).mtime <= 60 * 60 * max_age.to_i))
|
123
|
+
end
|
124
|
+
end
|
23
125
|
end
|
24
126
|
end
|
25
127
|
end
|
@@ -2,6 +2,7 @@ module ForemanMaintain
|
|
2
2
|
module Concerns
|
3
3
|
module Downstream
|
4
4
|
SATELLITE_MAINTAIN_CONFIG = '/usr/share/satellite-maintain/config.yml'.freeze
|
5
|
+
REDHAT_REPO_FILE = '/etc/yum.repos.d/redhat.repo'.freeze
|
5
6
|
|
6
7
|
def current_version
|
7
8
|
raise NotImplementedError
|
@@ -57,6 +58,10 @@ module ForemanMaintain
|
|
57
58
|
ForemanMaintain.upgrade_in_progress == satellite_maintain_target_version
|
58
59
|
end
|
59
60
|
|
61
|
+
def connected?
|
62
|
+
File.exist?(REDHAT_REPO_FILE) && File.new(REDHAT_REPO_FILE).read.include?('https://cdn.redhat.com')
|
63
|
+
end
|
64
|
+
|
60
65
|
private
|
61
66
|
|
62
67
|
def satellite_maintain_config
|
@@ -31,6 +31,11 @@ module ForemanMaintain
|
|
31
31
|
:pgsql_data => map_file(@backup_dir, 'pgsql_data.tar.gz'),
|
32
32
|
:pulp_data => map_file(@backup_dir, 'pulp_data.tar'),
|
33
33
|
:foreman_dump => map_file(@backup_dir, 'foreman.dump'),
|
34
|
+
:iop_advisor_dump => map_file(@backup_dir, 'iop_advisor.dump'),
|
35
|
+
:iop_inventory_dump => map_file(@backup_dir, 'iop_inventory.dump'),
|
36
|
+
:iop_remediations_dump => map_file(@backup_dir, 'iop_remediations.dump'),
|
37
|
+
:iop_vmaas_dump => map_file(@backup_dir, 'iop_vmaas.dump'),
|
38
|
+
:iop_vulnerability_dump => map_file(@backup_dir, 'iop_vulnerability.dump'),
|
34
39
|
:candlepin_dump => map_file(@backup_dir, 'candlepin.dump'),
|
35
40
|
:config_files => map_file(@backup_dir, 'config_files.tar.gz'),
|
36
41
|
:metadata => map_file(@backup_dir, 'metadata.yml'),
|
@@ -50,12 +50,12 @@ module ForemanMaintain::Utils
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def exist?
|
53
|
-
['enabled', 'disabled'].include?(service_enabled_status)
|
53
|
+
['enabled', 'disabled', 'generated'].include?(service_enabled_status)
|
54
54
|
end
|
55
55
|
|
56
56
|
def enabled?
|
57
57
|
if @sys.systemd_installed?
|
58
|
-
|
58
|
+
['enabled', 'generated'].include?(service_enabled_status)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: clamp
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- definitions/checks/check_ipv6_disable.rb
|
163
163
|
- definitions/checks/check_sha1_certificate_authority.rb
|
164
164
|
- definitions/checks/check_tmout.rb
|
165
|
+
- definitions/checks/container/podman_login.rb
|
165
166
|
- definitions/checks/disk/available_space.rb
|
166
167
|
- definitions/checks/disk/available_space_candlepin.rb
|
167
168
|
- definitions/checks/disk/available_space_postgresql13.rb
|
@@ -184,6 +185,11 @@ files:
|
|
184
185
|
- definitions/checks/foreman_tasks/invalid/check_planning_state.rb
|
185
186
|
- definitions/checks/foreman_tasks/not_paused.rb
|
186
187
|
- definitions/checks/foreman_tasks/not_running.rb
|
188
|
+
- definitions/checks/iop_advisor/db_up.rb
|
189
|
+
- definitions/checks/iop_inventory/db_up.rb
|
190
|
+
- definitions/checks/iop_remediations/db_up.rb
|
191
|
+
- definitions/checks/iop_vmaas/db_up.rb
|
192
|
+
- definitions/checks/iop_vulnerability/db_up.rb
|
187
193
|
- definitions/checks/maintenance_mode/check_consistency.rb
|
188
194
|
- definitions/checks/non_rh_packages.rb
|
189
195
|
- definitions/checks/package_manager/dnf/validate_dnf_config.rb
|
@@ -206,6 +212,7 @@ files:
|
|
206
212
|
- definitions/features/candlepin.rb
|
207
213
|
- definitions/features/candlepin_database.rb
|
208
214
|
- definitions/features/capsule.rb
|
215
|
+
- definitions/features/containers.rb
|
209
216
|
- definitions/features/cron.rb
|
210
217
|
- definitions/features/dynflow_sidekiq.rb
|
211
218
|
- definitions/features/foreman_cockpit.rb
|
@@ -218,6 +225,12 @@ files:
|
|
218
225
|
- definitions/features/hammer.rb
|
219
226
|
- definitions/features/installer.rb
|
220
227
|
- definitions/features/instance.rb
|
228
|
+
- definitions/features/iop.rb
|
229
|
+
- definitions/features/iop_advisor_database.rb
|
230
|
+
- definitions/features/iop_inventory_database.rb
|
231
|
+
- definitions/features/iop_remediations_database.rb
|
232
|
+
- definitions/features/iop_vmaas_database.rb
|
233
|
+
- definitions/features/iop_vulnerability_database.rb
|
221
234
|
- definitions/features/iptables.rb
|
222
235
|
- definitions/features/katello.rb
|
223
236
|
- definitions/features/katello_install.rb
|
@@ -239,6 +252,11 @@ files:
|
|
239
252
|
- definitions/procedures/backup/metadata.rb
|
240
253
|
- definitions/procedures/backup/online/candlepin_db.rb
|
241
254
|
- definitions/procedures/backup/online/foreman_db.rb
|
255
|
+
- definitions/procedures/backup/online/iop_advisor_db.rb
|
256
|
+
- definitions/procedures/backup/online/iop_inventory_db.rb
|
257
|
+
- definitions/procedures/backup/online/iop_remediations_db.rb
|
258
|
+
- definitions/procedures/backup/online/iop_vmaas_db.rb
|
259
|
+
- definitions/procedures/backup/online/iop_vulnerability_db.rb
|
242
260
|
- definitions/procedures/backup/online/pulpcore_db.rb
|
243
261
|
- definitions/procedures/backup/prepare_directory.rb
|
244
262
|
- definitions/procedures/backup/pulp.rb
|
@@ -292,6 +310,11 @@ files:
|
|
292
310
|
- definitions/procedures/restore/extract_files.rb
|
293
311
|
- definitions/procedures/restore/foreman_dump.rb
|
294
312
|
- definitions/procedures/restore/installer_reset.rb
|
313
|
+
- definitions/procedures/restore/iop_advisor_dump.rb
|
314
|
+
- definitions/procedures/restore/iop_inventory_dump.rb
|
315
|
+
- definitions/procedures/restore/iop_remediations_dump.rb
|
316
|
+
- definitions/procedures/restore/iop_vmaas_dump.rb
|
317
|
+
- definitions/procedures/restore/iop_vulnerability_dump.rb
|
295
318
|
- definitions/procedures/restore/pulpcore_dump.rb
|
296
319
|
- definitions/procedures/restore/reindex_databases.rb
|
297
320
|
- definitions/procedures/restore/required_packages.rb
|
@@ -306,13 +329,18 @@ files:
|
|
306
329
|
- definitions/procedures/service/stop.rb
|
307
330
|
- definitions/procedures/sync_plans/disable.rb
|
308
331
|
- definitions/procedures/sync_plans/enable.rb
|
332
|
+
- definitions/reports/advisor_on_prem_remediations.rb
|
333
|
+
- definitions/reports/alternate_content_sources.rb
|
309
334
|
- definitions/reports/compliance.rb
|
335
|
+
- definitions/reports/content.rb
|
310
336
|
- definitions/reports/external_auth_source.rb
|
311
337
|
- definitions/reports/grouping.rb
|
338
|
+
- definitions/reports/image_mode_hosts.rb
|
312
339
|
- definitions/reports/instance.rb
|
313
340
|
- definitions/reports/inventory.rb
|
314
341
|
- definitions/reports/kerberos.rb
|
315
342
|
- definitions/reports/ldap_auth_source.rb
|
343
|
+
- definitions/reports/networking.rb
|
316
344
|
- definitions/reports/oidc_usage.rb
|
317
345
|
- definitions/reports/platform.rb
|
318
346
|
- definitions/reports/provisioning.rb
|
@@ -446,7 +474,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
446
474
|
- !ruby/object:Gem::Version
|
447
475
|
version: '0'
|
448
476
|
requirements: []
|
449
|
-
rubygems_version: 3.6.
|
477
|
+
rubygems_version: 3.6.9
|
450
478
|
specification_version: 4
|
451
479
|
summary: Foreman maintenance tool belt
|
452
480
|
test_files: []
|