foreman_rh_cloud 12.2.17 → 13.0.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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +24 -78
  3. data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +24 -78
  4. data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +23 -77
  5. data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +23 -77
  6. data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +23 -77
  7. data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +3 -5
  8. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -1
  9. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +1 -1
  10. data/app/controllers/insights_cloud/ui_requests_controller.rb +3 -2
  11. data/app/models/concerns/rh_cloud_host.rb +1 -45
  12. data/app/models/foreman_rh_cloud/ping.rb +1 -2
  13. data/app/models/insights_hit.rb +1 -1
  14. data/app/services/foreman_rh_cloud/cert_auth.rb +3 -13
  15. data/app/services/foreman_rh_cloud/gateway_request.rb +26 -0
  16. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +1 -3
  17. data/app/services/foreman_rh_cloud/tags_auth.rb +4 -15
  18. data/app/views/api/v2/advisor_engine/host_details.json.rabl +3 -1
  19. data/app/views/api/v2/hosts/insights/base.rabl +2 -3
  20. data/lib/foreman_inventory_upload/async/generate_report_job.rb +8 -13
  21. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +26 -4
  22. data/lib/foreman_inventory_upload/async/upload_report_job.rb +96 -0
  23. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
  24. data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
  25. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +49 -0
  26. data/lib/foreman_inventory_upload.rb +6 -6
  27. data/lib/foreman_rh_cloud/engine.rb +15 -34
  28. data/lib/foreman_rh_cloud/plugin.rb +13 -20
  29. data/lib/foreman_rh_cloud/version.rb +1 -1
  30. data/lib/foreman_rh_cloud.rb +3 -3
  31. data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +3 -3
  32. data/lib/inventory_sync/async/inventory_hosts_sync.rb +2 -0
  33. data/lib/tasks/rh_cloud_inventory.rake +31 -14
  34. data/locale/foreman_rh_cloud.pot +157 -261
  35. data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  36. data/locale/fr/foreman_rh_cloud.po +26 -79
  37. data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  38. data/locale/ja/foreman_rh_cloud.po +26 -79
  39. data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  40. data/locale/ka/foreman_rh_cloud.po +24 -77
  41. data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  42. data/locale/ko/foreman_rh_cloud.po +25 -78
  43. data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  44. data/locale/zh_CN/foreman_rh_cloud.po +25 -78
  45. data/package.json +1 -1
  46. data/test/controllers/accounts_controller_test.rb +1 -1
  47. data/test/controllers/insights_cloud/api/advisor_engine_controller_test.rb +1 -28
  48. data/test/controllers/insights_cloud/ui_requests_controller_test.rb +0 -26
  49. data/test/controllers/uploads_controller_test.rb +1 -1
  50. data/test/factories/insights_factories.rb +0 -29
  51. data/test/jobs/cloud_connector_announce_task_test.rb +2 -3
  52. data/test/jobs/connector_playbook_execution_reporter_task_test.rb +20 -32
  53. data/test/jobs/exponential_backoff_test.rb +8 -9
  54. data/test/jobs/insights_client_status_aging_test.rb +2 -3
  55. data/test/jobs/insights_full_sync_test.rb +7 -13
  56. data/test/jobs/insights_resolutions_sync_test.rb +5 -9
  57. data/test/jobs/insights_rules_sync_test.rb +3 -5
  58. data/test/jobs/inventory_full_sync_test.rb +5 -9
  59. data/test/jobs/inventory_hosts_sync_test.rb +6 -11
  60. data/test/jobs/inventory_scheduled_sync_test.rb +6 -10
  61. data/test/jobs/inventory_self_host_sync_test.rb +1 -1
  62. data/test/jobs/remove_insights_hosts_job_test.rb +15 -14
  63. data/test/jobs/upload_report_job_test.rb +36 -0
  64. data/test/unit/fact_helpers_test.rb +0 -47
  65. data/test/unit/services/foreman_rh_cloud/tags_auth_test.rb +0 -14
  66. data/test/unit/slice_generator_test.rb +0 -57
  67. data/webpack/ForemanColumnExtensions/index.js +0 -2
  68. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +17 -24
  69. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +8 -178
  70. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +36 -0
  71. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +1 -1
  72. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +1 -3
  73. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +51 -69
  74. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -1
  75. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +1 -1
  76. data/webpack/ForemanRhCloudFills.js +2 -6
  77. data/webpack/ForemanRhCloudHelpers.js +0 -4
  78. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +3 -3
  79. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +9 -3
  80. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +4 -24
  81. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +112 -0
  82. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +2 -2
  83. data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +3 -3
  84. data/webpack/InsightsCloudSync/InsightsCloudSync.js +3 -3
  85. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -10
  86. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
  87. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -4
  88. data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +23 -59
  89. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +23 -25
  90. data/webpack/InsightsVulnerabilityHostIndexExtensions/CVECountCell.js +2 -8
  91. data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +4 -105
  92. data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +3 -0
  93. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +1 -16
  94. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -6
  95. data/webpack/common/Hooks/ConfigHooks.js +16 -3
  96. metadata +12 -32
  97. data/app/controllers/concerns/foreman_rh_cloud/registration_manager_extensions.rb +0 -39
  98. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +0 -36
  99. data/lib/foreman_inventory_upload/async/generate_host_report.rb +0 -20
  100. data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +0 -39
  101. data/lib/foreman_inventory_upload/async/single_host_report_job.rb +0 -20
  102. data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +0 -200
  103. data/test/jobs/create_missing_insights_facets_test.rb +0 -151
  104. data/test/jobs/generate_host_report_test.rb +0 -100
  105. data/test/jobs/generate_report_job_test.rb +0 -146
  106. data/test/jobs/host_inventory_report_job_test.rb +0 -244
  107. data/test/jobs/queue_for_upload_job_test.rb +0 -54
  108. data/test/jobs/single_host_report_job_test.rb +0 -155
  109. data/test/jobs/upload_report_direct_job_test.rb +0 -399
  110. data/test/unit/foreman_rh_cloud_iop_metadata_test.rb +0 -200
  111. data/test/unit/lib/foreman_rh_cloud/registration_manager_extensions_test.rb +0 -154
  112. data/test/unit/rh_cloud_host_test.rb +0 -345
  113. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js +0 -194
  114. data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +0 -154
