foreman_rh_cloud 3.0.17 → 3.0.21

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 (228) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -5
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +3 -15
  4. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +14 -3
  5. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +0 -48
  6. data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +34 -0
  7. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +17 -7
  8. data/app/controllers/insights_cloud/hits_controller.rb +38 -1
  9. data/app/controllers/insights_cloud/settings_controller.rb +1 -1
  10. data/app/controllers/insights_cloud/tasks_controller.rb +1 -2
  11. data/app/models/insights_client_report_status.rb +58 -0
  12. data/app/models/insights_resolution.rb +1 -1
  13. data/app/models/inventory_sync/inventory_status.rb +6 -0
  14. data/app/models/setting/rh_cloud.rb +5 -5
  15. data/app/services/foreman_rh_cloud/branch_info.rb +3 -14
  16. data/app/services/foreman_rh_cloud/cloud_connector.rb +12 -7
  17. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +32 -19
  18. data/app/services/foreman_rh_cloud/remediations_retriever.rb +78 -0
  19. data/app/services/foreman_rh_cloud/template_renderer_helper.rb +22 -0
  20. data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +9 -0
  21. data/app/views/job_templates/rh_cloud_remediations.erb +14 -0
  22. data/config/routes.rb +4 -6
  23. data/db/migrate/20210307000001_add_unique_to_insights_facet.foreman_rh_cloud.rb +11 -0
  24. data/db/migrate/20210404000001_change_resolutions.foreman_rh_cloud.rb +10 -0
  25. data/db/seeds.d/179_ui_notifications.rb +11 -0
  26. data/db/seeds.d/50_job_templates.rb +14 -0
  27. data/lib/foreman_inventory_upload.rb +11 -1
  28. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +8 -2
  29. data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
  30. data/lib/foreman_inventory_upload/generators/queries.rb +3 -2
  31. data/lib/foreman_inventory_upload/generators/slice.rb +14 -21
  32. data/lib/foreman_inventory_upload/generators/tags.rb +61 -0
  33. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +5 -1
  34. data/lib/foreman_rh_cloud.rb +22 -0
  35. data/lib/foreman_rh_cloud/engine.rb +34 -2
  36. data/lib/foreman_rh_cloud/version.rb +1 -1
  37. data/lib/insights_cloud.rb +12 -0
  38. data/lib/insights_cloud/async/insights_full_sync.rb +39 -24
  39. data/lib/insights_cloud/async/insights_generate_notifications.rb +58 -0
  40. data/lib/insights_cloud/async/insights_resolutions_sync.rb +69 -0
  41. data/lib/insights_cloud/async/insights_rules_sync.rb +13 -17
  42. data/lib/insights_cloud/async/insights_scheduled_sync.rb +1 -1
  43. data/lib/inventory_sync/async/host_result.rb +11 -6
  44. data/lib/inventory_sync/async/inventory_full_sync.rb +24 -41
  45. data/lib/inventory_sync/async/inventory_hosts_sync.rb +34 -0
  46. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +17 -0
  47. data/lib/inventory_sync/async/query_inventory_job.rb +54 -0
  48. data/lib/tasks/insights.rake +4 -12
  49. data/lib/tasks/rh_cloud_inventory.rake +12 -4
  50. data/package.json +1 -1
  51. data/test/controllers/accounts_controller_test.rb +1 -5
  52. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +12 -0
  53. data/test/controllers/uploads_controller_test.rb +0 -13
  54. data/test/controllers/uploads_settings_controller_test.rb +31 -0
  55. data/test/factories/insights_factories.rb +22 -0
  56. data/test/jobs/insights_full_sync_test.rb +25 -15
  57. data/test/jobs/insights_resolutions_sync_test.rb +74 -0
  58. data/test/jobs/insights_rules_sync_test.rb +5 -3
  59. data/test/jobs/inventory_full_sync_test.rb +182 -12
  60. data/test/models/insights_client_report_status_test.rb +77 -0
  61. data/test/test_plugin_helper.rb +13 -0
  62. data/test/unit/rh_cloud_http_proxy_test.rb +4 -4
  63. data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +5 -5
  64. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +39 -4
  65. data/test/unit/services/foreman_rh_cloud/remediations_retriever_test.rb +49 -0
  66. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +28 -0
  67. data/test/unit/slice_generator_test.rb +7 -2
  68. data/test/unit/tags_generator_test.rb +70 -0
  69. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +4 -19
  70. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +7 -7
  71. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
  72. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -34
  73. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +0 -14
  74. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +6 -4
  75. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +6 -4
  76. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +14 -12
  77. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +10 -1
  78. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +7 -7
  79. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +12 -9
  80. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +3 -3
  81. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +0 -30
  82. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +1 -23
  83. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +6 -6
  84. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +3 -8
  85. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +3 -35
  86. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -18
  87. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +24 -22
  88. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +1 -1
  89. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +1 -1
  90. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +2 -1
  91. data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +4 -2
  92. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +2 -1
  93. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +16 -14
  94. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +2 -1
  95. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +2 -1
  96. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +30 -16
  97. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +1 -24
  98. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +8 -2
  99. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +1 -17
  100. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +4 -9
  101. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +0 -12
  102. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +2 -3
  103. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +1 -1
  104. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +2 -0
  105. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +1 -1
  106. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingActions.js +7 -0
  107. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingsConstants.js +28 -0
  108. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
  109. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
  110. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/index.js +29 -0
  111. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +7 -8
  112. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.scss +15 -9
  113. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsActions.js +23 -0
  114. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsConstants.js +9 -0
  115. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +19 -0
  116. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
  117. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +16 -4
  118. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
  119. data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +16 -1
  120. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +1 -1
  121. data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -5
  122. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +1 -1
  123. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +1 -1
  124. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +15 -2
  125. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +13 -2
  126. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +1 -1
  127. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +81 -46
  128. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +3 -3
  129. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +6 -12
  130. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +1 -1
  131. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +1 -9
  132. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +18 -27
  133. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +1 -16
  134. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +58 -0
  135. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +51 -0
  136. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +1 -1
  137. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +1 -1
  138. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +3 -6
  139. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +1 -1
  140. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +1 -1
  141. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +1 -1
  142. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +1 -1
  143. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -1
  144. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +8 -6
  145. data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +9 -7
  146. data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +4 -2
  147. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +7 -5
  148. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +2 -1
  149. data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +15 -13
  150. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +27 -25
  151. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +1 -1
  152. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +0 -2
  153. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +13 -8
  154. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +3 -3
  155. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +21 -9
  156. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +3 -8
  157. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +6 -4
  158. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +1 -1
  159. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +1 -1
  160. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +1 -1
  161. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +1 -1
  162. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +3 -0
  163. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +2 -0
  164. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +1 -1
  165. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediateButton.js +59 -0
  166. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationActions.js +12 -0
  167. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationHelpers.js +43 -0
  168. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +101 -0
  169. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +9 -0
  170. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModalFooter.js +43 -0
  171. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationTableConstants.js +38 -0
  172. data/webpack/InsightsCloudSync/Components/RemediationModal/Resolutions.js +55 -0
  173. data/webpack/InsightsCloudSync/Components/RemediationModal/index.js +34 -0
  174. data/webpack/InsightsCloudSync/InsightsCloudSync.js +8 -3
  175. data/webpack/InsightsCloudSync/InsightsCloudSync.scss +5 -0
  176. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +1 -1
  177. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +9 -6
  178. data/webpack/InsightsHostDetailsTab/InsightsTab.js +2 -1
  179. data/webpack/__mocks__/foremanReact/components/Layout/LayoutSelectors.js +1 -0
  180. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +1 -1
  181. data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +4 -0
  182. data/webpack/common/Switcher/SwitcherPF4.scss +1 -1
  183. data/webpack/{InsightsCloudSync/Components/InsightsTable/components → common/table}/EmptyState.js +0 -0
  184. data/webpack/common/table/helpers.js +7 -0
  185. metadata +86 -62
  186. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +0 -3
  187. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +0 -29
  188. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +0 -29
  189. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
  190. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +0 -14
  191. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +0 -24
  192. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +0 -15
  193. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +0 -31
  194. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/index.js +0 -17
  195. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +0 -1
  196. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +0 -27
  197. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +0 -29
  198. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +0 -1
  199. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +0 -13
  200. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +0 -21
  201. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +0 -15
  202. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +0 -31
  203. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +0 -46
  204. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +0 -36
  205. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +0 -20
  206. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +0 -2
  207. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +0 -27
  208. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +0 -29
  209. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -1
  210. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcher.test.js +0 -14
  211. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +0 -24
  212. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +0 -15
  213. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +0 -31
  214. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/index.js +0 -20
  215. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +0 -1
  216. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +0 -27
  217. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +0 -29
  218. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +0 -1
  219. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +0 -13
  220. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +0 -21
  221. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +0 -15
  222. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +0 -31
  223. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +0 -20
  224. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +0 -36
  225. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +0 -31
  226. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +0 -26
  227. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +0 -98
  228. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de4c573e51011ac6fd99707859fa86d659454b7f30183494ab5e240e773bec0a
