foreman_maintain 1.10.5 → 1.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0885ff686d1f9c5bb03c5cfa7f32e8da07cd5032dc0cd2f9631f716d8db688d7'
4
- data.tar.gz: f07a9ea59b4dc4723a7e3f2a786269de44fe10d633b9add1b077ae8602d23545
3
+ metadata.gz: 0573bbda58a16e7632d6c074d5d99d4ddbace818cede03002efbc47ca9896f33
4
+ data.tar.gz: '009f7cf5f9fc5d2a7916041266c97dc76fbf44e1c6d670b368edcc0a4bf2c15c'
5
5
  SHA512:
6
- metadata.gz: 70370ebf76c611e79113ad7068ee60907a674e130178635aa1c5c885618a56b765cce656d1efcedaf2f77b76d216a655758fdee85ba57287beb37eba86e09e2e
7
- data.tar.gz: f6db48e5c475b4117d278f851217332d824bc0e6f052c46308780ad95984650f1eeea1a2b5874b170a0d0b592672f78dd9577d8453effc4f0207a4825212a73d
6
+ metadata.gz: 94f026030c038110b5d7fae4985313b3c00fb7e21e51bdd0026915ae017fb4bad826c72e8fa1797cfe78dc5dd89bcfe8d92d17ae25ffe288433e9a4cf278f79d
7
+ data.tar.gz: e7cc1350ad46e6d71a7651e83f9bbb4cdfb3db1eabe39691f84d102bb3ef12491db6920c682e364e8ed1e1db4e762fff2c6d4e11cb370a5b135ff820bc079c37
@@ -10,11 +10,9 @@ class Checks::SystemRegistration < ForemanMaintain::Check
10
10
  end
11
11
 
12
12
  def run
13
- assert(!rhsm_hostname_eql_hostname?, 'System is self registered',
14
- {
15
- :warn => true,
16
- :next_steps => [Procedures::KnowledgeBaseArticle.new(:doc => 'self_registered')],
17
- })
13
+ if rhsm_hostname_eql_hostname?
14
+ warn! 'System is self registered'
15
+ end
18
16
  end
19
17
 
20
18
  def rhsm_hostname
@@ -26,7 +26,6 @@ class Procedures::KnowledgeBaseArticle < ForemanMaintain::Procedure
26
26
  'fix_cpdb_validate_failure' => 'https://access.redhat.com/solutions/3362821',
27
27
  'fix_db_migrate_failure_on_duplicate_roles' => 'https://access.redhat.com/solutions/3998941',
28
28
  'many_fact_values' => 'https://access.redhat.com/solutions/4163891',
29
- 'self_registered' => 'https://access.redhat.com/solutions/3225941',
30
29
  }
31
30
  end
32
31
  end
