foreman_rh_cloud 13.2.10 → 14.0.1

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +61 -61
  3. data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +68 -68
  4. data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +9 -9
  5. data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +60 -60
  6. data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +60 -60
  7. data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +0 -9
  8. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +10 -13
  9. data/app/controllers/insights_cloud/ui_requests_controller.rb +7 -3
  10. data/app/models/concerns/rh_cloud_host.rb +3 -35
  11. data/app/models/insights_client_report_status.rb +1 -9
  12. data/app/models/inventory_sync/inventory_status.rb +4 -16
  13. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +5 -12
  14. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +2 -8
  15. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +4 -34
  16. data/lib/foreman_inventory_upload/generators/queries.rb +1 -1
  17. data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
  18. data/lib/foreman_inventory_upload.rb +1 -8
  19. data/lib/foreman_rh_cloud/engine.rb +0 -1
  20. data/lib/foreman_rh_cloud/version.rb +1 -1
  21. data/lib/foreman_rh_cloud.rb +9 -36
  22. data/lib/insights_cloud/async/insights_generate_notifications.rb +1 -10
  23. data/lib/insights_cloud/async/vmaas_reposcan_sync.rb +8 -23
  24. data/lib/inventory_sync/async/inventory_full_sync.rb +3 -39
  25. data/lib/inventory_sync/async/inventory_self_host_sync.rb +2 -12
  26. data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  27. data/locale/fr/foreman_rh_cloud.edit.po +1032 -0
  28. data/locale/fr/foreman_rh_cloud.po +65 -66
  29. data/locale/fr/foreman_rh_cloud.po.time_stamp +0 -0
  30. data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  31. data/locale/ja/foreman_rh_cloud.edit.po +1026 -0
  32. data/locale/ja/foreman_rh_cloud.po +70 -72
  33. data/locale/ja/foreman_rh_cloud.po.time_stamp +0 -0
  34. data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  35. data/locale/ka/foreman_rh_cloud.edit.po +1025 -0
  36. data/locale/ka/foreman_rh_cloud.po +10 -11
  37. data/locale/ka/foreman_rh_cloud.po.time_stamp +0 -0
  38. data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  39. data/locale/ko/foreman_rh_cloud.edit.po +1029 -0
  40. data/locale/ko/foreman_rh_cloud.po +63 -64
  41. data/locale/ko/foreman_rh_cloud.po.time_stamp +0 -0
  42. data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  43. data/locale/zh_CN/foreman_rh_cloud.edit.po +1031 -0
  44. data/locale/zh_CN/foreman_rh_cloud.po +64 -65
  45. data/locale/zh_CN/foreman_rh_cloud.po.time_stamp +0 -0
  46. data/package.json +1 -1
  47. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +3 -57
  48. data/test/controllers/insights_cloud/ui_requests_controller_test.rb +2 -16
  49. data/test/jobs/insights_client_status_aging_test.rb +0 -40
  50. data/test/jobs/inventory_full_sync_test.rb +4 -219
  51. data/test/jobs/inventory_hosts_sync_test.rb +5 -7
  52. data/test/jobs/inventory_self_host_sync_test.rb +1 -10
  53. data/test/models/insights_client_report_status_test.rb +0 -109
  54. data/test/unit/archived_report_generator_test.rb +1 -2
  55. data/test/unit/fact_helpers_test.rb +0 -16
  56. data/test/unit/foreman_rh_cloud_self_host_test.rb +2 -50
  57. data/test/unit/lib/insights_cloud/async/vmaas_reposcan_sync_test.rb +25 -80
  58. data/test/unit/metadata_generator_test.rb +1 -24
  59. data/test/unit/rh_cloud_host_test.rb +0 -214
  60. data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +1 -1
  61. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +1 -1
  62. data/test/unit/slice_generator_test.rb +2 -21
  63. data/webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js +3 -30
  64. data/webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js +10 -112
  65. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +1 -3
  66. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +2 -8
  67. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +0 -1
  68. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +0 -1
  69. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +17 -43
  70. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +0 -7
  71. data/webpack/ForemanRhCloudHelpers.js +0 -22
  72. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +15 -71
  73. metadata +16 -18
  74. data/app/controllers/concerns/insights_cloud/candlepin_proxies_extensions.rb +0 -23
  75. data/test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb +0 -70
  76. data/test/jobs/insights_generate_notifications_test.rb +0 -26
  77. data/test/models/inventory_sync/inventory_status_test.rb +0 -85
  78. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/__tests__/Toast.test.js +0 -82
  79. data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +0 -266