4
- data.tar.gz: f0510f09adf430834e01b9732a9cf6faedff0b18471e7b90fbca8a47fe867a13
3
+ metadata.gz: f19ab6e45bf75f915a43c8db5e829f77fe6e5e7b62998d42fe4207ce37dcc062
4
+ data.tar.gz: c2bf184dcdfaefe41c1d13116ede5236c381c1f0bc8e71353d2875eee9cb289e
5
5
  SHA512:
6
- metadata.gz: a5ef31993d25982136027082f9fb3d382133378627afd0f5da6eeb5eb24a971aa36cdb7f8995347b017ab438124219113e6b326a52f1821e0ccbdb0a6e402f52
7
- data.tar.gz: e5da37635a059fadc6e6c62464aec98f75e803fddb1f8b1ca9b23ad27e42cffdb006bdd4ae5e59d10317d8599f6629ff8f4e08065a15947aff7f93133ec49e8a
6
+ metadata.gz: 7f2e16294caeae0098b8b8367082d75af4a706f74022dba22c040d9f545b4c99ca3c31be0d3db568c2a2dfc3de5509590a9602b026caad6ea0fb1b53a3ccc9f2
7
+ data.tar.gz: 9cc8d2349b5879d84bb9d2e95157c3eaafbff04823ea6704889b2678dc9a6a1f8fe300f09d28eef47c62cbbeccd94d96b0bbd7518969f8edbdbfb338a2fff1c7
data/README.md CHANGED
@@ -42,7 +42,7 @@ In UI: Configure -> Insights -> Sync now
42
42
 
