foreman_maintain 1.12.0 → 1.12.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfa2280e285e63ea4e7b6269dc6761598c17034fc9febfde0aca731b19a684c3
4
- data.tar.gz: b83257b1cefd0ed6e6ad12205442b1817a2b2395b315b08f59a34c8b09833517
3
+ metadata.gz: 841269b0b17944b3a732b728e7c51ba5c11bdec27b47c45ce6b13fb61ec8be06
4
+ data.tar.gz: 966dd22a328585cb68ecb248341b8b566787f7efa6f590eb8dc1877203fdc895
5
5
  SHA512:
6
- metadata.gz: da581d87a81c7b38ab139245323e2ad3f9958fff5094c27b00ef28ff7e519741f18bb909388c660208ce2531ddc14bb39c7873deeacc1502d11185417f4bb321
7
- data.tar.gz: 143cd40662be08087e1da5f2cb29c40dbe24bbecd19ea292c6c34394b218606aeb024ddd2757d7fbbbb0edfc5d1220b92dcde0596bd011be6e8ec2cc47274a3c
6
+ metadata.gz: f996ba857e7ad9598f6b4e26811710387d8592c2841bb26dbf63660d44774c388312ab217d795dbd24c258767b3c276b048f13ced797927703dd6c85dbde106f
7
+ data.tar.gz: 72cc8e83ee3ff2fb76fdcaa226695c05b90fe70ed63bb82b7d65e8307d82cbab6b6141b51a8f5ceaac410648d41f9308744998b255a9ab2e9f8bf43b0d50d8fa
@@ -10,7 +10,7 @@ class Features::Iop < ForemanMaintain::Feature
10
10
 
11
11
  def config_files
12
12
  [
13
- '/var/lib/kafka',
13
+ '/var/lib/containers/storage/volumes/iop-core-kafka-data',
14
14
  '/var/lib/vmaas',
15
15
  ]
16
16
  end
@@ -39,7 +39,6 @@ class Features::Iop < ForemanMaintain::Feature
39
39
  system_service('iop-service-vuln-listener', 20),
40
40
  system_service('iop-service-vuln-manager', 20),
41
41
  system_service('iop-service-vuln-taskomatic', 20),
42
- system_service('iop-service-vuln-vmaas-sync', 20),
43
42
  ]
44
43
  end
45
44
  # rubocop:enable Metrics/MethodLength
@@ -23,13 +23,19 @@ class Features::IopAdvisorDatabase < ForemanMaintain::Feature
23
23
 
24
24
  private
25
25
 
26
+ # rubocop:disable Metrics/MethodLength
26
27
  def load_configuration
27
- podman_command = "podman exec iop-service-advisor-api bash -c 'env |grep DB_'"
28
- podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
28
+ podman_command = "podman exec iop-service-advisor-backend-api bash -c 'env |grep DB_'"
29
+ podman_result = begin
30
+ execute!(podman_command, merge_stderr: false).lines.map do |l|
31
+ l.strip.split('=')
32
+ end.to_h
33
+ rescue ForemanMaintain::Error::ExecutionError
34
+ {}
35
+ end
31
36
 
32
- db_host = if podman_result['ADVISOR_DB_HOST'].start_with?('/var/run/postgresql')
37
+ db_host = if podman_result['ADVISOR_DB_HOST'].nil? ||
38
+ podman_result['ADVISOR_DB_HOST'].start_with?('/var/run/postgresql')
33
39
  'localhost'
34
40
  else
35
41
  podman_result['ADVISOR_DB_HOST']
@@ -42,4 +48,5 @@ class Features::IopAdvisorDatabase < ForemanMaintain::Feature
42
48
  'username' => podman_result['ADVISOR_DB_USER'],
43
49
  }
44
50
  end
51
+ # rubocop:enable Metrics/MethodLength
45
52
  end
@@ -23,13 +23,19 @@ class Features::IopInventoryDatabase < ForemanMaintain::Feature
23
23
 
24
24
  private
25
25
 
26
+ # rubocop:disable Metrics/MethodLength
26
27
  def load_configuration
27
28
  podman_command = "podman exec iop-core-host-inventory bash -c 'env |grep INVENTORY_DB_'"
28
- podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
29
+ podman_result = begin
30
+ execute!(podman_command, merge_stderr: false).lines.map do |l|
31
+ l.strip.split('=')
32
+ end.to_h
33
+ rescue ForemanMaintain::Error::ExecutionError
34
+ {}
35
+ end
31
36
 