@@ -28,14 +28,6 @@ module ForemanInventoryUpload
28
28
  @organization_accounts[organization.id] ||= organization.pools.where.not(account_number: nil).pluck(:account_number).first
29
29
  end
30
30
 
31
- def golden_ticket?(organization)
32
- result = organization.try(:golden_ticket?)
33
- result = organization.content_access_mode == 'org_environment' if result.nil?
34
-
35
- @organization_golden_tickets ||= {}
36
- @organization_golden_tickets[organization.id] ||= result
37
- end
38
-
39
31
  def cloud_provider(host)
40
32
  bios_version = fact_value(host, 'dmi::bios::version')
41
33
 
@@ -114,7 +106,6 @@ module ForemanInventoryUpload
114
106
 
115
107
  def host_ips(host)
116
108
  # Determines and returns the IP addresses associated with a host, applying obfuscation if enabled.
117
- return {} if host.nil?
118
109
 
119
110
  # If IP obfuscation is enabled for the host return a representation of obfuscated IP addresses.
120
111
  return obfuscated_ips(host) if obfuscate_ips?(host)
@@ -164,29 +155,10 @@ module ForemanInventoryUpload
164
155
 
165
156
  def hostname_match
166
157
  bash_hostname = `uname -n`.chomp
167
- foreman_host = ForemanRhCloud.foreman_host
168
-
169
- # If bash hostname matches foreman_host, use fqdn
170
- if foreman_host && bash_hostname == foreman_host.name
171
- return fqdn(foreman_host)
172
- end
173
-
174
- # If no foreman_host, try foreman_host_name from Setting[:foreman_url]
175
- unless foreman_host
176
- foreman_hostname_from_setting = ForemanRhCloud.foreman_host_name
177
- if foreman_hostname_from_setting
178
- # Apply obfuscation if enabled
179
- return obfuscate_fqdn(foreman_hostname_from_setting) if Setting[:obfuscate_inventory_hostnames]
180
-
181
- return foreman_hostname_from_setting
182
- end
183
- # Otherwise fall through to bash_hostname below
184
- # NOTE: Containerized foremanctl setups must configure Setting[:foreman_url]
185
- # as bash hostname may not be available or meaningful in containers
186
- end
187
-
188
- # Fallback to bash hostname (with obfuscation if enabled)
189
- if Setting[:obfuscate_inventory_hostnames]
158
+ foreman_hostname = ForemanRhCloud.foreman_host&.name
159
+ if bash_hostname == foreman_hostname
160
+ fqdn(ForemanRhCloud.foreman_host)
161
+ elsif Setting[:obfuscate_inventory_hostnames]
190
162
  obfuscate_fqdn(bash_hostname)
191
163
  else
192
164
  bash_hostname
@@ -194,8 +166,6 @@ module ForemanInventoryUpload
194
166
  end
195
167
 
196
168
  def bios_uuid(host)
197
- return nil if host.nil?
198
-
199
169
  value = fact_value(host, 'dmi::system::uuid') || ''
200
170
  uuid_value(value)
201
171
  end
@@ -62,7 +62,7 @@ module ForemanInventoryUpload
62
62
  :content_facet,
63
63
  :host_statuses,
64
64
  :inventory_upload_facts,
65
- subscription_facet: [:pools, :installed_products, :hypervisor_host]
65
+ subscription_facet: [:installed_products, :hypervisor_host]
66
66
  )
67
67
  end
68
68
 
@@ -230,7 +230,7 @@ module ForemanInventoryUpload
230
230
  @stream.simple_field('system_purpose_sla', host.subscription_facet.service_level)