43
43
  From command-line:
44
44
 
45
- /usr/sbin/foreman-rake rh_cloud_inventory:sync
45
+ /usr/sbin/foreman-rake rh_cloud_insights:sync
46
46
 
47
47
  #### Synchronize inventory status
48
48
 
@@ -51,16 +51,32 @@ In UI: Configure -> Inventory Upload -> Sync inventory status
51
51
  From command-line:
52
52
 
53
53
  # all organizations
54
- /usr/sbin/foreman-rake rh_cloud_insights:sync
55
-
54
+ /usr/sbin/foreman-rake rh_cloud_inventory:sync
55
+
56
56
  # specific organization with id 1
57
57
  export organization_id=1
58
- /usr/sbin/foreman-rake rh_cloud_insights:sync
58
+ /usr/sbin/foreman-rake rh_cloud_inventory:sync
59
59
 
60
60
  ## TODO
61
61
 
62
62
  *Todo list here*
63
63
 
64
+ ## Design
65
+
66
+ ### Endpoints
67
+
68
+ | purpose | url | ENV setting for the **bold** part
69
+ | ------------------------------| -------| -----------
70
+ | Inventory uploads | **https://cert.cloud.redhat.com/api/ingress/v1/upload** | SATELLITE_INVENTORY_UPLOAD_URL
71
+ | Query inventory hosts list | **https://cloud.redhat.com** /api/inventory/v1/hosts?tags= | SATELLITE_RH_CLOUD_URL
72
+ | Query insights hits | **https://cloud.redhat.com** /api/insights/v1/export/hits/ | SATELLITE_RH_CLOUD_URL
73
+ | Query insights rules | **https://cloud.redhat.com** /api/insights/v1/rule/?impacting=true&rule_status=enabled&has_playbook=true&limit=&offset= | SATELLITE_RH_CLOUD_URL
74
+ | Query insights resolutions | **https://cloud.redhat.com** /api/remediations/v1/resolutions| SATELLITE_RH_CLOUD_URL
75
+ | Forward insights-client `/static` requests | **https://cloud.redhat.com** /api/static | SATELLITE_RH_CLOUD_URL
76
+ | Forward insights-client legacy `/platform` requests | **https://cert.cloud.redhat.com** /api | SATELLITE_CERT_RH_CLOUD_URL
77
+ | Forward insights-client legacy `/redhat_access/r/insights` requests | **https://cert-api.access.redhat.com** /r/insights | SATELLITE_LEGACY_INSIGHTS_URL
78
+
79
+
64
80
  ## Contributing