@@ -3,10 +3,10 @@
3
3
  "locale_data": {
4
4
  "foreman_rh_cloud": {
5
5
  "": {
6
- "Project-Id-Version": "foreman_rh_cloud 13.0.5",
6
+ "Project-Id-Version": "foreman_rh_cloud 11.1.0",
7
7
  "Report-Msgid-Bugs-To": "",
8
8
  "PO-Revision-Date": "2023-01-20 13:26+0000",
9
- "Last-Translator": "Ondřej Gajdušek, 2025",
9
+ "Last-Translator": "Ewoud Kohl van Wijngaarden <ewoud+transifex@kohlvanwijngaarden.nl>, 2025",
10
10
  "Language-Team": "Chinese (China) (https://app.transifex.com/foreman/teams/114/zh_CN/)",
11
11
  "MIME-Version": "1.0",
12
12
  "Content-Type": "text/plain; charset=UTF-8",
@@ -35,9 +35,6 @@
35
35
  "All recommendations are now selected.": [
36
36
  "现在选择了所有建议。"
37
37
  ],
38
- "Analytics data collection": [
39
- "数据收集分析"
40
- ],
41
38
  "Any Organization": [
42
39
  "任意机构"
43
40
  ],
@@ -119,17 +116,11 @@
119
116
  "Enable automatic deletion of mismatched host records from the Red Hat cloud": [
120
117
  "启用自动删除来自红帽云的主机记录"
121
118
  ],
122
- "Enable automatic deletion of mismatched host records from the Red Hat cloud. Ignored when using local Insights.": [
123
- ""
124
- ],
125
119
  "Enable automatic synchronization of Insights recommendations from the Red Hat cloud": [
126
120
  "启用来自红帽云的 Insights 建议自动同步"
127
121
  ],
128
- "Enable automatic synchronization of Insights recommendations from the Red Hat cloud. Ignored when using local Insights.": [
129
- ""
130
- ],
131
- "Enable automatic upload of your host inventory to the Red Hat cloud. Ignored when using local Insights.": [
132
- ""
122
+ "Enable automatic upload of your host inventory to the Red Hat cloud": [
123
+ "启用自动将主机清单上传到红帽云"
133
124
  ],
134
125
  "Enable automatic upload of your hosts inventory to the Red Hat cloud": [
135
126
  "启用自动将主机清单上传到红帽云"
@@ -143,14 +134,17 @@
143
134
  "Encountered an error while trying to access the server:": [
144
135
  "在尝试访问服务器时遇到错误:"
145
136
  ],
146
- "Exclude installed packages": [
137
+ "Exclude installed Packages": [
147
138
  "排除安装的软件包"
148
139
  ],
149
140
  "Exclude installed packages from being uploaded to the Red Hat cloud": [
150
141
  "将安装的软件包上传到红帽云"
151
142
  ],
152
- "Exclude installed packages from being uploaded to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored and installed packages are always excluded.) Ignored when using local Insights.": [
153
- ""
143
+ "Exclude packages": [
144
+ "排除软件包"
145
+ ],
146
+ "Exclude packages from being uploaded to the Red Hat cloud": [
147
+ "排除软件包上传到红帽云"
154
148
  ],
155
149
  "Exit Code: %s": [
156
150
  "退出代码:%s"
@@ -185,9 +179,6 @@
185
179
  "Generate and upload report": [
186
180
  "生成并上传报告"
187
181
  ],
188
- "Generate report": [
189
- "生成报告"
190
- ],
191
182
  "Generate the report, but do not upload": [
192
183
  "生成报告,但不上传"
193
184
  ],
@@ -215,9 +206,6 @@
215
206
  "Host Insights recommendations": [
216
207
  "主机 Insights 建议"
217
208
  ],
218
- "Host inventory report job": [
219
- ""
220
- ],
221
209
  "Host was not uploaded to your RH cloud inventory": [
222
210
  "主机没有上传到您的 RH 云清单"
223
211
  ],
@@ -260,9 +248,6 @@
260
248
  "Knowledgebase article": [
261
249
  "知识库文章"
262
250
  ],
263
- "Learn more about {minimalDataCollectionSetting}.": [
264
- "了解有关 {minimalDataCollectionSetting} 的更多信息。"
265
- ],
266
251
  "List of host UUIDs": [
267
252
  "主机 UUID 列表"
268
253
  ],
@@ -278,12 +263,6 @@
278
263
  "Manual": [
279
264
  "手册"
280
265
  ],
281
- "Minimal data collection": [
282
- "最小数据收集"
283
- ],
284
- "Missing Insights facets created: %s": [
285
- ""
286
- ],
287
266
  "Moderate": [
288
267
  "中等"
289
268
  ],
@@ -314,33 +293,21 @@
314
293
  "Notice": [
315
294
  "注意事項"
316
295
  ],
296
+ "Obfuscate IPs": [
297
+ "模糊 IP"
298
+ ],
317
299
  "Obfuscate host ipv4 addresses": [
318
300
  "模糊的主机 ipv4 地址"
319
301
  ],
320
- "Obfuscate host ipv4 addresses.": [
321
- "对主机 ipv4 地址进行模糊化处理"
322
- ],
323
302
  "Obfuscate host names": [
324
303
  "模糊主机名"
325
304
  ],
326
305
  "Obfuscate host names sent to the Red Hat cloud": [
327
306
  "发送到红帽云的模糊主机名"
328
307
  ],
329
- "Obfuscate host names sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host names are not included in the report.) Ignored when using local Insights.": [
330
- ""
331
- ],
332
308
  "Obfuscate ipv4 addresses sent to the Red Hat cloud": [
333
309
  "发送到红帽云的模糊 ipv4 地址"
334
310
  ],
335
- "Obfuscate ipv4 addresses sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host IPv4 addresses are not included in the report.) Ignored when using local Insights.": [
336
- ""
337
- ],
338
- "Only include the minimum required data in inventory reports for uploading to Red Hat cloud. When this is true, installed packages are excluded from the report regardless of the exclude_installed_packages setting, and host names and IPv4 addresses are excluded from the report regardless of obfuscation settings. Ignored when using local Insights.": [
339
- ""
340
- ],
341
- "Only send the minimum required data to Red Hat cloud, obfuscation settings are disabled": [
342
- "仅将最低所需的数据发送到红帽云,禁用模糊设置"
343
- ],
344
311
  "Oops! Couldn't find organization that matches your query": [
345
312
  "未找到与您的查询匹配的机构"
346
313
  ],
@@ -356,8 +323,11 @@
356
323
  "RH Cloud": [
357
324
  "RH Cloud"
358
325
  ],
359
- "RHC daemon id. Ignored when using local Insights.": [
360
- ""
326
+ "RHC daemon id": [
327
+ "RHC 守护进程 ID"
328
+ ],
329
+ "RHCloud": [
330
+ "RHCloud"
361
331
  ],
362
332
  "Read more about it in RH cloud insights": [
363
333
  "在 RH Cloud insights 中了解更多有关它的信息"
@@ -416,7 +386,7 @@
416
386
  "Run RH Cloud playbook": [
417
387
  "运行 RH Cloud playbook"
418
388
  ],
419
- "Run playbook generated by Red Hat remediations app": [
389
+ "Run playbook genrated by Red Hat remediations app": [
420
390
  "运行由红帽补救应用生成的 playbook"
421
391
  ],
422
392
  "Run remediation playbook generated by Insights": [
@@ -431,17 +401,14 @@
431
401
  "Select recommendations from all pages": [
432
402
  "在所有页面中选择建议"
433
403
  ],
434
- "Send additional data to enhance Insights services, as per the settings": [
435
- "根据设置,发送额外数据以增强 Insights 服务"
436
- ],
437
404
  "Set the current organization context for the request": [
438
405
  "设置请求的当前机构上下文"
439
406
  ],
440
407
  "Settings": [
441
408
  "设置"
442
409
  ],
443
- "Should import include parameter tags from Foreman? Ignored when using local Insights.": [
444
- ""
410
+ "Should import include parameter tags from Foreman?": [
411
+ "应从 Foreman 导入包含参数标签?"
445
412
  ],
446
413
  "Show Advanced Settings": [
447
414
  "显示高级设置"
@@ -449,12 +416,6 @@
449
416
  "Show if system is configured to use local iop-advisor-engine.": [
450
417
  "显示系统是否被配置为使用本地 iop-advisor-engine。"
451
418
  ],
452
- "Single-host report job": [
453
- ""
454
- ],
455
- "Single-host report job for host %s": [
456
- ""
457
- ],
458
419
  "Start inventory synchronization": [
459
420
  "启动清单同步"
460
421
  ],
@@ -485,8 +446,8 @@
485
446
  "The report file %{filename} doesn't exist": [
486
447
  "报告文件 %{filename} 不存在"
487
448
  ],
488
- "The scheduled process is disabled because this Foreman is configured with a local IoP Smart Proxy.": [
489
- "调度的进程被禁用,因为此 Foreman 配置了一个本地 IoP Smart Proxy。"
449
+ "The scheduled process is disabled because this Foreman is configured with the use_local_advisor_engine option.": [
450
+ "调度的进程被禁用,因为此 Foreman 配置了 use_local_advisor_engine 选项。"
490
451
  ],
491
452
  "The server returned the following error: %s": [
492
453
  "服务器返回以下错误:%s"
@@ -497,9 +458,6 @@
497
458
  "There are no recommendations for your hosts": [
498
459
  "没有适用于您的主机的建议"
499
460
  ],
500
- "There were no missing Insights facets": [
501
- ""
502
- ],
503
461
  "This action will also enable automatic reports upload": [
504
462
  "此操作还会启用自动报告上传"
505
463
  ],
@@ -509,9 +467,6 @@
509
467
  "To manually upload the data for a specific organization, select an organization and click {restartButtonName}.": [
510
468
  "要手动上传特定机构的数据,请选择机构并点 {restartButtonName}。"
511
469
  ],
512
- "Total CVEs": [
513
- "CVE 总数"
514
- ],
515
470
  "Total risk": [
516
471
  "总风险"
517
472
  ],
@@ -539,12 +494,6 @@
539
494
  "View in Red Hat Insights": [
540
495
  "禁用 Red Hat Insights"
541
496
  ],
542
- "Vulnerabilities": [
543
- "安全漏洞"
544
- ],
545
- "Vulnerability": [
546
- "安全漏洞"
547
- ],
548
497
  "Wait and %s": [
549
498
  "等待和 %s"
550
499
  ],
@@ -611,9 +560,6 @@
611
560
  "rule title": [
612
561
  "rule 标题"
613
562
  ],
614
- "setting minimal data collection": [
615
- "设置最小数据收集"
616
- ],
617
563
  "solution url": [
618
564
  "solution url"
619
565
  ],
@@ -15,15 +15,13 @@ module InsightsCloud
15
15
  logger.debug("Generating host-specific report for host #{@host.name}")
16
16
 
17
17
  ForemanTasks.async_task(
18
- ForemanInventoryUpload::Async::SingleHostReportJob,
18
+ ForemanInventoryUpload::Async::GenerateReportJob,
19
19
  ForemanInventoryUpload.generated_reports_folder,
20
20
  @host.organization_id,
21
- @host.id
21
+ false,
22
+ "id=#{@host.id}"
22
23
  )
23
24
 
24
- # Ensure insights UUID matches subscription UUID (only runs in IoP mode per method guard above)
25
- @host.ensure_iop_insights_uuid
26
-
27
25
  # in IoP case, the hosts are identified by the sub-man ID, and we can assume they already
28
26
  # exist in the local inventory. This will also handle facet creation for new hosts.
29
27
  return if @host.insights
@@ -7,7 +7,7 @@ module ForemanInventoryUpload
7
7
  accounts = Hash[
8
8
  labels.map do |id, label|
9
9
  generate_report_status = status_for(id, ForemanInventoryUpload::Async::GenerateReportJob)
10
- upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportDirectJob)
10
+ upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
11
11
  report_file_paths = ForemanInventoryUpload.report_file_paths(id)
12
12
 
13
13
  [
@@ -6,7 +6,7 @@ module ForemanInventoryUpload
6
6
  before_action :require_non_iop_smart_proxy, only: [:enable_cloud_connector]
7
7
 
8
8
  def last
9
- label = ForemanInventoryUpload::Async::UploadReportDirectJob.output_label(params[:organization_id])
9
+ label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:organization_id])
10
10
  output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
11
11
 
12
12
  render json: {
@@ -2,7 +2,7 @@ module InsightsCloud
2
2
  class UIRequestsController < ::ApplicationController
3
3
  layout false
4
4
 
5
- before_action :ensure_org, :find_location, :only => [:forward_request]
5
+ before_action :ensure_org, :ensure_loc, :only => [:forward_request]
6
6
 
7
7
  # The method that "proxies" requests over to Cloud
8
8
  def forward_request
@@ -93,8 +93,9 @@ module InsightsCloud
93
93
  return render_message 'Organization not found or invalid', :status => 400 unless @organization
94
94
  end
95
95
 
96
- def find_location
96
+ def ensure_loc
97
97
  @location = Location.current
98
+ return render_message 'Location not found or invalid', :status => 400 unless @location
98
99
  end
99
100
 
100
101
  def base_url
@@ -21,54 +21,10 @@ module RhCloudHost
21
21
  scoped_search :relation => :inventory_sync_status_object, :on => :status, :rename => :insights_inventory_sync_status,
22
22
  :complete_value => { :disconnect => ::InventorySync::InventoryStatus::DISCONNECT,
23
23
  :sync => ::InventorySync::InventoryStatus::SYNC }
24
- scoped_search :on => :id, :rename => :insights_uuid, :only_explicit => true,
25
- :ext_method => :search_by_insights_uuid, :complete_value => false
24
+ scoped_search :relation => :insights, :on => :uuid, :only_explicit => true, :rename => :insights_uuid
26
25
 
27
26
  def insights_facet
28
27
  insights
29
28
  end
30
-
31
- # In IoP, read directly from the subscription facet to avoid stale data (see comment on ensure_iop_insights_uuid)
32
- def insights_uuid
33
- ForemanRhCloud.with_iop_smart_proxy? ? subscription_facet&.uuid : insights_facet&.uuid
34
- end
35
-
36
- # In non-IoP, insights_facet uuids are assigned by Hosted.
37
- # In IoP, insights_facet uuids must match Katello subscription_facet uuids.
38
- # If the host was previously registered to hosted Insights,
39
- # we need to correct its uuid.
40
- def ensure_iop_insights_uuid
41
- return unless insights_facet.present? && subscription_facet.present? && insights_facet.uuid != subscription_facet.uuid
42
- insights_facet.update!(uuid: subscription_facet.uuid)
43
- end
44
- end
45
-
46
- module ClassMethods
47
- def search_by_insights_uuid(_key, operator, value)
48
- # Determine which facet table to search based on IoP mode
49
- facet_table = ForemanRhCloud.with_iop_smart_proxy? ? Katello::Host::SubscriptionFacet.table_name : InsightsFacet.table_name
50
-
51
- # Build SQL condition
52
- if ['IN', 'NOT IN'].include?(operator)
53
- # For IN/NOT IN, value may be an array or comma-separated string
54
- # Convert to array and build placeholders for each value
55
- values = value.is_a?(Array) ? value : value.to_s.split(',').map(&:strip)
56
- placeholders = (['?'] * values.size).join(',')
57
- condition = sanitize_sql_for_conditions(
58
- ["#{facet_table}.uuid #{operator} (#{placeholders})", *values]
59
- )
60
- else
61
- # For other operators (=, !=, LIKE, etc.), use value_to_sql for proper SQL formatting
62
- condition = sanitize_sql_for_conditions(
63
- ["#{facet_table}.uuid #{operator} ?", value_to_sql(operator, value)]
64
- )
65
- end
66
-
67
- # Return search parameters with LEFT JOIN to include hosts without facets
68
- {
69
- joins: "LEFT JOIN #{facet_table} ON #{facet_table}.host_id = #{Host::Managed.table_name}.id",
70
- conditions: condition,
71
- }
72
- end
73
29
  end
74
30
  end
@@ -7,7 +7,7 @@ module ForemanRhCloud
7
7
  include ForemanRhCloud::CertAuth
8
8
 
9
9
  def iop_smart_proxy_url
10
- ForemanRhCloud.iop_smart_proxy&.url
10
+ @iop_smart_proxy_url ||= ForemanRhCloud.iop_smart_proxy.url
11
11
  end
12
12
 
13
13
  def service_urls
@@ -33,7 +33,6 @@ module ForemanRhCloud
33
33
  end
34
34
 
35
35
  def ping
36
- return {} unless ForemanRhCloud.with_iop_smart_proxy?
37
36
  ping_services
38
37
  end
39
38
 
@@ -1,6 +1,6 @@
1
1
  class InsightsHit < ApplicationRecord
2
2
  include ::Authorizable
3
- belongs_to :host, class_name: 'Host::Base'
3
+ belongs_to :host
4
4
  # since the facet is one-to-one association with a host, we can connect
5
5
  # through host_id column on both this model and facet.
6
6
  belongs_to :insights_facet, foreign_key: 'host_id', primary_key: 'host_id', counter_cache: :hits_count
@@ -11,21 +11,11 @@ module ForemanRhCloud
11
11
 
12
12
  def execute_cloud_request(params)
13
13
  organization = params.delete(:organization)
14
- # Cache the value of with_iop_smart_proxy? to avoid multiple calls to the database
15
- with_iop_smart_proxy = ForemanRhCloud.with_iop_smart_proxy?
16
- certs = with_iop_smart_proxy ? foreman_certificate : candlepin_id_cert(organization)
17
- default_params = {
14
+ certs = ForemanRhCloud.with_iop_smart_proxy? ? foreman_certificate : candlepin_id_cert(organization)
15
+ final_params = {
18
16
  ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
19
17
  ssl_client_key: OpenSSL::PKey.read(certs[:key]),
20
- }
21
-
22
- if with_iop_smart_proxy && organization&.label
23
- default_params[:headers] = {
24
- 'X-Org-Id' => organization&.label,
25
- }
26
- end
27
-
28
- final_params = default_params.deep_merge(params)
18
+ }.deep_merge(params)
29
19
 
30
20
  super(final_params)
31
21
  end
@@ -0,0 +1,26 @@
1
+ module ForemanRhCloud
2
+ module GatewayRequest
3
+ extend ActiveSupport::Concern
4
+
5
+ include CloudRequest
6
+
7
+ def execute_cloud_request(params)
8
+ certs = params.delete(:certs) || foreman_certificates
9
+ final_params = {
10
+ ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
11
+ ssl_client_key: OpenSSL::PKey.read(certs[:key]),
12
+ ssl_ca_file: Setting[:ssl_ca_file],
13
+ verify_ssl: OpenSSL::SSL::VERIFY_PEER,
14
+ }.deep_merge(params)
15
+
16
+ super(final_params)
17
+ end
18
+
19
+ def foreman_certificates
20
+ {
21
+ cert: File.read(Setting[:ssl_certificate]),
22
+ key: File.read(Setting[:ssl_priv_key]),
23
+ }
24
+ end
25
+ end
26
+ end
@@ -2,7 +2,7 @@ require 'rest-client'
2
2
 
3
3
  module ForemanRhCloud
4
4
  class InsightsApiForwarder
5
- include ForemanRhCloud::CertAuth
5
+ include ForemanRhCloud::GatewayRequest
6
6
 
7
7
  SCOPED_REQUESTS = [
8
8
  { test: %r{api/vulnerability/v1/vulnerabilities/cves}, tag_name: :tags },
@@ -26,8 +26,6 @@ module ForemanRhCloud
26
26
 
27
27
  request_opts = prepare_request_opts(original_request, path, forward_payload, forward_params)
28
28
 
29
- request_opts[:organization] = organization
30
-
31
29
  logger.debug("Sending request to: #{request_opts[:url]}")
32
30
 
33
31
  execute_cloud_request(request_opts)
@@ -1,6 +1,6 @@
1
1
  module ForemanRhCloud
2
2
  class TagsAuth
3
- include CertAuth
3
+ include GatewayRequest
4
4
 
5
5
  TAG_NAMESPACE = 'sat_iam'.freeze
6
6
  TAG_SHORT_NAME = 'scope'.freeze
@@ -20,12 +20,10 @@ module ForemanRhCloud
20
20
  end
21
21
 
22
22
  def update_tag
23
- loc_name = location_name_for_tag
24
- logger.debug("Updating tags for user: #{@user}, org: #{@org.name}, loc: #{loc_name}")
23
+ logger.debug("Updating tags for user: #{@user}, org: #{@org.name}, loc: #{@loc.name}")
25
24
 
26
25
  payload = tags_query_payload
27
26
  params = {
28
- organization: @org,
29
27
  method: :post,
30
28
  url: "#{InsightsCloud.gateway_url}/tags",
31
29
  headers: {
@@ -37,9 +35,7 @@ module ForemanRhCloud
37
35
  end
38
36
 
39
37
  def allowed_hosts
40
- query = Host.authorized_as(@user, nil, nil).where(organization: @org)
41
- query = query.where(location: @loc) if @loc
42
- query.joins(:subscription_facet).pluck('katello_subscription_facets.uuid')
38
+ Host.authorized_as(@user, nil, nil).where(organization: @org, location: @loc).joins(:subscription_facet).pluck('katello_subscription_facets.uuid')
43
39
  end
44
40
 
45
41
  def tags_query_payload
@@ -50,18 +46,11 @@ module ForemanRhCloud
50
46
  end
51
47
 
52
48
  def tag_value
53
- location_part = "L:\"#{location_name_for_tag}\""
54
- "U:\"#{@user.login}\"O:\"#{@org.name}\"#{location_part}"
49
+ "U:\"#{@user.login}\"O:\"#{@org.name}\"L:\"#{@loc.name}\""
55
50
  end
56
51
 
57
52
  def auth_tag
58
53
  "#{TAG_NAME}=#{tag_value}"
59
54
  end
60
-
61
- private
62
-
63
- def location_name_for_tag
64
- @loc ? @loc.name : '*'
65
- end
66
55
  end
67
56
  end
@@ -1,7 +1,9 @@
1
1
  collection @hosts
2
2
 
3
3
  attributes :name
4
- node :insights_uuid, &:insights_uuid
4
+ node :insights_uuid do |host|
5
+ host.insights_facet&.uuid
6
+ end
5
7
  node :insights_hit_details do |host|
6
8
  host&.facts('insights::hit_details')&.values&.first
7
9
  end
@@ -1,6 +1,5 @@
1
- node :uuid do |facet|
2
- facet&.host&.insights_uuid
3
- end
1
+ attributes :uuid
2
+
4
3
  node :insights_hit_details do |facet|
5
4
  facet&.host&.facts('insights::hit_details')&.values&.first
6
5
  end
@@ -5,7 +5,7 @@ module ForemanInventoryUpload
5
5
  "report_for_#{label}"
6
6
  end
7
7
 
8
- def plan(base_folder, organization_id, disconnected = false, hosts_filter = nil)
8
+ def plan(base_folder, organization_id, disconnected, hosts_filter = nil)
9
9
  sequence do
10
10
  super(
11
11
  GenerateReportJob.output_label("#{organization_id}#{hosts_filter.empty? ? nil : "[#{hosts_filter.to_s.parameterize}]"}"),
@@ -14,14 +14,13 @@ module ForemanInventoryUpload
14
14
  hosts_filter: hosts_filter
15
15
  )
16
16
 
17
- unless content_disconnected?(disconnected)
18
- plan_action(
19
- QueueForUploadJob,
20
- base_folder,
21
- ForemanInventoryUpload.facts_archive_name(organization_id, hosts_filter),
22
- organization_id
23
- )
24
- end
17
+ plan_action(
18
+ QueueForUploadJob,
19
+ base_folder,
20
+ ForemanInventoryUpload.facts_archive_name(organization_id, hosts_filter),
21
+ organization_id,
22
+ disconnected
23
+ )
25
24
  end
26
25
  end
27
26
 
@@ -41,10 +40,6 @@ module ForemanInventoryUpload
41
40
  )
42
41
  end
43
42
 
44
- def content_disconnected?(disconnected)
45
- disconnected || !Setting[:subscription_connection_enabled]
46
- end
47
-
48
43
  def base_folder
49
44
  input[:base_folder]
50
45
  end
@@ -1,14 +1,15 @@
1
1
  module ForemanInventoryUpload
2
2
  module Async
3
3
  class QueueForUploadJob < ::Actions::EntryAction
4
- def plan(base_folder, report_file, organization_id)
4
+ def plan(base_folder, report_file, organization_id, disconnected)
5
5
  enqueue_task = plan_self(base_folder: base_folder, report_file: report_file)
6
- plan_upload_report(enqueue_task.output[:enqueued_file_name], organization_id)
6
+ plan_upload_report(enqueue_task.output[:enqueued_file_name], organization_id, disconnected)
7
7
  end
8
8
 
9
9
  def run
10
10
  logger.debug('Ensuring objects')
11
11
  ensure_ouput_folder
12
+ ensure_output_script
12
13
  logger.debug("Copying #{report_file} to #{uploads_folder}")
13
14
  enqueued_file_name = File.join(uploads_folder, report_file)
14
15
  FileUtils.mv(File.join(base_folder, report_file), enqueued_file_name)
@@ -21,10 +22,31 @@ module ForemanInventoryUpload
21
22
  @uploads_folder ||= ForemanInventoryUpload.uploads_folder
22
23
  end
23
24
 
25
+ def script_file
26
+ @script_file ||= File.join(uploads_folder, ForemanInventoryUpload.upload_script_file)
27
+ end
28
+
24
29
  def ensure_ouput_folder
25
30
  FileUtils.mkdir_p(uploads_folder)
26
31
  end
27
32
 
33
+ def ensure_output_script
34
+ return if File.exist?(script_file)
35
+
36
+ script_source = File.join(ForemanRhCloud::Engine.root, 'lib/foreman_inventory_upload/scripts/uploader.sh.erb')
37
+
38
+ template_src = Foreman::Renderer::Source::String.new(content: File.read(script_source))
39
+ scope = Foreman::Renderer::Scope::Base.new(
40
+ source: template_src,
41
+ variables: {
42
+ upload_url: ForemanInventoryUpload.upload_url,
43
+ }
44
+ )
45
+ script_source = Foreman::Renderer.render(template_src, scope)
46
+ File.write(script_file, script_source)
47
+ FileUtils.chmod('+x', script_file)
48
+ end
49
+
28
50
  def logger
29
51
  Foreman::Logging.logger('background')
30
52
  end
@@ -37,8 +59,8 @@ module ForemanInventoryUpload
37
59
  input[:report_file]
38
60
  end
39
61
 
40
- def plan_upload_report(enqueued_file_name, organization_id)
41
- plan_action(UploadReportDirectJob, enqueued_file_name, organization_id)
62
+ def plan_upload_report(enqueued_file_name, organization_id, disconnected)
63
+ plan_action(UploadReportJob, enqueued_file_name, organization_id, disconnected)
42
64
  end
43
65
  end
44
66
  end