foreman_rh_cloud 2.0.17 → 3.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/insights_cloud/candlepin_cache.rb +28 -0
  3. data/app/controllers/concerns/insights_cloud/client_authentication.rb +23 -0
  4. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +3 -7
  5. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +4 -54
  6. data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +26 -0
  7. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +73 -0
  8. data/app/controllers/insights_cloud/hits_controller.rb +24 -0
  9. data/app/controllers/insights_cloud/settings_controller.rb +8 -0
  10. data/app/controllers/insights_cloud/tasks_controller.rb +6 -1
  11. data/app/helpers/foreman_inventory_upload_host_helper.rb +1 -8
  12. data/app/models/insights_hit.rb +20 -1
  13. data/app/models/insights_resolution.rb +3 -0
  14. data/app/models/insights_rule.rb +3 -0
  15. data/app/models/setting/rh_cloud.rb +15 -3
  16. data/app/overrides/layouts/base/styles.html.erb.deface +2 -0
  17. data/app/services/foreman_rh_cloud/branch_info.rb +46 -0
  18. data/app/services/foreman_rh_cloud/cloud_connector.rb +65 -0
  19. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +114 -0
  20. data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -4
  21. data/config/Gemfile.lock.gh_test +116 -86
  22. data/config/package-lock.json.gh_test +3085 -3943
  23. data/config/routes.rb +23 -8
  24. data/db/migrate/20210214000001_create_rules_and_resolutions.foreman_rh_cloud.rb +24 -0
  25. data/db/migrate/20210214000002_add_rule_id_to_hits.foreman_rh_cloud.rb +5 -0
  26. data/db/migrate/20210307000001_add_unique_to_insights_facet.foreman_rh_cloud.rb +11 -0
  27. data/lib/foreman_inventory_upload.rb +2 -1
  28. data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
  29. data/lib/foreman_inventory_upload/generators/slice.rb +14 -21
  30. data/lib/foreman_inventory_upload/generators/tags.rb +59 -0
  31. data/lib/foreman_rh_cloud.rb +13 -0
  32. data/lib/foreman_rh_cloud/engine.rb +19 -6
  33. data/lib/foreman_rh_cloud/version.rb +1 -1
  34. data/lib/insights_cloud.rb +4 -0
  35. data/lib/insights_cloud/async/insights_full_sync.rb +29 -0
  36. data/lib/insights_cloud/async/insights_rules_sync.rb +80 -0
  37. data/lib/insights_cloud/async/rules_result.rb +13 -0
  38. data/package.json +19 -18
  39. data/test/controllers/accounts_controller_test.rb +1 -5
  40. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +107 -0
  41. data/test/controllers/uploads_controller_test.rb +0 -13
  42. data/test/controllers/uploads_settings_controller_test.rb +31 -0
  43. data/test/factories/insights_factories.rb +2 -1
  44. data/test/factories/inventory_upload_factories.rb +12 -0
  45. data/test/jobs/insights_full_sync_test.rb +17 -0
  46. data/test/jobs/insights_rules_sync_test.rb +198 -0
  47. data/test/test_plugin_helper.rb +13 -0
  48. data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +60 -0
  49. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +141 -0
  50. data/test/unit/slice_generator_test.rb +7 -2
  51. data/test/unit/tags_generator_test.rb +60 -0
  52. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +9 -18
  53. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +10 -9
  54. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +1 -1
  55. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
  56. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +2 -34
  57. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +0 -14
  58. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +6 -4
  59. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +6 -4
  60. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +14 -12
  61. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +10 -1
  62. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +36 -18
  63. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +44 -41
  64. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +6 -7
  65. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +5 -4
  66. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +19 -34
  67. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +2 -2
  68. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +3 -3
  69. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +0 -30
  70. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +1 -23
  71. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +9 -9
  72. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +9 -8
  73. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +9 -35
  74. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -18
  75. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +31 -6
  76. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +1 -1
  77. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +1 -1
  78. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +2 -2
  79. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +6 -6
  80. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +2 -1
  81. data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +4 -2
  82. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +2 -1
  83. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +16 -14
  84. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +2 -1
  85. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +1 -1
  86. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +2 -1
  87. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +6 -11
  88. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +1 -1
  89. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +3 -3
  90. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +5 -0
  91. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingActions.js +7 -0
  92. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingsConstants.js +26 -0
  93. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
  94. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
  95. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/index.js +29 -0
  96. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +9 -10
  97. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.scss +18 -0
  98. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsActions.js +23 -0
  99. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsConstants.js +9 -0
  100. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +19 -0
  101. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
  102. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +17 -5
  103. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
  104. data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +16 -1
  105. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +1 -1
  106. data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -5
  107. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +12 -18
  108. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +31 -0
  109. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +53 -0
  110. data/webpack/ForemanInventoryUpload/Components/PageHeader/{components/DocsButton/__tests__/DocsButton.test.js → __tests__/PageTitle.test.js} +3 -3
  111. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +13 -38
  112. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +43 -0
  113. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +21 -0
  114. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +59 -0
  115. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js +6 -0
  116. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +19 -0
  117. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
  118. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +22 -0
  119. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
  120. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +56 -0
  121. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +21 -0
  122. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js +64 -0
  123. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +18 -0
  124. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +30 -0
  125. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +25 -0
  126. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +9 -11
  127. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +1 -1
  128. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +2 -2
  129. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +2 -2
  130. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +7 -9
  131. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +1 -1
  132. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +1 -1
  133. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +1 -1
  134. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -4
  135. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -2
  136. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +5 -2
  137. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +1 -1
  138. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +1 -1
  139. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +1 -1
  140. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +1 -1
  141. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -1
  142. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +8 -6
  143. data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +9 -7
  144. data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +4 -2
  145. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +7 -5
  146. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +2 -1
  147. data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +15 -13
  148. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +27 -24
  149. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +2 -2
  150. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +8 -14
  151. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +97 -0
  152. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +17 -0
  153. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +106 -0
  154. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +72 -0
  155. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +23 -0
  156. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +24 -0
  157. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +7 -10
  158. data/webpack/ForemanRhCloudFills.js +23 -0
  159. data/webpack/ForemanRhCloudPages.js +25 -1
  160. data/webpack/ForemanRhCloudReducers.js +10 -1
  161. data/webpack/InsightsCloudSync/Components/InsightsHeader/InsightsHeader.scss +4 -0
  162. data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +16 -0
  163. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +1 -1
  164. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +1 -1
  165. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +2 -2
  166. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
  167. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +1 -1
  168. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +125 -0
  169. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +154 -0
  170. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +56 -0
  171. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +39 -0
  172. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableReducer.js +28 -0
  173. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +78 -0
  174. data/webpack/InsightsCloudSync/Components/InsightsTable/SelectAllAlert.js +59 -0
  175. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +13 -0
  176. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js +48 -0
  177. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +58 -0
  178. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +155 -0
  179. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +132 -0
  180. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +89 -0
  181. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +104 -0
  182. data/webpack/InsightsCloudSync/Components/InsightsTable/components/EmptyState.js +53 -0
  183. data/webpack/InsightsCloudSync/Components/InsightsTable/index.js +45 -0
  184. data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +11 -0
  185. data/webpack/InsightsCloudSync/Components/NoTokenEmptyState.js +79 -0
  186. data/webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js +10 -0
  187. data/webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js +19 -0
  188. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +13 -0
  189. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +214 -0
  190. data/webpack/InsightsCloudSync/InsightsCloudSync.js +47 -44
  191. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +11 -3
  192. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +23 -20
  193. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +16 -2
  194. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +7 -0
  195. data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +2 -0
  196. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +44 -61
  197. data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncActions.test.js +9 -0
  198. data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +11 -0
  199. data/webpack/InsightsCloudSync/index.js +11 -3
  200. data/webpack/InsightsHostDetailsTab/InsightsTab.js +7 -8
  201. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +1 -1
  202. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +12 -14
  203. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +2 -2
  204. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +10 -12
  205. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +10 -12
  206. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +10 -12
  207. data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +1 -0
  208. data/webpack/__mocks__/foremanReact/common/MountingService.js +1 -0
  209. data/webpack/__mocks__/foremanReact/constants.js +19 -0
  210. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +24 -0
  211. data/webpack/__mocks__/foremanReact/redux/API/index.js +12 -0
  212. data/webpack/__mocks__/foremanReact/routes/RouterSelector.js +2 -0
  213. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +10 -0
  214. data/webpack/common/Switcher/HelpLabel.js +30 -0
  215. data/webpack/common/Switcher/SwitcherPF4.js +36 -0
  216. data/webpack/common/Switcher/SwitcherPF4.scss +10 -0
  217. data/webpack/common/Switcher/__tests__/HelpLabel.test.js +13 -0
  218. data/webpack/common/Switcher/__tests__/SwitcherPF4.test.js +14 -0
  219. data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +20 -0
  220. data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +22 -0
  221. data/webpack/common/Switcher/index.js +79 -0
  222. data/webpack/global_index.js +7 -0
  223. data/webpack/index.js +4 -14
  224. metadata +168 -75
  225. data/app/controllers/foreman_rh_cloud/react_controller.rb +0 -11
  226. data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +0 -1
  227. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +0 -1
  228. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
  229. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +0 -16
  230. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +0 -3
  231. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +0 -32
  232. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +0 -29
  233. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
  234. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +0 -14
  235. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +0 -24
  236. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +0 -38
  237. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +0 -31
  238. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +0 -3
  239. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/index.js +0 -17
  240. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +0 -1
  241. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +0 -30
  242. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +0 -29
  243. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +0 -1
  244. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +0 -13
  245. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +0 -21
  246. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +0 -38
  247. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +0 -31
  248. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +0 -41
  249. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +0 -36
  250. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +0 -3
  251. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +0 -20
  252. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +0 -2
  253. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +0 -30
  254. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +0 -3
  255. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +0 -29
  256. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -1
  257. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcher.test.js +0 -14
  258. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +0 -24
  259. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +0 -38
  260. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +0 -31
  261. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/index.js +0 -20
  262. data/webpack/ForemanInventoryUpload/Components/InventorySettings/inventorySettings.scss +0 -15
  263. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +0 -1
  264. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +0 -29
  265. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +0 -29
  266. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +0 -1
  267. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +0 -13
  268. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +0 -21
  269. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +0 -38
  270. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +0 -31
  271. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +0 -20
  272. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +0 -18
  273. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +0 -21
  274. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +0 -1
  275. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +0 -19
  276. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +0 -12
  277. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +0 -22
  278. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +0 -1
  279. data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +0 -3
  280. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
  281. data/webpack/__mocks__/foremanReact/API.js +0 -7
  282. data/webpack/subscriptions_extension_index.js +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b34803af6696737993eb885384efd806b443d28668c96734e175f2595ce4829