65
81
 
66
82
  Fork and send a Pull Request. Thanks!
@@ -81,4 +97,3 @@ GNU General Public License for more details.
81
97
 
82
98
  You should have received a copy of the GNU General Public License
83
99
  along with this program. If not, see <http://www.gnu.org/licenses/>.
84
-
@@ -10,36 +10,24 @@ module ForemanInventoryUpload
10
10
  upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
11
11
 
12
12
  [
13
- id,
13
+ label,
14
14
  {
15
15
  generate_report_status: generate_report_status,
16
16
  upload_report_status: upload_report_status,
17
- label: label,
17
+ id: id,
18
18
  },
19
19
  ]
20
20
  end
21
21
  ]
22
22
 
23
23
  render json: {
24
- autoUploadEnabled: Setting[:allow_auto_inventory_upload],
25
- hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
26
- ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
27
- cloudToken: !Setting[:rh_cloud_token].empty?,
28
- excludePackages: Setting[:exclude_installed_packages],
29
24
  accounts: accounts,
30
- CloudConnectorStatus: cloud_connector_status,
25
+ CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
31
26
  }, status: :ok
32
27
  end
33
28
 
34
29
  private
35
30
 
36
- def cloud_connector_status
37
- cloud_connector = ForemanRhCloud::CloudConnector.new
38
- job = cloud_connector&.latest_job
39
- return nil unless job
40
- { id: job.id, task: ForemanTasks::Task.where(:id => job.task_id).first }
41
- end
42
-
43
31
  def status_for(label, job_class)
44
32
  label = job_class.output_label(label)
45
33
  ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
@@ -13,12 +13,23 @@ module ForemanInventoryUpload
13
13
  message: N_('Nothing to sync, there are no hosts with subscription for this organization.'),
14
14
  }, status: :method_not_allowed
15
15
  else
16
- host_statuses = InventorySync::Async::InventoryFullSync.perform_now(selected_org)
16
+ task = ForemanTasks.async_task(InventorySync::Async::InventoryFullSync, selected_org)
17
17
  end
18
+ return render json: { message: N_('there was an issue triggering the task') }, status: :internal_server_error unless task
18
19
 
19
20
  render json: {
20
- syncHosts: host_statuses[:sync],
21
- disconnectHosts: host_statuses[:disconnect],
21
+ task: task,
22
+ }, status: :ok
23
+ end
24
+
25
+ def show
26
+ task = ForemanTasks::Task.find_by(id: params[:id])
27
+ return render json: { message: N_('No task was found') }, status: :internal_server_error unless task
28
+
29
+ render json: {
30
+ endedAt: task.ended_at,
31
+ output: task.output,
32
+ result: task.result,
22
33
  }, status: :ok
23
34
  end
24
35
  end
@@ -21,53 +21,5 @@ module ForemanInventoryUpload
21
21
  cloud_connector = ForemanRhCloud::CloudConnector.new
22
22
  render json: cloud_connector.install.to_json
23
23
  end
