foreman_rh_cloud 2.0.9 → 2.0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -2
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +3 -0
  4. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +25 -0
  5. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +18 -0
  6. data/app/controllers/insights_cloud/hits_controller.rb +17 -0
  7. data/app/controllers/insights_cloud/settings_controller.rb +24 -0
  8. data/app/controllers/insights_cloud/tasks_controller.rb +1 -2
  9. data/app/helpers/foreman_inventory_upload_host_helper.rb +10 -2
  10. data/app/models/concerns/rh_cloud_host.rb +15 -0
  11. data/app/models/insights_facet.rb +5 -1
  12. data/app/models/insights_hit.rb +1 -1
  13. data/app/models/inventory_sync/inventory_status.rb +30 -0
  14. data/app/models/setting/rh_cloud.rb +3 -0
  15. data/app/overrides/hosts_list.rb +1 -1
  16. data/app/services/foreman_rh_cloud/cloud_auth.rb +28 -0
  17. data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +1 -6
  18. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -1
  19. data/app/views/hosts/_insights_tab.html.erb +9 -0
  20. data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -1
  21. data/config/routes.rb +6 -0
  22. data/db/migrate/20200727111529_add_uuid_column_to_insights_facets.foreman_rh_cloud.rb +5 -0
  23. data/db/migrate/20201007115752_add_hits_count_to_insights_facets_table.foreman_rh_cloud.rb +5 -0
  24. data/db/migrate/20201007121540_setup_hits_count_cache.foreman_rh_cloud.rb +10 -0
  25. data/lib/foreman_inventory_upload.rb +4 -0
  26. data/lib/foreman_inventory_upload/async/generate_report_job.rb +1 -1
  27. data/lib/foreman_inventory_upload/async/shell_process.rb +15 -9
  28. data/lib/foreman_inventory_upload/async/upload_report_job.rb +21 -5
  29. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +36 -1
  30. data/lib/foreman_inventory_upload/generators/json_stream.rb +7 -2
  31. data/lib/foreman_inventory_upload/generators/metadata.rb +3 -0
  32. data/lib/foreman_inventory_upload/generators/queries.rb +4 -4
  33. data/lib/foreman_inventory_upload/generators/slice.rb +51 -27
  34. data/lib/foreman_rh_cloud.rb +68 -0
  35. data/lib/foreman_rh_cloud/engine.rb +19 -3
  36. data/lib/foreman_rh_cloud/version.rb +1 -1
  37. data/lib/insights_cloud.rb +8 -8
  38. data/lib/insights_cloud/async/insights_full_sync.rb +19 -31
  39. data/lib/insights_cloud/async/insights_scheduled_sync.rb +23 -0
  40. data/lib/inventory_sync/async/host_result.rb +50 -0
  41. data/lib/inventory_sync/async/inventory_full_sync.rb +80 -0
  42. data/lib/tasks/insights.rake +15 -0
  43. data/lib/tasks/rh_cloud_inventory.rake +37 -0
  44. data/package.json +3 -1
  45. data/test/controllers/insights_sync/settings_controller_test.rb +30 -0
  46. data/test/factories/insights_factories.rb +31 -0
  47. data/test/jobs/insights_full_sync_test.rb +4 -2
  48. data/test/jobs/inventory_full_sync_test.rb +91 -0
  49. data/test/jobs/upload_report_job_test.rb +34 -0
  50. data/test/unit/fact_helpers_test.rb +22 -0
  51. data/test/unit/insights_facet_test.rb +23 -0
  52. data/test/unit/metadata_generator_test.rb +2 -0
  53. data/test/unit/rh_cloud_http_proxy_test.rb +65 -0
  54. data/test/unit/slice_generator_test.rb +143 -8
  55. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +16 -1
  56. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +22 -17
  57. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +18 -0
  58. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +8 -0
  59. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +7 -0
  60. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +12 -6
  61. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +9 -0
  62. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +20 -0
  63. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +12 -0
  64. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -0
  65. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +2 -0
  66. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +10 -11
  67. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
  68. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +12 -2
  69. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +17 -0
  70. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +1 -0
  71. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +30 -0
  72. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +29 -0
  73. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +1 -0
  74. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +13 -0
  75. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +21 -0
  76. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +38 -0
  77. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +31 -0
  78. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +41 -0
  79. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +36 -0
  80. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +3 -0
  81. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +20 -0
  82. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +5 -1
  83. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -0
  84. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +15 -13
  85. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +2 -1
  86. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +1 -0
  87. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +3 -0
  88. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +10 -11
  89. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -2
  90. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +12 -2
  91. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +18 -1
  92. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +13 -2
  93. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +10 -1
  94. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +6 -0
  95. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +9 -0
  96. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +4 -0
  97. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +2 -0
  98. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +1 -0
  99. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +29 -0
  100. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +29 -0
  101. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +1 -0
  102. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +13 -0
  103. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +21 -0
  104. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +38 -0
  105. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +31 -0
  106. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +20 -0
  107. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +1 -1
  108. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +3 -3
  109. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +1 -0
  110. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +1 -0
  111. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +1 -0
  112. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +1 -0
  113. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +58 -0
  114. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +57 -0
  115. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +3 -0
  116. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +36 -0
  117. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +13 -0
  118. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +13 -0
  119. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +31 -0
  120. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +9 -0
  121. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +26 -0
  122. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +36 -0
  123. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +26 -0
  124. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +98 -0
  125. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +18 -0
  126. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +18 -0
  127. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +63 -0
  128. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +41 -0
  129. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +20 -0
  130. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +22 -0
  131. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -0
  132. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -0
  133. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +6 -1
  134. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +1 -1
  135. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +1 -1
  136. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +1 -1
  137. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +6 -1
  138. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +2 -4
  139. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +3 -1
  140. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +8 -0
  141. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +2 -0
  142. data/webpack/ForemanRhCloudPages.js +9 -0
  143. data/webpack/ForemanRhCloudReducers.js +2 -0
  144. data/webpack/ForemanRhCloudSelectors.js +5 -0
  145. data/webpack/ForemanRhCloudTestHelpers.js +17 -3
  146. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +33 -0
  147. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +57 -0
  148. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +4 -0
  149. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +24 -0
  150. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsSelectors.js +6 -0
  151. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +18 -0
  152. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +62 -0
  153. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +33 -0
  154. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +21 -0
  155. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +15 -0
  156. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +65 -0
  157. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +19 -0
  158. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +9 -0
  159. data/webpack/InsightsCloudSync/Components/InsightsSettings/index.js +21 -0
  160. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +16 -0
  161. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +1 -0
  162. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +45 -0
  163. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +17 -0
  164. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +38 -0
  165. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +1 -0
  166. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +3 -0
  167. data/webpack/InsightsCloudSync/InsightsCloudSync.js +34 -32
  168. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +1 -3
  169. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +10 -11
  170. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -2
  171. data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +7 -2
  172. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +51 -46
  173. data/webpack/InsightsCloudSync/index.js +2 -1
  174. data/webpack/InsightsHostDetailsTab/InsightsTab.js +66 -0
  175. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +86 -0
  176. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +31 -0
  177. data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +2 -0
  178. data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +19 -0
  179. data/webpack/InsightsHostDetailsTab/InsightsTabSelectors.js +3 -0
  180. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +25 -0
  181. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.test.js +13 -0
  182. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +19 -0
  183. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabIntegration.test.js +17 -0
  184. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +26 -0
  185. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js +13 -0
  186. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +34 -0
  187. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +58 -0
  188. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +34 -0
  189. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +20 -0
  190. data/webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js +69 -0
  191. data/webpack/InsightsHostDetailsTab/components/ListItem/index.js +1 -0
  192. data/webpack/InsightsHostDetailsTab/index.js +20 -0
  193. data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +1 -0
  194. data/webpack/__mocks__/foremanReact/constants.js +5 -0
  195. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
  196. data/webpack/__tests__/ForemanRhCloudSelectors.test.js +4 -1
  197. data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +12 -2
  198. data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +10 -9
  199. data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +27 -2
  200. data/webpack/index.js +2 -12
  201. metadata +120 -12
  202. data/lib/tasks/generator.rake +0 -29
  203. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/hostObfuscationSwitcher.scss +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c164b990c325cd1f5e90004585c0074c558ee29ece8b687d37115d88f278274d