@@ -0,0 +1,33 @@
1
+ module Reports
2
+ class AdvisorOnPremRemediations < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report number of remediations based on advisor rules from advisor on premise'
5
+ end
6
+
7
+ def run
8
+ data_field('advisor_on_prem_remediations_enabled') { advisor_on_prem_remediations_enabled }
9
+ data_field('advisor_on_prem_remediations_count') { advisor_on_prem_remediations_count }
10
+ end
11
+
12
+ def advisor_on_prem_remediations_enabled
13
+ if @iop_enabled.nil?
14
+ @iop_enabled = feature(:installer)&.answers&.dig(
15
+ 'foreman::plugin::rh_cloud', 'enable_iop_advisor_engine'
16
+ ) || false
17
+ end
18
+ @iop_enabled
19
+ end
20
+
21
+ def advisor_on_prem_remediations_count
22
+ if advisor_on_prem_remediations_enabled
23
+ return sql_count('
24
+ job_invocations AS jobs
25
+ INNER JOIN remote_execution_features AS rexf ON jobs.remote_execution_feature_id = rexf.id
26
+ INNER JOIN template_invocations AS tinv ON jobs.id = tinv.job_invocation_id
27
+ WHERE rexf.label = \'rh_cloud_remediate_hosts\'
28
+ AND tinv.host_id IS NOT NULL
29
+ ')
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,46 @@
1
+ module Checks
2
+ module Report
3
+ class AlternateContentSources < ForemanMaintain::Report
4
+ metadata do
5
+ description 'Facts about ACSs'
6
+ confine do
7
+ feature(:katello)
8
+ end
9
+ end
10
+
11
+ def run
12
+ data_field('custom_alternate_content_sources_count') { custom_alternate_content_sources }
13
+ data_field('simplified_alternate_content_sources_count') do
14
+ simplified_alternate_content_sources
15
+ end
16
+ data_field('rhui_alternate_content_sources_count') { rhui_alternate_content_sources }
17
+ data_field('yum_alternate_content_sources_count') { yum_alternate_content_sources }
18
+ data_field('file_alternate_content_sources_count') { file_alternate_content_sources }
19
+ end
20
+
21
+ def custom_alternate_content_sources
22
+ sql_count(
23
+ "katello_alternate_content_sources WHERE alternate_content_source_type = 'custom'"
24
+ )
25
+ end
26
+
27
+ def simplified_alternate_content_sources
28
+ sql_count(
29
+ "katello_alternate_content_sources WHERE alternate_content_source_type = 'simplified'"
30
+ )
31
+ end
32
+
33
+ def rhui_alternate_content_sources
34
+ sql_count("katello_alternate_content_sources WHERE alternate_content_source_type = 'rhui'")
35
+ end
36
+
37
+ def yum_alternate_content_sources
38
+ sql_count("katello_alternate_content_sources WHERE content_type = 'yum'")
39
+ end
40
+
41
+ def file_alternate_content_sources
42
+ sql_count("katello_alternate_content_sources WHERE content_type = 'file'")
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,54 @@
1
+ module Checks
2
+ module Report
3
+ class Content < ForemanMaintain::Report
4
+ metadata do
5
+ description 'Facts about Katello content'
6
+ confine do
7
+ feature(:katello)
8
+ end
9
+ end
10
+
11
+ def run
12
+ data_field('custom_library_yum_repositories_count') { custom_library_yum_repositories }
13
+ data_field('redhat_library_yum_repositories_count') { redhat_library_yum_repositories }
14
+ data_field('library_debian_repositories_count') { library_repositories('deb') }
15
+ data_field('library_container_repositories_count') { library_repositories('docker') }
16
+ data_field('library_file_repositories_count') { library_repositories('file') }
17
+ data_field('library_python_repositories_count') { library_repositories('python') }
18
+ data_field('library_ansible_collection_repositories_count') do
19
+ library_repositories('ansible_collection')
20
+ end
21
+ data_field('library_ostree_repositories_count') { library_repositories('ostree') }
22
+ end
23
+
24
+ def custom_library_yum_repositories
25
+ query_snippet =
26
+ <<-SQL
27
+ "katello_root_repositories"
28
+ WHERE "katello_root_repositories"."id" NOT IN
29
+ (SELECT "katello_root_repositories"."id" FROM "katello_root_repositories" INNER JOIN "katello_products"
30
+ ON "katello_products"."id" = "katello_root_repositories"."product_id" INNER JOIN "katello_providers"
31
+ ON "katello_providers"."id" = "katello_products"."provider_id" WHERE "katello_providers"."provider_type" = 'Red Hat')
32
+ AND "katello_root_repositories"."content_type" = 'yum'
33
+ SQL
34
+ sql_count(query_snippet)
35
+ end
36
+
37
+ def redhat_library_yum_repositories
38
+ query_snippet =
39
+ <<-SQL
40
+ "katello_root_repositories"
41
+ INNER JOIN "katello_products" ON "katello_products"."id" = "katello_root_repositories"."product_id"
42
+ INNER JOIN "katello_providers" ON "katello_providers"."id" = "katello_products"."provider_id"
43
+ WHERE "katello_providers"."provider_type" = 'Red Hat'
44
+ AND "katello_root_repositories"."content_type" = 'yum'
45
+ SQL
46
+ sql_count(query_snippet)
47
+ end
48
+
49
+ def library_repositories(content_type)
50
+ sql_count("katello_root_repositories WHERE content_type = '#{content_type}'")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ module Reports
2
+ class ImageModeHosts < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report number of image mode hosts registered by operating system'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ merge_data('image_mode_hosts_by_os_count') { image_mode_hosts_by_os_count }
12
+ end
13
+
14
+ # OS usage on image mode hosts
15
+ def image_mode_hosts_by_os_count
16
+ query(
17
+ <<-SQL
18
+ select max(operatingsystems.name) as os_name, count(*) as hosts_count
19
+ from hosts inner join operatingsystems on operatingsystem_id = operatingsystems.id inner join katello_content_facets on hosts.id = katello_content_facets.host_id
20
+ where bootc_booted_digest is not null
21
+ group by operatingsystems.name
22
+ SQL
23
+ ).
24
+ to_h { |row| [row['os_name'], row['hosts_count'].to_i] }
25
+ end
26
+ end
27
+ end
@@ -10,6 +10,7 @@ module Reports
10
10
  merge_data('facts_by_type') { facts_by_type }
11
11
  merge_data('audits') { audits }
12
12
  merge_data('parameters_count') { parameters }
13
+ hosts_running_rhel_ai
13
14
  end
14
15
 
15
16
  # Hosts
@@ -80,5 +81,16 @@ module Reports
80
81
  max_created_at: row['max_created_at'],
81
82
  }