231
231
  @stream.simple_field('distribution_version', fact_value(host, 'distribution::version'))
232
232
  @stream.simple_field('satellite_instance_id', Foreman.try(:instance_id))
233
- @stream.simple_field('is_simple_content_access', golden_ticket?(host.organization))
233
+ @stream.simple_field('is_simple_content_access', true)
234
234
  @stream.simple_field('is_hostname_obfuscated', !!obfuscate_hostname?(host))
235
235
  @stream.simple_field('organization_id', host.organization_id, :last)
236
236
  end
@@ -96,14 +96,7 @@ module ForemanInventoryUpload
96
96
  end
97
97
 
98
98
  def self.inventory_self_url
99
- host = ForemanRhCloud.foreman_host
100
- hostname = host ? host.fqdn : ForemanRhCloud.foreman_host_name
101
- if hostname.nil?
102
- Rails.logger.warn("Cannot determine Foreman hostname for inventory sync. " \
103
- "Please configure Setting[:foreman_url]. " \
104
- "Containerized setups must explicitly set this.")
105
- end
106
- inventory_base_url + "?hostname_or_id=#{hostname}"
99
+ inventory_base_url + "?hostname_or_id=#{ForemanRhCloud.foreman_host.fqdn}"
107
100
  end
108
101
 
109
102
  def self.host_by_id_url(host_uuid)
@@ -40,7 +40,6 @@ module ForemanRhCloud
40
40
  ::Host::Managed.include RhCloudHost
41
41
 
42
42
  ::Katello::Api::Rhsm::CandlepinDynflowProxyController.include InsightsCloud::PackageProfileUploadExtensions
43
- ::Katello::Api::Rhsm::CandlepinProxiesController.include InsightsCloud::CandlepinProxiesExtensions
44
43
  ::Katello::RegistrationManager.singleton_class.prepend ::ForemanRhCloud::RegistrationManagerExtensions
45
44
  end
46
45
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '13.2.10'.freeze
2
+ VERSION = '14.0.1'.freeze
3
3
  end
@@ -84,50 +84,23 @@ module ForemanRhCloud
84
84
 
85
85
  # For testing purposes we can override the default hostname with an environment variable SATELLITE_RH_CLOUD_FOREMAN_HOST
86
86
  def self.foreman_host
87
- return @foreman_host if defined?(@foreman_host)
88
-
89
- fullname = foreman_host_name
90
- return @foreman_host = nil unless fullname
91
-
92
- # Try fullname first
93
- host = ::Host.unscoped.friendly.where(name: fullname).first
94
-
95
- # If not found, try shortname
96
- if host.nil?
87
+ @foreman_host ||= begin
88
+ fullname = foreman_host_name
89
+ ::Host.unscoped.friendly.find(fullname)
90
+ rescue ActiveRecord::RecordNotFound
91
+ # fullname didn't work. Let's try shortname
97
92
  shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
98
- host = ::Host.unscoped.friendly.where(name: shortname).first
93
+ ::Host.unscoped.friendly.find(shortname)
99
94
  end
100
-
101
- @foreman_host = host
102
95
  end
103
96
 
104
97
  def self.foreman_host_name
105
- ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || marked_foreman_host&.name || foreman_url_hostname
106
- end
107
-
108
- def self.foreman_url_hostname
109
- return nil unless Setting[:foreman_url]
110
-
111
- begin
112
- # Ensure setting is a string to avoid TypeError from URI.parse
113
- url = Setting[:foreman_url].to_s
114
- URI.parse(url).host
115
- rescue URI::InvalidURIError, ArgumentError, TypeError => e
116
- Rails.logger.warn("Invalid foreman_url setting: #{e.message}")
117
- nil
118
- end
98
+ ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || marked_foreman_host&.name || ::SmartProxy.default_capsule.name
119
99
  end
120
100
 
121
101
  def self.marked_foreman_host