32
- db_host = if podman_result['INVENTORY_DB_HOST'].start_with?('/var/run/postgresql')
37
+ db_host = if podman_result['INVENTORY_DB_HOST'].nil? ||
38
+ podman_result['INVENTORY_DB_HOST'].start_with?('/var/run/postgresql')
33
39
  'localhost'
34
40
  else
35
41
  podman_result['INVENTORY_DB_HOST']
@@ -42,4 +48,5 @@ class Features::IopInventoryDatabase < ForemanMaintain::Feature
42
48
  'username' => podman_result['INVENTORY_DB_USER'],
43
49
  }
44
50
  end
51
+ # rubocop:enable Metrics/MethodLength
45
52
  end
@@ -23,13 +23,19 @@ class Features::IopRemediationsDatabase < ForemanMaintain::Feature
23
23
 
24
24
  private
25
25
 
26
+ # rubocop:disable Metrics/MethodLength
26
27
  def load_configuration
27
28
  podman_command = "podman exec iop-service-remediations-api bash -c 'env |grep DB_'"
28
- podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
29
+ podman_result = begin
30
+ execute!(podman_command, merge_stderr: false).lines.map do |l|
31
+ l.strip.split('=')
32
+ end.to_h
33
+ rescue ForemanMaintain::Error::ExecutionError
34
+ {}
35
+ end
31
36
 
32
- db_host = if podman_result['DB_HOST'].start_with?('/var/run/postgresql')
37
+ db_host = if podman_result['DB_HOST'].nil? ||
38
+ podman_result['DB_HOST'].start_with?('/var/run/postgresql')
33
39
  'localhost'
34
40
  else
35
41
  podman_result['DB_HOST']
@@ -42,4 +48,5 @@ class Features::IopRemediationsDatabase < ForemanMaintain::Feature
42
48
  'username' => podman_result['DB_USERNAME'],
43
49
  }
44
50
  end
51
+ # rubocop:enable Metrics/MethodLength
45
52
  end
@@ -23,13 +23,19 @@ class Features::IopVmaasDatabase < ForemanMaintain::Feature
23
23
 
24
24
  private
25
25
 
26
+ # rubocop:disable Metrics/MethodLength
26
27
  def load_configuration
27
28
  podman_command = "podman exec iop-service-vmaas-reposcan bash -c 'env |grep POSTGRESQL_'"
28
- podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
29
+ podman_result = begin
30
+ execute!(podman_command, merge_stderr: false).lines.map do |l|
31
+ l.strip.split('=')
32
+ end.to_h
33
+ rescue ForemanMaintain::Error::ExecutionError
34
+ {}
35
+ end
31
36
 
32
- db_host = if podman_result['POSTGRESQL_HOST'].start_with?('/var/run/postgresql')
37
+ db_host = if podman_result['POSTGRESQL_HOST'].nil? ||
38
+ podman_result['POSTGRESQL_HOST'].start_with?('/var/run/postgresql')
33
39
  'localhost'
34
40
  else
35
41
  podman_result['POSTGRESQL_HOST']
@@ -42,4 +48,5 @@ class Features::IopVmaasDatabase < ForemanMaintain::Feature
42
48
  'username' => podman_result['POSTGRESQL_USER'],
43
49
  }
44
50
  end
51
+ # rubocop:enable Metrics/MethodLength
45
52
  end
@@ -23,13 +23,19 @@ class Features::IopVulnerabilityDatabase < ForemanMaintain::Feature
23
23
 
24
24
  private
25
25
 
26
+ # rubocop:disable Metrics/MethodLength
26
27
  def load_configuration
27
28
  podman_command = "podman exec iop-service-vuln-manager bash -c 'env |grep POSTGRES_'"
28
- podman_result = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
29
+ podman_result = begin
30
+ execute!(podman_command, merge_stderr: false).lines.map do |l|
31
+ l.strip.split('=')
32
+ end.to_h
33
+ rescue ForemanMaintain::Error::ExecutionError
34
+ {}
35
+ end
31
36
 
32
- db_host = if podman_result['POSTGRES_HOST'].start_with?('/var/run/postgresql')
37
+ db_host = if podman_result['POSTGRES_HOST'].nil? ||
38
+ podman_result['POSTGRES_HOST'].start_with?('/var/run/postgresql')
33
39
  'localhost'
34
40
  else
35
41
  podman_result['POSTGRES_HOST']