4
- data.tar.gz: e936612e09f71e9e3b351be01862763a4fae2f7caa29f6161547456416e8675f
3
+ metadata.gz: 50f4cac8e85d4aa6a6f5311e0276277ee3de729dfe29954d2fb8e907c2996e65
4
+ data.tar.gz: 96a40dac10cabdcf362add97a29d841a88a16d96a9cfb2a59c10eab0a64b8b5d
5
5
  SHA512:
6
- metadata.gz: bb8e4f801f862736c5a4a93b3fe4b259067a1f7d44d1c81b5b11432e61b6047614c7ba7ec4e9d97af352fe85ee6a972ce1c7bcc5ac97b8602526750b0ff7018b
7
- data.tar.gz: 59c87465077fbc67aac9e71076cc7f70ede3a577aa3cb37af8e257e78ee12f9955a77f2dfdf4a11fe84c76be073c6f84503e3a2b4178dda1bbe13bad458abf1d
6
+ metadata.gz: 9dee0e2da14903584e433cf39e5f21c0e6e913ee54a6c579d929dee1db8163d60990502d7404285d7df8fed49f2b2910e923d47adc529dbda0c5f9aada23174b
7
+ data.tar.gz: 9c468f95609d7d844ae0b0c1b8bbe697c4b43e55529a6dfc5030b74089b05c2d0fae0843e415cb98bec95dacd45c056d25b2130c8df141238059552303a62573
@@ -0,0 +1,28 @@
1
+ module InsightsCloud
2
+ module CandlepinCache
3
+ extend ActiveSupport::Concern
4
+
5
+ def upstream_owner(org)
6
+ # We use a cache because owner_details is a call to Candlepin
7
+ Rails.cache.fetch("rh_cloud_upstream_owner_#{org.id}", expires_in: 1.minute) do
8
+ org.owner_details['upstreamConsumer']
9
+ end
10
+ end
11
+
12
+ def cp_owner_id(org)
13
+ owner = upstream_owner(org)
14
+ owner['uuid'] if owner
15
+ end
16
+
17
+ def candlepin_id_cert(org)
18
+ owner = upstream_owner(org)
19
+ return unless owner
20
+ id_cert = {
21
+ cert: owner.dig('idCert', 'cert'),
22
+ key: owner.dig('idCert', 'key'),
23
+ }
24
+ return unless id_cert.values.all?
25
+ id_cert
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ module InsightsCloud
2
+ module ClientAuthentication
3
+ extend ActiveSupport::Concern
4
+
5
+ include ::Katello::Authentication::ClientAuthentication
6
+
7
+ def authorize
8
+ client_authorized? || super
9
+ end
10
+
11
+ def client_authorized?
12
+ authenticate_client && valid_machine_user?
13
+ end
14
+
15
+ def valid_machine_user?
16
+ subscribed_host_by_uuid(User.current.uuid).present?
17
+ end
18
+
19
+ def subscribed_host_by_uuid(uuid)
20
+ @host = Host.unscoped.joins(:subscription_facet).where(:katello_subscription_facets => {:uuid => uuid }).first
21
+ end
22
+ end
23
+ end
@@ -10,23 +10,19 @@ 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],
28
- excludePackages: Setting[:exclude_installed_packages],
29
24
  accounts: accounts,