122
- # Find host with infrastructure_facet.foreman_instance = true
123
- # Facets use a special mechanism in Foreman, so we query the facet table directly
124
- return nil unless defined?(HostFacets::InfrastructureFacet)
125
-
126
- facet = HostFacets::InfrastructureFacet.find_by(foreman_instance: true)
127
- facet&.host
128
- rescue ActiveRecord::StatementInvalid => e
129
- # Table might not exist yet during migrations
130
- Rails.logger.debug("Could not query marked foreman host: #{e.message}")
102
+ ::Host.unscoped.search_for('infrastructure_facet.foreman = true').first
103
+ rescue ScopedSearch::QueryNotSupported
131
104
  nil
132
105
  end
133
106
 
@@ -13,16 +13,7 @@ module InsightsCloud
13
13
  end
14
14
 
15
15
  def add_satellite_notifications
16
- host = foreman_host
17
-
18
- # Skip if no Foreman host record exists
19
- unless host
20
- logger.debug("Skipping Insights notifications: no Foreman host record found")
21
- blueprint&.notifications&.destroy_all
22
- return
23
- end
24
-
25
- hits_count = InsightsHit.where(host_id: host.id).count
16
+ hits_count = InsightsHit.where(host_id: foreman_host.id).count
26
17
 
27
18
  # Remove stale notifications
28
19
  blueprint.notifications.destroy_all
@@ -6,8 +6,6 @@ module InsightsCloud
6
6
  class VmaasReposcanSync < ::Actions::EntryAction
7
7
  include ::ForemanRhCloud::CertAuth
8
8
 
9
- HTTP_TOO_MANY_REQUESTS = 429
10
-
11
9
  # Subscribe to Katello repository sync hook action, if available
12
10
  def self.subscribe
13
11
  'Actions::Katello::Repository::SyncHook'.constantize
@@ -51,9 +49,15 @@ module InsightsCloud
51
49
 
52
50
  response
53
51
  rescue RestClient::ExceptionWithResponse => e
54
- handle_rest_client_error(e)
52
+ message = "VMaaS reposcan sync failed: #{e.response&.code} - #{e.response&.body}"
53
+ logger.error(message)
54
+ output[:message] = message
55
+ raise
55
56
  rescue StandardError => e
56
- handle_standard_error(e)
57
+ message = "Error triggering VMaaS reposcan sync: #{e.message}, response: #{e.respond_to?(:response) ? e.response : nil}"
58
+ logger.error(message)
59
+ output[:message] = message
60
+ raise
57
61
  end
58
62
 
59
63
  def rescue_strategy_for_self
@@ -66,25 +70,6 @@ module InsightsCloud
66
70
 
67
71
  private
68
72
 
69
- def handle_rest_client_error(exception)
70
- if exception.response&.code == HTTP_TOO_MANY_REQUESTS
71
- message = "VMaaS reposcan sync skipped: another sync already in progress (#{HTTP_TOO_MANY_REQUESTS})"
72
- logger.warn(message)
73
- else
74
- message = "VMaaS reposcan sync failed: #{exception.response&.code} - #{exception.response&.body}"
75
- logger.error(message)
76
- end
77
- output[:message] = message
78
- # Do NOT raise - let rescue_strategy_for_self Skip handle this
79
- end
80
-
81
- def handle_standard_error(exception)
82
- message = "Error triggering VMaaS reposcan sync: #{exception.message}"
83
- logger.error(message)
84
- output[:message] = message
85
- # Do NOT raise - let rescue_strategy_for_self Skip handle this
86
- end
87
-
88
73
  def logger
89
74
  action_logger
90
75
  end
@@ -15,26 +15,16 @@ module InventorySync
15
15
 
16
16
  def setup_statuses
17
17
  @subscribed_hosts_ids = Set.new(affected_host_ids)
18
- @omitted_ids = Set.new(user_omitted_host_ids)
19
-
20
- # Remove user-omitted hosts from subscribed set. In normal operation, affected_host_ids
21
- # already excludes user-omitted hosts via for_slice, but this handles edge cases like
22
- # a host transitioning from uploaded to user-omitted between syncs.
23
- @subscribed_hosts_ids.subtract(@omitted_ids)
24
18
 
25
19
  InventorySync::InventoryStatus.transaction do