4
- data.tar.gz: 01f04d99170a49224c7687949acff8d7171ce73d0d620343ce348c324b2b6040
3
+ metadata.gz: aef13982f858bea42312ee1495b628b86c789e54d81ad939853f0657dbd0d5ad
4
+ data.tar.gz: 0e9e278c013651e9407d56cc0a85d3c923e28718b91d40a626cb395de572c702
5
5
  SHA512:
6
- metadata.gz: dc211d399ff2f518b47ccfe76e8a569cac8b3356bab5dc6f2dabfc8c0a3de2926dd8fe99f2a84ea8dba9e4dea3b871cdd3380dfebb48e51cdcb1198dbac16bc8
7
- data.tar.gz: 622e9894c0bef62e38f25b687d2acb0c5db74cf8e299e5a327f102052704324e2aafaee71fa30b595de66a29124789a815899e3f324000c559e3c75ce2ce401c
6
+ metadata.gz: c923cf6e37a14a608601f343dfed4184b8d22a4356372a65bfd3b94fc6aa451848d50952b54adad6cada51af4a7452af3554b9f2ccd325f6b530b51f2fa3b272
7
+ data.tar.gz: 28b1eb1031ce920dfe66e379c52f0ea7c4799114b6d84104df47b005d722caa08b5ae930fed87de0762ac0fe9a25a83c1fc40c7abc1147ed0da36723ce4eed76
data/README.md CHANGED
@@ -13,11 +13,36 @@ for how to install Foreman plugins
13
13
 