25
+ CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
30
26
  }, status: :ok
31
27
  end
32
28
 
@@ -14,62 +14,12 @@ module ForemanInventoryUpload
14
14
  files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]
15
15
 
16
16
  return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
17
- throw_flash_error "File doesn't exist"
17
+ raise ::Foreman::Exception.new("The report file doesn't exist")
18
18
  end
19
19
 
20
- def throw_flash_error(message)
21
- process_error(
22
- :redirect => foreman_inventory_upload_index_path,
23
- :error_msg => message
24
- )
25
- end
26
-
27
- def auto_upload
28
- Setting[:allow_auto_inventory_upload] = auto_upload_params
29
- render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
30
- end
31
-
32
- def show_auto_upload
33
- render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
34
- end
35
-
36
- def auto_upload_params
37
- ActiveModel::Type::Boolean.new.cast(params.require(:value))
38
- end
39
-
40
- def host_obfuscation
41
- Setting[:obfuscate_inventory_hostnames] = host_obfuscation_params
42
- render_setting(:hostObfuscationEnabled, :obfuscate_inventory_hostnames)
43
- end
44
-
45
- def host_obfuscation_params
46
- ActiveModel::Type::Boolean.new.cast(params.require(:value))
47
- end
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
-
67
- private
68
-
69
- def render_setting(node_name, setting)
70
- render json: {
71
- node_name => Setting[setting],
72
- }
20
+ def enable_cloud_connector
21
+ cloud_connector = ForemanRhCloud::CloudConnector.new
22
+ render json: cloud_connector.install.to_json
73
23
  end