26
20
  InventorySync::InventoryStatus.where(host_id: @subscribed_hosts_ids).delete_all
27
- InventorySync::InventoryStatus.where(host_id: @omitted_ids).delete_all
28
21
  yield
29
- add_missing_hosts_statuses(@subscribed_hosts_ids) # any remaining hosts after yield are disconnected
30
- add_user_omitted_host_statuses(@omitted_ids)
22
+ add_missing_hosts_statuses(@subscribed_hosts_ids)
31
23
  host_statuses[:disconnect] += @subscribed_hosts_ids.size
32
- host_statuses[:user_omitted] += @omitted_ids.size
33
24
  end
34
25
 
35
- logger.debug("Synced hosts count: #{host_statuses[:sync]}")
36
- logger.debug("Disconnected hosts count: #{host_statuses[:disconnect]}")
37
- logger.debug("User-omitted hosts count: #{host_statuses[:user_omitted]}")
26
+ logger.debug("Synced hosts amount: #{host_statuses[:sync]}")
27
+ logger.debug("Disconnected hosts amount: #{host_statuses[:disconnect]}")
38
28
  output[:host_statuses] = host_statuses
39
29
  end
40
30
 
@@ -54,7 +44,6 @@ module InventorySync
54
44
  private
55
45
 
56
46
  def update_hosts_status(status_hashes)
57
- # create Inventory statuses
58
47
  InventorySync::InventoryStatus.create(status_hashes)
59
48
  updated_ids = status_hashes.map { |hash| hash[:host_id] }
60
49
  @subscribed_hosts_ids.subtract(updated_ids)
@@ -72,23 +61,10 @@ module InventorySync
72
61
  )
73
62
  end
74
63
 
75
- def add_user_omitted_host_statuses(host_ids)
76
- InventorySync::InventoryStatus.create(
77
- host_ids.map do |host_id|
78
- {
79
- host_id: host_id,
80
- status: InventorySync::InventoryStatus::USER_OMITTED,
81
- reported_at: DateTime.current,
82
- }
83
- end
84
- )
85
- end
86
-
87
64
  def host_statuses
88
65
  @host_statuses ||= {
89
66
  sync: 0,
90
67
  disconnect: 0,
91
- user_omitted: 0,
92
68
  }
93
69
  end
94
70
 
@@ -97,18 +73,6 @@ module InventorySync
97
73
  Host.unscoped.where(organization: organizations)
98
74
  ).pluck(:id)
99
75
  end
100
-
101
- def user_omitted_host_ids
102
- param_name = InsightsCloud.enable_client_param_inventory
103
-
104
- # Use search_for to respect parameter inheritance (global, org, hostgroup, host)
105
- # This matches the same logic used by for_slice, ensuring consistency
106
- Host.unscoped
107
- .where(organization: organizations)
108
- .joins(:subscription_facet)
109
- .search_for("params.#{param_name} = f")
110
- .pluck(:id)
111
- end
112
76
  end
113
77
  end
114
78
  end
@@ -4,14 +4,7 @@ module InventorySync
4
4
  set_callback :step, :around, :create_facets
5
5
 
6
6
  def plan
7
- host = ForemanRhCloud.foreman_host
8
-
9
- if host.nil?
10
- logger.warn("Skipping self-host inventory sync: no Foreman host record found.")
11
- return
12
- end
13
-
14
- super(host.organization)
7
+ super(ForemanRhCloud.foreman_host.organization)
15
8
  end
16
9
 
17
10
  def create_facets
@@ -29,10 +22,7 @@ module InventorySync
29
22
  private
30
23
 
31
24
  def add_missing_insights_facet(uuids_hash)
32
- host = ForemanRhCloud.foreman_host
33
- return unless host # Guard against nil
34
-
35
- facet = InsightsFacet.find_or_create_by(host_id: host.id) do |facet|
25
+ facet = InsightsFacet.find_or_create_by(host_id: ForemanRhCloud.foreman_host.id) do |facet|
36
26
  facet.uuid = uuids_hash.values.first
37
27
  end
38
28