14
14
  ### In Satellite
15
15
 
16
- Normally you run it via UI in RH Cloud -> Inventory Upload -> Restart, but if you need to run from command-line for some reason:
16
+ #### Inventory upload
17
+
18
+ In UI: Configure -> Inventory Upload -> Restart
19
+
20
+ From command-line:
17
21
 
18
22
  export organization_id=1
19
23
  export target=/var/lib/foreman/red_hat_inventory/generated_reports/
20
- /usr/sbin/foreman-rake foreman_inventory_upload:report:generate
24
+ /usr/sbin/foreman-rake rh_cloud_inventory:report:generate
25
+
26
+ #### Fetch hosts remediation data
27
+
28
+ In UI: Configure -> Insights -> Sync now
29
+
30
+ From command-line:
31
+
32
+ /usr/sbin/foreman-rake rh_cloud_inventory:sync
33
+
34
+ #### Synchronize inventory status
35
+
36
+ In UI: Configure -> Inventory Upload -> Sync inventory status
37
+
38
+ From command-line:
39
+
40
+ # all organizations
41
+ /usr/sbin/foreman-rake rh_cloud_insights:sync
42
+
43
+ # specific organization with id 1
44
+ export organization_id=1
45
+ /usr/sbin/foreman-rake rh_cloud_insights:sync
21
46
 
22
47
  ## TODO
23
48
 
@@ -23,6 +23,9 @@ module ForemanInventoryUpload
23
23
  render json: {
24
24
  autoUploadEnabled: Setting[:allow_auto_inventory_upload],
25
25
  hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
26
+ ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
27
+ cloudToken: Setting[:rh_cloud_token],
28
+ excludePackages: Setting[:exclude_installed_packages],
26
29
  accounts: accounts,
27
30
  }, status: :ok
28
31
  end