74
24
  end
75
25
  end
@@ -0,0 +1,26 @@
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
+ }, status: :ok
12
+ end
13
+
14
+ def set_advanced_setting
15
+ Setting[params.require(:setting)] = ActiveModel::Type::Boolean.new.cast(params.require(:value))
16
+ index
17
+ end
18
+
19
+ def self.cloud_connector_status
20
+ cloud_connector = ForemanRhCloud::CloudConnector.new
21
+ job = cloud_connector&.latest_job
22
+ return nil unless job
23
+ { id: job.id, task: ForemanTasks::Task.where(:id => job.task_id).first }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,73 @@
1
+ module InsightsCloud::Api
2
+ class MachineTelemetriesController < ::Api::V2::BaseController
3
+ layout false
4
+
5
+ include ::InsightsCloud::ClientAuthentication
6
+ include ::InsightsCloud::CandlepinCache
7
+
8
+ before_action :cert_uuid, :ensure_org, :ensure_branch_id, :only => [:forward_request, :branch_info]
9
+ before_action :ensure_telemetry_enabled_for_consumer, :only => [:forward_request]
10
+
11
+ skip_after_action :log_response_body, :only => [:forward_request]
12
+ skip_before_action :check_media_type, :only => [:forward_request]
13
+
14
+ # The method that "proxies" requests over to Cloud
15
+ def forward_request
16
+ certs = candlepin_id_cert @organization
17
+ cloud_response = ::ForemanRhCloud::CloudRequestForwarder.new.forward_request(request, controller_name, @branch_id, certs)
18
+
19
+ if cloud_response.code == 401
20
+ return render json: {
21
+ :message => 'Authentication to the Insights Service failed.',
22
+ :headers => {},
23
+ }, status: :bad_gateway
24
+ end
25
+
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]
28
+ end
29
+
30
+ assign_header(response, cloud_response, :x_resource_count, true)
31
+ assign_header(response, cloud_response, :x_rh_insights_request_id, false)
32
+
33
+ render json: cloud_response, status: cloud_response.code
34
+ end
35
+
36
+ def branch_info
37
+ render :json => ForemanRhCloud::BranchInfo.new.generate(@uuid, @host, @branch_id, request.host).to_json
38
+ end
39
+
40
+ def assign_header(res, cloud_res, header, transform)
41
+ header_content = cloud_res.headers[header]
42
+ return unless header_content
43
+ new_header = transform ? header.to_s.tr('_', '-') : header.to_s
44
+ res.headers[new_header] = header_content
45
+ end
46
+
47
+ private
48
+
49
+ def ensure_telemetry_enabled_for_consumer
50
+ render_message 'Telemetry is not enabled for your organization', :status => 403 unless telemetry_config
51
+ end
52
+
53
+ def telemetry_config
54
+ ::RedhatAccess::TelemetryConfiguration.find_or_create_by(:organization_id => @organization.id) do |conf|
55
+ conf.enable_telemetry = true
56
+ end
57
+ end
58
+
59
+ def cert_uuid
60
+ @uuid ||= User.current.login
61
+ end
62
+
63
+ def ensure_org
64
+ @organization = @host.organization
65
+ return render_message 'Organization not found or invalid', :status => 400 unless @organization
66
+ end
67
+
68
+ def ensure_branch_id
69
+ @branch_id = cp_owner_id(@organization)
70
+ return render_message "Branch ID not found for organization #{@organization.title}", :status => 400 unless @branch_id
71
+ end
72
+ end
73
+ end
@@ -1,6 +1,18 @@
1
1
  module InsightsCloud