24
-
25
- def auto_upload
26
- Setting[:allow_auto_inventory_upload] = auto_upload_params
27
- render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
28
- end
29
-
30
- def show_auto_upload
31
- render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
32
- end
33
-
34
- def auto_upload_params
35
- ActiveModel::Type::Boolean.new.cast(params.require(:value))
36
- end
37
-
38
- def host_obfuscation
39
- Setting[:obfuscate_inventory_hostnames] = host_obfuscation_params
40
- render_setting(:hostObfuscationEnabled, :obfuscate_inventory_hostnames)
41
- end
42
-
43
- def host_obfuscation_params
44
- ActiveModel::Type::Boolean.new.cast(params.require(:value))
45
- end
46
-
47
- def installed_packages_inclusion
48
- Setting[:exclude_installed_packages] = host_obfuscation_params
49
- render_setting(:excludePackages, :exclude_installed_packages)
50
- end
51
-
52
- def installed_packages_inclusion_params
53
- ActiveModel::Type::Boolean.new.cast(params.require(:value))
54
- end
55
-
56
- def ips_obfuscation
57
- Setting[:obfuscate_inventory_ips] = ips_obfuscation_params
58
- render_setting(:ipsObfuscationEnabled, :obfuscate_inventory_ips)
59
- end
60
-
61
- def ips_obfuscation_params
62
- ActiveModel::Type::Boolean.new.cast(params.require(:value))
63
- end
64
-
65
- private
66
-
67
- def render_setting(node_name, setting)
68
- render json: {
69
- node_name => Setting[setting],
70
- }
71
- end
72
24
  end
73
25
  end
@@ -0,0 +1,34 @@
1
+ module ForemanInventoryUpload
2
+ class UploadsSettingsController < ::ApplicationController
3
+ def index
4
+ render json: {
5
+ autoUploadEnabled: Setting[:allow_auto_inventory_upload],
6
+ hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
7
+ ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
8
+ excludePackagesEnabled: Setting[:exclude_installed_packages],
9
+ CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
10
+ cloudToken: !Setting[:rh_cloud_token].empty?,
11
+ lastSyncTask: last_successful_inventory_sync_task,
12
+ }, status: :ok
13
+ end
14
+
15
+ def set_advanced_setting
16
+ Setting[params.require(:setting)] = ActiveModel::Type::Boolean.new.cast(params.require(:value))
17
+ index
18
+ end
19
+
20
+ def self.cloud_connector_status
21
+ cloud_connector = ForemanRhCloud::CloudConnector.new
22
+ job = cloud_connector&.latest_job
23
+ return nil unless job
24
+ { id: job.id, task: ForemanTasks::Task.where(:id => job.task_id).first }
25
+ end
26
+
27
+ def last_successful_inventory_sync_task
28
+ task = ForemanTasks::Task.where(label: 'InventorySync::Async::InventoryFullSync', result: 'success')
29
+ .reorder('ended_at desc').first
30
+ return nil unless task
31
+ { output: task.output, endedAt: task.ended_at }
32
+ end
33
+ end
34
+ end
@@ -10,27 +10,28 @@ module InsightsCloud::Api
10
10
 
11
11
  skip_after_action :log_response_body, :only => [:forward_request]
12
12
  skip_before_action :check_media_type, :only => [:forward_request]
13
+ after_action :update_host_insights_status, only: [:forward_request]
13
14
 
14
15
  # The method that "proxies" requests over to Cloud
15
16
  def forward_request
16
17
  certs = candlepin_id_cert @organization
17
- cloud_response = ::ForemanRhCloud::CloudRequestForwarder.new.forward_request(request, controller_name, @branch_id, certs)
18
+ @cloud_response = ::ForemanRhCloud::CloudRequestForwarder.new.forward_request(request, controller_name, @branch_id, certs)
18
19
 
19
- if cloud_response.code == 401
20
+ if @cloud_response.code == 401
20
21
  return render json: {
21
22
  :message => 'Authentication to the Insights Service failed.',
22
23
  :headers => {},
23
24
  }, status: :bad_gateway
24
25
  end
25
26
 
26
- if cloud_response.headers[:content_disposition]
27
- return send_data cloud_response, disposition: cloud_response.headers[:content_disposition], type: cloud_response.headers[:content_type]
27
+ if @cloud_response.headers[:content_disposition]
28
+ return send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
28
29
  end
29
30
 
30
- assign_header(response, cloud_response, :x_resource_count, true)
31
- assign_header(response, cloud_response, :x_rh_insights_request_id, false)
31
+ assign_header(response, @cloud_response, :x_resource_count, true)
32
+ assign_header(response, @cloud_response, :x_rh_insights_request_id, false)
32
33
 
33
- render json: cloud_response, status: cloud_response.code
34
+ render json: @cloud_response, status: @cloud_response.code
34
35
  end