@@ -0,0 +1,25 @@
1
+ module ForemanInventoryUpload
2
+ class TasksController < ::ApplicationController
3
+ def create
4
+ selected_org = Organization.current
5
+ subscribed_hosts_ids = Set.new(
6
+ ForemanInventoryUpload::Generators::Queries.for_slice(
7
+ Host.unscoped.where(organization: selected_org)
8
+ ).pluck(:id)
9
+ )
10
+
11
+ if subscribed_hosts_ids.empty?
12
+ return render json: {
13
+ message: N_('Nothing to sync, there are no hosts with subscription for this organization.'),
14
+ }, status: :method_not_allowed
15
+ else
16
+ host_statuses = InventorySync::Async::InventoryFullSync.perform_now(selected_org)
17
+ end
18
+
19
+ render json: {
20
+ syncHosts: host_statuses[:sync],
21
+ disconnectHosts: host_statuses[:disconnect],
22
+ }, status: :ok
23
+ end
24
+ end
25
+ end
@@ -46,6 +46,24 @@ module ForemanInventoryUpload
46
46
  ActiveModel::Type::Boolean.new.cast(params.require(:value))
47
47
  end
48
48
 
49
+ def installed_packages_inclusion
50
+ Setting[:exclude_installed_packages] = host_obfuscation_params
51
+ render_setting(:excludePackages, :exclude_installed_packages)
52
+ end
53
+
54
+ def installed_packages_inclusion_params
55
+ ActiveModel::Type::Boolean.new.cast(params.require(:value))
56
+ end
57
+
58
+ def ips_obfuscation
59
+ Setting[:obfuscate_inventory_ips] = ips_obfuscation_params
60
+ render_setting(:ipsObfuscationEnabled, :obfuscate_inventory_ips)
61
+ end
62
+
63
+ def ips_obfuscation_params
64
+ ActiveModel::Type::Boolean.new.cast(params.require(:value))
65
+ end
66
+
49
67
  private
50
68
 
51
69
  def render_setting(node_name, setting)
@@ -0,0 +1,17 @@
1
+ module InsightsCloud
2
+ class HitsController < ::ApplicationController
3
+ def index
4
+ host = Host.where(id: host_id_param).first
5
+
6
+ render json: {
7
+ hits: host.insights.hits,
8
+ }, status: :ok
9
+ end
10
+
11
+ private
12
+
13
+ def host_id_param
14
+ params.require(:host_id)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ module InsightsCloud
2
+ class SettingsController < ::ApplicationController
3
+ def show
4
+ render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
5
+ end
6
+
7
+ def update
8
+ Setting[:allow_auto_insights_sync] = settings_params
9
+ render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
10
+ end
11
+
12
+ private
13
+
14
+ def render_setting(node_name, setting)
15
+ render json: {
16
+ node_name => Setting[setting],
17
+ }
18
+ end
19
+
20
+ def settings_params
21
+ ActiveModel::Type::Boolean.new.cast(params.require(:insightsSyncEnabled))
22
+ end
23
+ end
24
+ end
@@ -1,8 +1,7 @@
1
1
  module InsightsCloud
2
2
  class TasksController < ::ApplicationController
3
3
  def create
4
- selected_org = Organization.current
5
- InsightsCloud::Async::InsightsFullSync.perform_now(selected_org)
4
+ InsightsCloud::Async::InsightsFullSync.perform_now
6
5
  end
7
6
  end
8
7
  end
@@ -5,7 +5,15 @@ module ForemanInventoryUploadHostHelper
5
5
 
6
6
  def hits_counts_cell(host)
7
7
  host_hits = hits_counts[host.id]
8
- content = n_('One recommendation', '%{hits} recommendations', host_hits) % { hits: host_hits } if host_hits
9
- tag.td content, class: ['hidden-xs', 'ellipsis']
8
+ tag.td class: ['hidden-xs', 'ellipsis', 'text-center'] do
9
+ if host_hits
10
+ link_to(
11
+ host_hits,
12
+ InsightsCloud::WebUi.system_url(InsightsCloud::WebUi::ADVISOR, host.insights.uuid),
13
+ :rel => 'external noopener noreferrer',
14
+ :target => '_blank'
15
+ )
16
+ end
17
+ end
10
18
  end
11
19
  end