2
2
  class HitsController < ::ApplicationController
3
+ include Foreman::Controller::AutoCompleteSearch
4
+
3
5
  def index
6
+ hits = resource_base_search_and_page.where(host: Host.authorized).preload(:host, :rule)
7
+
8
+ render json: {
9
+ hasToken: !Setting[:rh_cloud_token].empty?,
10
+ hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, has_playbook: hit.has_playbook?) },
11
+ itemCount: hits.count,
12
+ }, status: :ok
13
+ end
14
+
15
+ def show
4
16
  host = Host.where(id: host_id_param).first
5
17
 
6
18
  render json: {
@@ -8,6 +20,18 @@ module InsightsCloud
8
20
  }, status: :ok
9
21
  end
10
22
 
23
+ def model_of_controller
24
+ ::InsightsHit
25
+ end
26
+
27
+ def resource_class
28
+ ::InsightsHit
29
+ end
30
+
31
+ def controller_permission
32
+ :insights_hits
33
+ end
34
+
11
35
  private
12
36
 
13
37
  def host_id_param
@@ -9,6 +9,14 @@ module InsightsCloud
9
9
  render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
10
10
  end
11
11
 
12
+ def save_token_and_sync
13
+ token = Setting::RhCloud.find_by_name("rh_cloud_token")
14
+ token.value = params.require(:value)
15
+ token.save!
16
+ InsightsCloud::Async::InsightsFullSync.perform_now
17
+ redirect_to(:controller => "hits", :action => 'index')
18
+ end
19
+
12
20
  private
13
21
 
14
22
  def render_setting(node_name, setting)
@@ -1,7 +1,12 @@
1
1
  module InsightsCloud
2
2
  class TasksController < ::ApplicationController
3
3
  def create
4
- InsightsCloud::Async::InsightsFullSync.perform_now
4
+ job = InsightsCloud::Async::InsightsFullSync.perform_later
5
+ task = ForemanTasks::Task.find_by(external_id: job.provider_job_id)
6
+
7
+ render json: {
8
+ task: task,
9
+ }, status: :ok
5
10
  end
6
11
  end
7
12
  end
@@ -6,14 +6,7 @@ module ForemanInventoryUploadHostHelper
6
6
  def hits_counts_cell(host)
7
7
  host_hits = hits_counts[host.id]
8
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
9
+ link_to(host_hits, "#{host_path(host)}#insights") if host_hits
17
10
  end
18
11
  end
19
12
  end
@@ -1,6 +1,25 @@
1
1
  class InsightsHit < ApplicationRecord
2
- has_one :host
2
+ include ::Authorizable
3
+ belongs_to :host
3
4
  # since the facet is one-to-one association with a host, we can connect
4
5
  # through host_id column on both this model and facet.
5
6
  belongs_to :insights_facet, foreign_key: 'host_id', primary_key: 'host_id', counter_cache: :hits_count