@@ -42,4 +48,5 @@ class Features::IopVulnerabilityDatabase < ForemanMaintain::Feature
42
48
  'username' => podman_result['POSTGRES_USER'],
43
49
  }
44
50
  end
51
+ # rubocop:enable Metrics/MethodLength
45
52
  end
@@ -90,10 +90,6 @@ module Scenarios::Foreman
90
90
 
91
91
  def compose
92
92
  add_step(Procedures::Repositories::Setup.new(:version => 'nightly'))
93
- if el8?
94
- modules_to_switch = ['postgresql:13']
95
- add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch))
96
- end
97
93
 
98
94
  add_step(Procedures::Packages::Update.new(
99
95
  :assumeyes => true,
@@ -92,12 +92,6 @@ module Scenarios::Satellite
92
92
 
93
93
  def compose
94
94
  add_step(Procedures::Repositories::Setup.new(:version => target_version))
95
- if el8?
96
- modules_to_switch = ['postgresql:13']
97
- add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch))
98
- modules_to_enable = ["#{feature(:instance).downstream.module_name}:#{el_short_name}"]
99
- add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
100
- end
101
95
  add_steps(
102
96
  Procedures::Packages::Update.new(
103
97
  :assumeyes => true,
@@ -74,8 +74,6 @@ module ForemanMaintain::Scenarios
74
74
  )
75
75
  end
76
76
 
77
- ForemanMaintain.enable_maintenance_module
78
-
79
77
  add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
80
78
  enabled_repos: req_repos_to_update_pkgs))
81
79
  end
@@ -20,8 +20,9 @@ module ForemanMaintain
20
20
  end
21
21
  end
22
22
 
23
- option '--output', 'FILE', 'Output the generate report into FILE'
24
23
  subcommand 'generate', 'Generates the usage reports' do
24
+ option '--output', 'FILE', 'Output the generate report into FILE'
25
+
25
26
  def execute
26
27
  report_data = generate_report
27
28
  yaml = report_data.to_yaml
@@ -31,11 +32,12 @@ module ForemanMaintain
31
32
  end
32
33
  end
33
34
 
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
35
  subcommand 'condense',
38
36
  'Generate a JSON formatted report with condensed data from the original report.' do
37
+ option '--input', 'FILE', 'Input the report from FILE'
38
+ option '--output', 'FILE', 'Output the condense report into FILE'
39
+ option '--max-age', 'HOURS', 'Max age of the report in hours'
40
+
39
41
  def execute
40
42
  data = if fresh_enough?(@input, @max_age)
41
43
  YAML.load_file(@input)
@@ -43,76 +45,11 @@ module ForemanMaintain
43
45
  generate_report
44
46
  end
45
47
 
46
- report = condense_report(data)
48
+ report = Utils::ReportCondenser.condense_report(data)
47
49
  report = prefix_keys(report)
48
50
  save_report(JSON.dump(report), @output)
49
51
  end
50
52
 
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
53
  def prefix_keys(data)
117
54
  data.transform_keys { |key| 'foreman.' + key }
118
55
  end
@@ -54,10 +54,6 @@ module ForemanMaintain
54
54
  File.exist?('/etc/redhat-release')
55
55
  end
56
56
 
57
- def el8?
58
- el_major_version == 8
59
- end
60
-
61
57
  def debian?
62
58
  os_id == 'debian'
63
59
  end