35
36
 
36
37
  def branch_info
@@ -69,5 +70,14 @@ module InsightsCloud::Api
69
70
  @branch_id = cp_owner_id(@organization)
70
71
  return render_message "Branch ID not found for organization #{@organization.title}", :status => 400 unless @branch_id
71
72
  end
73
+
74
+ def update_host_insights_status
75
+ return unless request.path == '/redhat_access/r/insights/platform/ingress/v1/upload' ||
76
+ request.path.include?('/redhat_access/r/insights/uploads/')
77
+
78
+ data = @cloud_response.code.to_s.start_with?('2')
79
+ host_status = @host.get_status(InsightsClientReportStatus)
80
+ host_status.update(reported_at: Time.now.utc, status: host_status.to_status(data: data))
81
+ end
72
82
  end
73
83
  end
@@ -3,12 +3,13 @@ module InsightsCloud
3
3
  include Foreman::Controller::AutoCompleteSearch
4
4
 
5
5
  def index
6
- hits = resource_base_search_and_page.preload(:host, :rule)
6
+ hits = resource_base_search_and_page.where(host: Host.authorized).preload(:host, :rule)
7
7
 
8
8
  render json: {
9
9
  hasToken: !Setting[:rh_cloud_token].empty?,
10
10
  hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, has_playbook: hit.has_playbook?) },
11
11
  itemCount: hits.count,
12
+ isExperimentalMode: Setting[:lab_features],
12
13
  }, status: :ok
13
14
  end
14
15
 
@@ -20,6 +21,21 @@ module InsightsCloud
20
21
  }, status: :ok
21
22
  end
22
23
 
24
+ def resolutions
25
+ if remediation_all_selected_param
26
+ hits = InsightsHit.with_playbook.search_for(params[:query])
27
+ else
28
+ hits = resource_base_search_and_page.where(id: remediation_ids_param)
29
+ end
30
+
31
+ hits.preload(:host, rule: :resolutions)
32
+
33
+ render json: {
34
+ hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, resolutions: hit.rule.resolutions.map(&:attributes), reboot: hit.rule.reboot_required) },
35
+ itemCount: hits.count,
36
+ }, status: :ok
37
+ end
38
+
23
39
  def model_of_controller
24
40
  ::InsightsHit
25
41
  end
@@ -32,10 +48,31 @@ module InsightsCloud
32
48
  :insights_hits
33
49
  end
34
50
 
51
+ def action_permission
52
+ case params[:action]
53
+ when 'resolutions'
54
+ 'view'
55
+ else
56
+ super
57
+ end
58
+ end
59
+
35
60
  private
36
61
 
37
62
  def host_id_param
38
63
  params.require(:host_id)
39
64
  end
65
+
66
+ def remediation_request_params
67
+ params.permit(remediations: [:hit_id, :remediation_id]).require(:remediations)
68
+ end
69
+
70
+ def remediation_ids_param
71
+ params.require(:ids).map(&:to_i)
72
+ end
73
+
74
+ def remediation_all_selected_param
75
+ ActiveModel::Type::Boolean.new.cast(params[:isAllSelected])
76
+ end
40
77
  end
41
78
  end
@@ -13,7 +13,7 @@ module InsightsCloud
13
13
  token = Setting::RhCloud.find_by_name("rh_cloud_token")
14
14
  token.value = params.require(:value)
15
15
  token.save!
16
- InsightsCloud::Async::InsightsFullSync.perform_now
16
+ ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync)
17
17
  redirect_to(:controller => "hits", :action => 'index')
18
18
  end
19
19
 
@@ -1,8 +1,7 @@
1
1
  module InsightsCloud
2
2
  class TasksController < ::ApplicationController
3
3
  def create
4
- job = InsightsCloud::Async::InsightsFullSync.perform_later
5
- task = ForemanTasks::Task.find_by(external_id: job.provider_job_id)
4
+ task = ForemanTasks.async_task(InsightsCloud::Async::InsightsFullSync)
6
5
 