7
+
8
+ has_one :rule, class_name: 'InsightsRule', foreign_key: 'rule_id', primary_key: 'rule_id'
9
+
10
+ scope :with_playbook, -> { joins(:rule) }
11
+
12
+ scoped_search on: :title, complete_value: true
13
+ scoped_search on: :total_risk, complete_value: true
14
+ scoped_search on: :rule_id, complete_value: true, only_explicit: true
15
+ scoped_search relation: :host, on: :name, rename: :hostname, complete_value: true
16
+ scoped_search on: :rule_id, rename: :with_playbook, only_explicit: true, complete_value: false, ext_method: :find_with_playbook
17
+
18
+ def self.find_with_playbook(key, operator, value)
19
+ { joins: :rule }
20
+ end
21
+
22
+ def has_playbook?
23
+ !rule.nil?
24
+ end
6
25
  end
@@ -0,0 +1,3 @@
1
+ class InsightsResolution < ApplicationRecord
2
+ belongs_to :rule, class_name: 'InsightsRule', foreign_key: 'rule_id', primary_key: 'rule_id', inverse_of: :resolutions
3
+ end
@@ -0,0 +1,3 @@
1
+ class InsightsRule < ApplicationRecord
2
+ has_many :resolutions, class_name: 'InsightsResolution', dependent: :destroy, foreign_key: 'rule_id', primary_key: 'rule_id', inverse_of: :rule
3
+ end
@@ -1,14 +1,26 @@
1
1
  class Setting::RhCloud < Setting
2
+ ::Setting::BLANK_ATTRS.concat %w{rh_cloud_token}
3
+
4
+ def self.load_defaults
5
+ return false unless table_exists?
6
+ transaction do
7
+ # If the user had auto_upload default setting, we will not surprise him, and force the value to false
8
+ # for new users, the default will be set to true and the value will remain nil
9
+ Setting.where(name: 'allow_auto_inventory_upload', value: nil).where("settings.default LIKE '%false%'").update_all(value: "--- false\n...")
10
+ super
11
+ end
12
+ end
13
+
2
14
  def self.default_settings
3
15
  return unless ActiveRecord::Base.connection.table_exists?('settings')
4
- return unless super
5
16
  [
6
- set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false, N_('Allow automatic inventory uploads')),
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')),
7
18
  set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false, N_('Allow recommendations synchronization')),
8
19
  set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false, N_('Obfuscate host names')),
9
20
  set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false, N_('Obfuscate IPs')),
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),
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),
11
22
  set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false, N_("Don't upload installed packages")),
23
+ set('include_parameter_tags', N_('Should import include parameter tags from Foreman?'), false, N_('Include parameters in insights-client reports')),
12
24
  ]
13
25
  end
14
26
 
@@ -0,0 +1,2 @@
1
+ <!-- insert_top 'head' -->
2
+ <%= css_tags_for([:foreman_rh_cloud]).first %>
@@ -0,0 +1,46 @@
1
+ module ForemanRhCloud
2
+ class BranchInfo
3
+ def generate(uuid, host, branch_id, request_hostname)
4
+ {
5
+ :remote_leaf => uuid,
6
+ :remote_branch => branch_id,
7
+ :display_name => host.organization.name,
8
+ :hostname => request_hostname,
9
+ :product => {
10
+ :type => core_app_name,
11
+ :major_version => core_app_version.major,
12
+ :minor_version => core_app_version.minor,
13
+ },
14
+ :organization_id => host.organization.id,
15
+ :satellite_instance_id => Foreman.instance_id,
16
+ :labels => host_labels(host),
17
+ }
18
+ end
19
+
20
+ def core_app_name
21
+ 'Foreman'
22
+ end
23
+
24
+ def core_app_version
25
+ Foreman::Version.new
26
+ end
27
+
28
+ def new_label(key, value, namespace)
29
+ {
30
+ :namespace => namespace,
31
+ :key => key,
32
+ :value => value,
33
+ }
34
+ end
35
+
36
+ def labels_from_items(items, label_namespace, label_lamb, label_value_method = :to_s)
37
+ items.map { |item| new_label(label_lamb.call(item), item.public_send(label_value_method), label_namespace) }
38
+ end
39
+
40
+ def host_labels(host)
41
+ tags_generator = ForemanInventoryUpload::Generators::Tags.new(host)
42
+ tags_generator.generate.map { |key, value| new_label(key, value, ForemanInventoryUpload::Generators::Slice::SATELLITE_NAMESPACE) } +
43
+ tags_generator.generate_parameters.map { |key, value| new_label(key, value, ForemanInventoryUpload::Generators::Slice::SATELLITE_PARAMS_NAMESPACE) }
44
+ end
45
+ end
46
+ end