@@ -0,0 +1,15 @@
1
+ module RhCloudHost
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ has_many(
6
+ :inventory_upload_facts,
7
+ -> { where(fact_name_id: ForemanInventoryUpload::Generators::Queries.fact_names.values) },
8
+ class_name: 'FactValue',
9
+ foreign_key: :host_id
10
+ )
11
+
12
+ has_many :insights_hits, through: :insights, source: :hits
13
+ scoped_search :relation => :insights, :on => :hits_count, :only_explicit => true, :rename => :insights_recommendations_count
14
+ end
15
+ end
@@ -1,3 +1,7 @@
1
1
  class InsightsFacet < HostFacets::Base
2
- has_many :hits, foreign_key: :host_id, primary_key: :host_id, class_name: 'InsightsHit'
2
+ has_many :hits,
3
+ foreign_key: :host_id,
4
+ primary_key: :host_id,
5
+ class_name: 'InsightsHit',
6
+ dependent: :destroy
3
7
  end
@@ -2,5 +2,5 @@ class InsightsHit < ApplicationRecord
2
2
  has_one :host
3
3
  # since the facet is one-to-one association with a host, we can connect
4
4
  # through host_id column on both this model and facet.
5
- has_one :insights_facet, foreign_key: 'host_id', primary_key: 'host_id'
5
+ belongs_to :insights_facet, foreign_key: 'host_id', primary_key: 'host_id', counter_cache: :hits_count
6
6
  end
@@ -0,0 +1,30 @@
1
+ module InventorySync
2
+ class InventoryStatus < HostStatus::Status
3
+ DISCONNECT = 0
4
+ SYNC = 1
5
+
6
+ def self.status_name
7
+ N_('Inventory')
8
+ end
9
+
10
+ def to_global(_options = {})
11
+ case status
12
+ when DISCONNECT
13
+ ::HostStatus::Global::WARN
14
+ when SYNC
15
+ ::HostStatus::Global::OK
16
+ else
17
+ ::HostStatus::Global::WARN
18
+ end
19
+ end
20
+
21
+ def to_label
22
+ case status
23
+ when DISCONNECT
24
+ N_('Host was not uploaded to your RH cloud inventory')
25
+ when SYNC
26
+ N_('Successfully uploaded to your RH cloud inventory')
27
+ end
28
+ end
29
+ end
30
+ end
@@ -4,8 +4,11 @@ class Setting::RhCloud < Setting
4
4
  return unless super
5
5
  [
6
6
  set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false),
7
+ set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false),
7
8
  set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false),
9
+ set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false),
8
10
  set('rh_cloud_token', N_('Authentication token to Red Hat cloud services. Used to authenticate requests to cloud APIs'), 'DEFAULT', N_('Red Hat Cloud token'), nil, encrypted: true),
11
+ set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false),
9
12
  ]
10
13
  end
11
14
 
@@ -2,7 +2,7 @@ Deface::Override.new(
2
2
  virtual_path: 'hosts/_list',
3
3
  name: 'insights_hits_header',
4
4
  insert_before: 'thead tr th.hidden-xs:first-of-type',
5
- text: '<th class="hidden-xs" width="10%"><%= _("Insights")%></th>'
5
+ text: '<th class="hidden-xs ellipsis" width="12%"><%= sort :insights_recommendations_count, :as => _("Recommendations")%></th>'
6
6
  )
7
7
 