7
6
  render json: {
8
7
  task: task,
@@ -0,0 +1,58 @@
1
+ class InsightsClientReportStatus < HostStatus::Status
2
+ REPORT_INTERVAL = 48.hours
3
+
4
+ REPORTING = 0 # host_registration_insights = true & getting data
5
+ NO_REPORT = 1 # host_registration_insights = true & not getting data
6
+ NOT_MANAGED = 2 # host_registration_insights = false
7
+ NOT_MANAGED_WITH_DATA = 3 # host_registration_insights = false & getting data
8
+
9
+ def self.status_name
10
+ N_('Insights')
11
+ end
12
+
13
+ def to_label(_options = {})
14
+ case status
15
+ when REPORTING
16
+ N_('Reporting')
17
+ when NO_REPORT
18
+ N_('Not reporting')
19
+ when NOT_MANAGED
20
+ N_('Not reporting (not set by registration)')
21
+ when NOT_MANAGED_WITH_DATA
22
+ N_('Reporting (not set by registration)')
23
+ end
24
+ end
25
+
26
+ def to_global(_options = {})
27
+ case status
28
+ when REPORTING
29
+ ::HostStatus::Global::OK
30
+ when NO_REPORT
31
+ ::HostStatus::Global::ERROR
32
+ when NOT_MANAGED
33
+ ::HostStatus::Global::OK
34
+ when NOT_MANAGED_WITH_DATA
35
+ ::HostStatus::Global::WARN
36
+ end
37
+ end
38
+
39
+ def to_status(data: false)
40
+ if insights_param
41
+ return REPORTING if data
42
+ return in_interval? ? REPORTING : NO_REPORT
43
+ end
44
+
45
+ data ? NOT_MANAGED_WITH_DATA : NOT_MANAGED
46
+ end
47
+
48
+ private
49
+
50
+ def in_interval?
51
+ return false unless reported_at
52
+ (Time.now.utc - reported_at).to_i < REPORT_INTERVAL.to_i
53
+ end
54
+
55
+ def insights_param
56
+ host.host_params_hash.dig('host_registration_insights', :value)
57
+ end
58
+ end
@@ -1,3 +1,3 @@
1
1
  class InsightsResolution < ApplicationRecord
2
- belongs_to :rule, class_name: 'InsightsRule', foreign_key: 'rule_id', primary_key: 'rule_id', inverse_of: :resolutions
2
+ belongs_to :rule, class_name: 'InsightsRule', primary_key: 'rule_id', inverse_of: :resolutions
3
3
  end
@@ -26,5 +26,11 @@ module InventorySync
26
26
  N_('Successfully uploaded to your RH cloud inventory')
27
27
  end
28
28
  end
29
+
30
+ def to_status(options = {})
31
+ # this method used to calculate status.
32
+ # Since the calculation is done externally we should return the previously calculated status
33
+ status
34
+ end
29
35
  end
30
36
  end
@@ -14,12 +14,12 @@ class Setting::RhCloud < Setting
14
14
  def self.default_settings
15
15
  return unless ActiveRecord::Base.connection.table_exists?('settings')
16
16
  [
17
- set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), true, N_('Allow automatic inventory uploads')),
18
- set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false, N_('Allow recommendations synchronization')),
19
- set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false, N_('Obfuscate host names')),
20
- set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false, N_('Obfuscate IPs')),
17
+ set('allow_auto_inventory_upload', N_('Enable automatic upload of your host inventory to the Red Hat cloud'), true, N_('Automatic inventory upload')),
18
+ set('allow_auto_insights_sync', N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud'), false, N_('Synchronize recommendations Automatically')),
19
+ set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to the Red Hat cloud'), false, N_('Obfuscate host names')),
20
+ set('obfuscate_inventory_ips', N_('Obfuscate ipv4 addresses sent to the Red Hat cloud'), false, N_('Obfuscate host ipv4 addresses')),
21
21
  set('rh_cloud_token', N_('Authentication token to Red Hat cloud services. Used to authenticate requests to cloud APIs'), nil, N_('Red Hat Cloud token'), nil, encrypted: true),
22
- set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false, N_("Don't upload installed packages")),
22
+ set('exclude_installed_packages', N_('Exclude installed packages from being uploaded to the Red Hat cloud'), false, N_("Exclude installed Packages")),
23
23
  set('include_parameter_tags', N_('Should import include parameter tags from Foreman?'), false, N_('Include parameters in insights-client reports')),
24
24
  ]
25
25
  end