82
83
  end
84
+
85
+ def hosts_running_rhel_ai
86
+ query = <<~SQL
87
+ hosts
88
+ INNER JOIN katello_subscription_facets AS ksf ON hosts.id = ksf.host_id
89
+ INNER JOIN katello_subscription_facet_installed_products AS ksfip ON ksfip.subscription_facet_id = ksf.id
90
+ INNER JOIN katello_installed_products AS kip ON ksfip.installed_product_id = kip.id
91
+ WHERE kip.name = 'Red Hat Enterprise Linux AI'
92
+ SQL
93
+ data_field('rhel_ai_workload_host_count') { sql_count(query) }
94
+ end
83
95
  end
84
96
  end
@@ -0,0 +1,78 @@
1
+ require 'socket'
2
+
3
+ module Reports
4
+ class Networking < ForemanMaintain::Report
5
+ metadata do
6
+ description 'Report information about networking'
7
+ end
8
+
9
+ def run
10
+ subnet_counts_by_type
11
+ hosts_by_address_family
12
+ interfaces_by_address_family
13
+ preference_settings
14
+ end
15
+
16
+ private
17
+
18
+ # How many ipv4 subnets are defined in Foreman?
19
+ # How many ipv6 subnets are defined in Foreman?
20
+ def subnet_counts_by_type
21
+ %w[Ipv4 Ipv6].each do |type|
22
+ data_field("subnet_#{type.downcase}_count") do
23
+ sql_count("subnets where type = 'Subnet::#{type}'")
24
+ end
25
+ end
26
+ end
27
+
28
+ # How many hosts in Foreman have an interface with an ipv4 address but no ipv6 address?
29
+ # How many hosts in Foreman have an interface with no ipv4 address but an ipv6 address?
30
+ # How many hosts in Foreman have an interface with both ipv4 and ipv6 addresses?
31
+ def hosts_by_address_family
32
+ { 'ipv4only': 'nics.ip IS NOT NULL AND nics.ip6 IS NULL',
33
+ 'ipv6only': 'nics.ip IS NULL AND nics.ip6 IS NOT NULL',
34
+ 'dualstack': 'nics.ip IS NOT NULL AND nics.ip6 IS NOT NULL' }.each do |kind, condition|
35
+ query = <<~SQL
36
+ hosts
37
+ WHERE id IN (SELECT host_id FROM nics WHERE #{condition})
38
+ SQL
39
+ data_field("hosts_with_#{kind}_interface_count") { sql_count(query) }
40
+ end
41
+ end
42
+
43
+ # How many of Foreman's interfaces:
44
+ # - only have a non-loopback, non-multicast ipv4 address?
45
+ # - only have a non-loopback, non-multicast, non-link-local ipv6 address?
46
+ # - have a non-loopback, non-multicast ipv4 address
47
+ # as well as a non-loopback, non-multicast, non-link-local ipv6 address?
48
+ def interfaces_by_address_family
49
+ by_name = Socket.getifaddrs.group_by(&:name).transform_values { |addrs| addrs.map(&:addr) }
50
+ with_ipv4, without_ipv4 = by_name.partition { |_name, addrs| relevant_ipv4?(addrs) }
51
+ dualstack, ipv4_only = with_ipv4.partition { |_name, addrs| relevant_ipv6?(addrs) }
52
+ ipv6_only = without_ipv4.select { |_name, addrs| relevant_ipv6?(addrs) }
53
+
54
+ data_field("foreman_interfaces_ipv4only_count") { ipv4_only.count }
55
+ data_field("foreman_interfaces_ipv6only_count") { ipv6_only.count }
56
+ data_field("foreman_interfaces_dualstack_count") { dualstack.count }
57
+ end
58
+
59
+ def relevant_ipv4?(addrs)
60
+ addrs.any? { |addr| addr.ipv4? && !(addr.ipv4_loopback? || addr.ipv4_multicast?) }
61
+ end
62
+
63
+ def relevant_ipv6?(addrs)
64
+ addrs.any? do |addr|
65
+ addr.ipv6? && !(addr.ipv6_loopback? || addr.ipv6_multicast? || addr.ipv6_linklocal?)
66
+ end
67
+ end
68
+
69
+ def preference_settings
70
+ %w[remote_execution_connect_by_ip_prefer_ipv6 discovery_prefer_ipv6].each do |setting|
71
+ data_field("setting_#{setting}") do
72
+ value = sql_setting(setting)
73
+ value.nil? ? false : YAML.safe_load(value)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -57,7 +57,7 @@ module Reports
57
57
 
58
58
  def settings_fields
59
59
  data_field('modified_settings') do
60
- query("select name from settings").
60
+ query("select name from settings WHERE value IS NOT NULL").
61
61
  map { |setting_line| setting_line['name'] }.
62
62
  join(',')
63
63
  end
@@ -116,7 +116,6 @@ module Scenarios::Foreman
116
116
  add_steps(
117
117
  Procedures::RefreshFeatures,
118
118
  Procedures::Service::Start,
119
- Procedures::Pulpcore::RpmDatarepair,
120
119
  Procedures::Crond::Start,
121
120
  Procedures::SyncPlans::Enable,
122
121
  Procedures::MaintenanceMode::DisableMaintenanceMode
@@ -120,7 +120,6 @@ module Scenarios::Satellite
120
120
  add_steps(
121
121
  Procedures::RefreshFeatures,
122
122
  Procedures::Service::Start,
123
- Procedures::Pulpcore::RpmDatarepair,
124
123
  Procedures::Crond::Start,
125
124
  Procedures::SyncPlans::Enable,
126
125
  Procedures::MaintenanceMode::DisableMaintenanceMode,
@@ -137,7 +137,7 @@ module ForemanMaintain
137
137
  option '--label', 'label',
138
138
  'Run only a specific check with a label. ' \
139
139
  '(Use "list" command to see available labels)' do |label|
140
- raise ArgumentError, 'no value provided' if label.nil? || label.empty?
140
+ raise ArgumentError, 'value not specified' if label.nil? || label.empty?
141
141
  underscorize(label).to_sym
142
142
  end
143
143
  end
@@ -147,7 +147,7 @@ module ForemanMaintain
147
147
  'Run only those with all specific set of tags. ' \
148
148
  '(Use list-tags command to see available tags)',
149
149
  :multivalued => true) do |tags|
150
- raise ArgumentError, 'no value provided' if tags.nil? || tags.empty?
150
+ raise ArgumentError, 'value not specified' if tags.nil? || tags.empty?
151
151
  tags.map { |tag| underscorize(tag).to_sym }
152
152
  end
153
153
  end
@@ -166,7 +166,7 @@ module ForemanMaintain
166
166
  if opts.include?('whitelist')
167
167
  option(['-w', '--whitelist'], 'whitelist',
168
168
  'Comma-separated list of labels of steps to be skipped') do |whitelist|
169
- raise ArgumentError, 'no value provided' if whitelist.nil? || whitelist.empty?
169
+ raise ArgumentError, 'value not specified' if whitelist.nil? || whitelist.empty?
170
170
  whitelist.split(',').map(&:strip)
171
171
  end
172
172
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.10.5'.freeze
2
+ VERSION = '1.11.0'.freeze
3
3
  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.10.5
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
@@ -55,16 +55,16 @@ dependencies:
55
55
  name: minitest
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '5.0'
60
+ version: '0'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '5.0'
67
+ version: '0'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: minitest-reporters
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -274,7 +274,6 @@ files:
274
274
  - definitions/procedures/packages/update.rb
275
275
  - definitions/procedures/packages/update_all_confirmation.rb
276
276
  - definitions/procedures/pulpcore/container_handle_image_metadata.rb
277
- - definitions/procedures/pulpcore/rpm_datarepair.rb
278
277
  - definitions/procedures/pulpcore/wait_for_tasks.rb
279
278
  - definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
280
279
  - definitions/procedures/puppet/remove_puppet.rb
@@ -307,13 +306,18 @@ files:
307
306
  - definitions/procedures/service/stop.rb
308
307
  - definitions/procedures/sync_plans/disable.rb
309
308
  - definitions/procedures/sync_plans/enable.rb
309
+ - definitions/reports/advisor_on_prem_remediations.rb
310
+ - definitions/reports/alternate_content_sources.rb
310
311
  - definitions/reports/compliance.rb
312
+ - definitions/reports/content.rb
311
313
  - definitions/reports/external_auth_source.rb
312
314
  - definitions/reports/grouping.rb
315
+ - definitions/reports/image_mode_hosts.rb
313
316
  - definitions/reports/instance.rb
314
317
  - definitions/reports/inventory.rb
315
318
  - definitions/reports/kerberos.rb
316
319
  - definitions/reports/ldap_auth_source.rb
320
+ - definitions/reports/networking.rb
317
321
  - definitions/reports/oidc_usage.rb
318
322
  - definitions/reports/platform.rb
319
323
  - definitions/reports/provisioning.rb
@@ -447,7 +451,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
447
451
  - !ruby/object:Gem::Version
448
452
  version: '0'
449
453
  requirements: []
450
- rubygems_version: 4.0.10
454
+ rubygems_version: 3.6.7
451
455
  specification_version: 4
452
456
  summary: Foreman maintenance tool belt
453
457
  test_files: []
@@ -1,17 +0,0 @@
1
- module Procedures::Pulpcore
2
- class RpmDatarepair < ForemanMaintain::Procedure
3
- include ForemanMaintain::Concerns::PulpCommon
4
-
5
- metadata do
6
- description 'Rename ContentArtifact relative_paths to match `{N-V-R.A.rpm}`'
7
- for_feature :pulpcore
8
- end
9
-
10
- def run
11
- with_spinner('Running pulpcore-manager rpm-datarepair 4073') do
12
- # Assumption: services are already started
13
- execute!(pulpcore_manager('rpm-datarepair 4073'))
14
- end
15
- end
16
- end
17
- end