8
8
  Deface::Override.new(
@@ -0,0 +1,28 @@
1
+ module ForemanRhCloud
2
+ module CloudAuth
3
+ extend ActiveSupport::Concern
4
+
5
+ def rh_credentials
6
+ @rh_credentials ||= query_refresh_token
7
+ end
8
+
9
+ def query_refresh_token
10
+ token_response = RestClient::Request.execute(
11
+ method: :post,
12
+ url: ForemanRhCloud.authentication_url,
13
+ verify_ssl: ForemanRhCloud.verify_ssl_method,
14
+ proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
15
+ payload: {
16
+ grant_type: 'refresh_token',
17
+ client_id: 'rhsm-api',
18
+ refresh_token: Setting[:rh_cloud_token],
19
+ }
20
+ )
21
+
22
+ JSON.parse(token_response)['access_token']
23
+ rescue RestClient::ExceptionWithResponse => e
24
+ Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
25
+ raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
26
+ end
27
+ end
28
+ end
@@ -1,6 +1 @@
1
- <%= mount_react_component(
2
- 'InsightsCloudSync',
3
- '#ForemanRhCloudReactRoot',
4
- {
5
- settingsUrl: settings_url(search: 'name = rh_cloud_token')
6
- }.to_json) %>
1
+ <%= react_component('InsightsCloudSync', { settingsUrl: settings_url(search: 'name = rh_cloud_token') }) %>
@@ -1 +1 @@
1
- <%= mount_react_component("ForemanInventoryUpload", '#ForemanRhCloudReactRoot') %>
1
+ <%= react_component('ForemanInventoryUpload') %>
@@ -0,0 +1,9 @@
1
+ <% content_for(:javascripts) do %>
2
+ <%= webpacked_plugins_js_for :'foreman_rh_cloud' %>
3
+ <% end %>
4
+
5
+ <% content_for(:stylesheets) do %>
6
+ <%= webpacked_plugins_css_for :'foreman_rh_cloud' %>
7
+ <% end %>
8
+
9
+ <%= react_component('InsightsHostDetailsTab', { hostID: host.id }) %>
@@ -10,7 +10,6 @@
10
10
  <%= notifications %>
11
11
  <div id="organization-id" data-id="<%= Organization.current.id if Organization.current %>" ></div>
12
12
  <div id="user-id" data-id="<%= User.current.id if User.current %>" ></div>
13
- <div id="ForemanRhCloudReactRoot"></div>
14
13
  <%= yield %>
15
14
  <% end %>
16
15
  <%= render file: "layouts/base" %>
@@ -8,10 +8,16 @@ Rails.application.routes.draw do
8
8
  get 'auto_upload', to: 'uploads#show_auto_upload'
9
9
  post 'auto_upload', to: 'uploads#auto_upload'
10
10
  post 'host_obfuscation', to: 'uploads#host_obfuscation'
11
+ post 'installed_packages_inclusion', to: 'uploads#installed_packages_inclusion'
12
+ post 'ips_obfuscation', to: 'uploads#ips_obfuscation'
13
+
14
+ resources :tasks, only: [:create]
11
15
  end
12
16
 
13
17
  namespace :insights_cloud do
14
18
  resources :tasks, only: [:create]
19
+ resource :settings, only: [:show, :update]
20
+ get 'hits/:host_id', to: 'hits#index'
15
21
  end
16
22
 
17
23
  namespace :foreman_rh_cloud do
@@ -0,0 +1,5 @@
1
+ class AddUuidColumnToInsightsFacets < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :insights_facets, :uuid, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddHitsCountToInsightsFacetsTable < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :insights_facets, :hits_count, :integer
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class SetupHitsCountCache < ActiveRecord::Migration[5.0]
2
+ def up
3
+ ActiveRecord::Base.connection.execute <<-SQL.squish
4
+ UPDATE insights_facets
5
+ SET hits_count = (SELECT count(1)
6
+ FROM insights_hits
7
+ WHERE insights_hits.host_id = insights_facets.host_id)
8
+ SQL
9
+ end
10
+ end
@@ -60,4 +60,8 @@ module ForemanInventoryUpload
60
60
  FileUtils.mkdir_p(folder)
61
61
  folder
62
62
  end
63
+
64
+ def self.inventory_export_url
65
+ ForemanRhCloud.base_url + '/api/inventory/v1/hosts'
66
+ end
63
67
  end
@@ -23,7 +23,7 @@ module ForemanInventoryUpload
23
23
  end
24
24
 
25
25
  def command
26
- "#{rake_prefix}rake foreman_inventory_upload:report:generate"
26
+ "#{rake_prefix}rake rh_cloud_inventory:report:generate"
27
27
  end
28
28
 
29
29
  def env
@@ -8,24 +8,30 @@ module ForemanInventoryUpload
8
8
  def perform(instance_label)
9
9
  klass_name = self.class.name
10
10
  logger.debug("Starting #{klass_name} with label #{instance_label}")
11
- progress_output = ProgressOutput.register(instance_label)
12
- Open3.popen2e(hash_to_s(env), *preprocess_command(command)) do |_stdin, stdout_stderr, wait_thread|
13
- progress_output.status = "Running in pid #{wait_thread.pid}"
11
+ progress_output_for(instance_label) do |progress_output|
12
+ Open3.popen2e(hash_to_s(env), *preprocess_command(command)) do |_stdin, stdout_stderr, wait_thread|
13
+ progress_output.status = "Running in pid #{wait_thread.pid}"
14
14
 
15
- stdout_stderr.each do |out_line|
16
- progress_output.write_line(out_line)
17
- end
15
+ stdout_stderr.each do |out_line|
16
+ progress_output.write_line(out_line)
17
+ end
18
18
 
19
- progress_output.status = wait_thread.value.to_s
19
+ progress_output.status = wait_thread.value.to_s
20
+ end
20
21
  end
21
22
  logger.debug("Finished job #{klass_name} with label #{instance_label}")
22
- ensure
23
- progress_output.close
24
23
  end
25
24
 
26
25
  def command
27
26
  end
28
27
 
28
+ def progress_output_for(instance_label)
29
+ progress_output = ProgressOutput.register(instance_label)
30
+ yield(progress_output)
31
+ ensure
32
+ progress_output.close
33
+ end
34
+
29
35
  def env
30
36
  {}
31
37
  end
@@ -8,15 +8,33 @@ module ForemanInventoryUpload
8
8
  end
9
9
 
10
10
  def perform(filename, organization_id)
11
+ label = UploadReportJob.output_label(organization_id)
11
12
  @filename = filename
12
13
  @organization = Organization.find(organization_id)
13
14
 
15
+ if Setting[:content_disconnected]
16
+ progress_output_for(label) do |progress_output|
17
+ progress_output.write_line('Upload was stopped since disconnected mode setting is enabled for content on this instance.')
18
+ progress_output.status = "Task aborted, exit 1"
19
+ end
20
+ return
21
+ end
22
+
23
+ unless @organization.owner_details&.fetch('upstreamConsumer')&.fetch('idCert')
24
+ logger.info("Skipping organization '#{@organization}', no candlepin certificate defined.")
25
+ progress_output_for(label) do |progress_output|
26
+ progress_output.write_line("Skipping organization #{@organization}, no candlepin certificate defined.")
27
+ progress_output.status = "Task aborted, exit 1"
28
+ end
29
+ return
30
+ end
31
+
14
32
  Tempfile.create([@organization.name, '.pem']) do |cer_file|
15
33
  cer_file.write(rh_credentials[:cert])
16
34
  cer_file.write(rh_credentials[:key])
17
35
  cer_file.flush
18
36
  @cer_path = cer_file.path
19
- super(UploadReportJob.output_label(organization_id))
37
+ super(label)
20
38
  end
21
39
  end
22
40
 
@@ -29,6 +47,8 @@ module ForemanInventoryUpload
29
47
  'FILES' => @filename,
30
48
  'CER_PATH' => @cer_path
31
49
  )
50
+
51
+ http_proxy_string = ForemanRhCloud.http_proxy_string(logger: logger)
32
52
  if http_proxy_string
33
53
  env_vars['http_proxy'] = http_proxy_string
34
54
  env_vars['https_proxy'] = http_proxy_string
@@ -36,10 +56,6 @@ module ForemanInventoryUpload
36
56
  env_vars
37
57
  end
38
58
 
39
- def http_proxy_string
40
- @http_proxy_string ||= HttpProxy.default_global_content_proxy&.full_url
41
- end
42
-
43
59
  def rh_credentials
44
60
  @rh_credentials ||= begin
45
61
  candlepin_id_certificate = @organization.owner_details['upstreamConsumer']['idCert']