@@ -0,0 +1,72 @@
1
+ module ForemanMaintain::Utils
2
+ module ReportCondenser
3
+ class << self
4
+ def condense_report(data)
5
+ result = {}
6
+ %w[advisor_on_prem_remediations_count rhel_ai_workload_host_count].each do |key|
7
+ result[key] = data[key] || 0
8
+ end
9
+ result.merge!(aggregate_host_count(data))
10
+ result.merge!(aggregate_image_mode_host_count(data))
11
+ result.merge!(aggregate_networking_metrics(data))
12
+ result
13
+ end
14
+
15
+ # Aggregates the host count numbers. The goal is to distinguish
16
+ # - RHEL hosts
17
+ # - RedHat family but not RHEL hosts
18
+ # - Other hosts
19
+ def aggregate_host_count(data)
20
+ result = {}
21
+ rhel_count = data['hosts_by_os_count|RedHat'] || 0
22
+ rh_count = data['hosts_by_family_count|Redhat'] || 0
23
+ result['host_rhel_count'] = rhel_count
24
+ result['host_redhat_without_rhel_count'] = rh_count - rhel_count
25
+ result['host_other_count'] = data.select do |k, _|
26
+ k.start_with?('hosts_by_os_count')
27
+ end.values.sum - rh_count
28
+ result
29
+ end
30
+
31
+ def aggregate_image_mode_host_count(data)
32
+ count = data.select { |k, _| k.start_with?('image_mode_hosts_by_os_count') }.values.sum
33
+ { 'image_mode_host_count' => count }
34
+ end
35
+
36
+ def aggregate_networking_metrics(data)
37
+ ipv6 = any_positive?(data, %w[subnet_ipv6_count hosts_with_ipv6only_interface_count
38
+ foreman_interfaces_ipv6only_count])
39
+ # Deployment is considered to run in dualstack mode if:
40
+ # - Foreman has both ipv6 and ipv4 addresses on a single interface
41
+ # - or if any host in Foreman has both ipv6 and ipv4 addresses on a single interface
42
+ dualstack = any_positive?(data, %w[hosts_with_dualstack_interface_count
43
+ foreman_interfaces_dualstack_count])
44
+
45
+ # - or if there are both ipv4 and ipv6 subnets defined
46
+ dualstack |= all_positive?(data, %w[subnet_ipv4_count subnet_ipv6_count])
47
+
48
+ # - or if any host in Foreman has an interface with only an ipv4 address
49
+ # as well as another interface with ipv6 address
50
+ dualstack |= all_positive?(data, %w[hosts_with_ipv4only_interface_count
51
+ hosts_with_ipv6only_interface_count])
52
+
53
+ # - or if Foreman has an interface with only an ipv4 address
54
+ # as well as another interface with ipv6 address
55
+ dualstack |= all_positive?(data,
56
+ %w[foreman_interfaces_ipv4only_count foreman_interfaces_ipv6only_count])
57
+
58
+ { 'use_dualstack' => dualstack, 'use_ipv6' => ipv6 }
59
+ end
60
+
61
+ private
62
+
63
+ def all_positive?(source, keys)
64
+ source.values_at(*keys).map { |x| x || 0 }.all?(&:positive?)
65
+ end
66
+
67
+ def any_positive?(source, keys)
68
+ source.values_at(*keys).map { |x| x || 0 }.any?(&:positive?)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -4,5 +4,6 @@ require 'foreman_maintain/utils/disk'
4
4
  require 'foreman_maintain/utils/bash'
5
5
  require 'foreman_maintain/utils/hash_tools'
6
6
  require 'foreman_maintain/utils/curl_response'
7
+ require 'foreman_maintain/utils/report_condenser'
7
8
  require 'foreman_maintain/utils/service'
8
9
  require 'foreman_maintain/utils/system_helpers'
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.12.0'.freeze
2
+ VERSION = '1.12.2'.freeze
3
3
  end
@@ -191,7 +191,6 @@ module ForemanMaintain
191
191
 
192
192
  puts "Checking for new version of #{packages_to_update_str}..."
193
193
 
194
- enable_maintenance_module
195
194
  package_manager = ForemanMaintain.package_manager
196
195
 
197
196
  if package_manager.update_available?(packages_to_update)
@@ -204,19 +203,6 @@ module ForemanMaintain
204
203
  puts "Nothing to update, can't find new version of #{packages_to_update_str}."
205
204
  end
206
205
 
207
- def enable_maintenance_module
208
- return unless el8?
209
-
210
- maintenance_module = 'satellite-maintenance:el8'
211
- package_manager = ForemanMaintain.package_manager
212
-
213
- if package_manager.module_exists?(maintenance_module) &&
214
- !package_manager.module_enabled?(maintenance_module)
215
- puts "\nEnabling #{maintenance_module} module"
216
- package_manager.enable_module(maintenance_module)
217
- end
218
- end
219
-
220
206
  def main_package_name
221
207
  el? ? 'rubygem-foreman_maintain' : 'ruby-foreman-maintain'
222
208
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
@@ -445,6 +445,7 @@ files:
445
445
  - lib/foreman_maintain/utils/disk/nil_device.rb
446
446
  - lib/foreman_maintain/utils/disk/stats.rb
447
447
  - lib/foreman_maintain/utils/hash_tools.rb
448
+ - lib/foreman_maintain/utils/report_condenser.rb
448
449
  - lib/foreman_maintain/utils/response.rb
449
450
  - lib/foreman_maintain/utils/service.rb
450
451
  - lib/foreman_maintain/utils/service/abstract.rb