foreman_rh_cloud 0.9.5 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +4 -6
  3. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +25 -0
  4. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +22 -3
  5. data/app/controllers/foreman_rh_cloud/react_controller.rb +11 -0
  6. data/app/controllers/insights_cloud/settings_controller.rb +24 -0
  7. data/app/controllers/insights_cloud/tasks_controller.rb +7 -0
  8. data/app/helpers/foreman_inventory_upload_host_helper.rb +20 -0
  9. data/app/models/insights_facet.rb +7 -0
  10. data/app/models/insights_hit.rb +6 -0
  11. data/app/models/inventory_sync/inventory_status.rb +30 -0
  12. data/app/models/setting/rh_cloud.rb +4 -1
  13. data/app/overrides/hosts_list.rb +13 -0
  14. data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +6 -0
  15. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -0
  16. data/app/views/{foreman_inventory_upload/layouts/react.html.erb → layouts/foreman_rh_cloud/application.html.erb} +2 -2
  17. data/config/routes.rb +14 -1
  18. data/db/migrate/20191215104806_create_insights_hits.foreman_inventory_upload.rb +14 -0
  19. data/db/migrate/20191216062008_create_insights_facets.foreman_inventory_upload.rb +7 -0
  20. data/db/migrate/20200727111529_add_uuid_column_to_insights_facets.foreman_rh_cloud.rb +5 -0
  21. data/lib/foreman_inventory_upload.rb +4 -0
  22. data/lib/foreman_inventory_upload/async/async_helpers.rb +13 -0
  23. data/lib/foreman_inventory_upload/async/shell_process.rb +3 -1
  24. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +56 -0
  25. data/lib/foreman_inventory_upload/generators/json_stream.rb +10 -0
  26. data/lib/foreman_inventory_upload/generators/queries.rb +6 -0
  27. data/lib/foreman_inventory_upload/generators/slice.rb +54 -22
  28. data/lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb +19 -0
  29. data/lib/foreman_rh_cloud.rb +13 -0
  30. data/lib/foreman_rh_cloud/engine.rb +32 -5
  31. data/lib/foreman_rh_cloud/version.rb +1 -1
  32. data/lib/insights_cloud.rb +15 -0
  33. data/lib/insights_cloud/async/insights_full_sync.rb +103 -0
  34. data/lib/insights_cloud/async/insights_scheduled_sync.rb +23 -0
  35. data/lib/inventory_sync/async/host_result.rb +50 -0
  36. data/lib/inventory_sync/async/inventory_full_sync.rb +99 -0
  37. data/test/controllers/insights_sync/settings_controller_test.rb +30 -0
  38. data/test/factories/insights_factories.rb +31 -0
  39. data/test/jobs/insights_full_sync_test.rb +94 -0
  40. data/test/jobs/inventory_full_sync_test.rb +91 -0
  41. data/test/unit/archived_report_generator_test.rb +1 -0
  42. data/test/unit/fact_helpers_test.rb +29 -0
  43. data/test/unit/insights_facet_test.rb +16 -0
  44. data/test/unit/slice_generator_test.rb +252 -25
  45. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +14 -2
  46. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +13 -10
  47. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +6 -3
  48. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +10 -0
  49. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +11 -1
  50. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +10 -1
  51. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js +15 -0
  52. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +13 -0
  53. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
  54. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +7 -0
  55. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js +1 -0
  56. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +1 -4
  57. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +1 -0
  58. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +8 -1
  59. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +12 -0
  60. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +1 -1
  61. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +13 -0
  62. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +12 -8
  63. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +2 -3
  64. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +21 -2
  65. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +11 -0
  66. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +3 -0
  67. data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +2 -0
  68. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +6 -6
  69. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +4 -1
  70. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +9 -9
  71. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +1 -1
  72. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +4 -3
  73. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +1 -1
  74. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +2 -3
  75. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +1 -1
  76. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +3 -2
  77. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +5 -1
  78. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -0
  79. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +15 -13
  80. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +1 -0
  81. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +29 -0
  82. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +30 -0
  83. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +3 -0
  84. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcher.test.js +14 -0
  85. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +14 -0
  86. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +38 -0
  87. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +14 -0
  88. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/hostObfuscationSwitcher.scss +0 -0
  89. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/index.js +20 -0
  90. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +26 -0
  91. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js +1 -0
  92. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +2 -0
  93. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +39 -0
  94. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js +16 -0
  95. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +3 -0
  96. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +36 -0
  97. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js +7 -0
  98. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +14 -0
  99. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
  100. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +35 -0
  101. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
  102. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +25 -0
  103. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
  104. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +25 -0
  105. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
  106. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +37 -0
  107. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +18 -0
  108. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +17 -0
  109. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +28 -0
  110. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +15 -0
  111. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettings.test.js +13 -0
  112. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +13 -0
  113. data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +1 -0
  114. data/webpack/ForemanInventoryUpload/Components/InventorySettings/inventorySettings.scss +15 -0
  115. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +25 -6
  116. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +33 -5
  117. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +18 -0
  118. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/DocsButton.test.js +13 -0
  119. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +21 -0
  120. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +1 -0
  121. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +19 -0
  122. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +14 -0
  123. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +22 -0
  124. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +1 -0
  125. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +24 -0
  126. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js +11 -0
  127. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +17 -0
  128. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/index.js +1 -0
  129. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +52 -0
  130. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +59 -0
  131. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +3 -0
  132. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +36 -0
  133. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +13 -0
  134. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +13 -0
  135. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +13 -0
  136. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +9 -0
  137. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +33 -0
  138. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +36 -0
  139. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +26 -0
  140. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +36 -0
  141. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +25 -0
  142. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +18 -0
  143. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +63 -0
  144. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +41 -0
  145. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +20 -0
  146. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +22 -0
  147. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +15 -0
  148. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +12 -0
  149. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +11 -0
  150. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/index.js +1 -0
  151. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +12 -0
  152. data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +3 -0
  153. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +9 -0
  154. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +12 -0
  155. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +16 -8
  156. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +6 -4
  157. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +34 -0
  158. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +12 -0
  159. data/webpack/ForemanInventoryUpload/{ForemanInventoryUpload.test.js → __tests__/ForemanInventoryUpload.test.js} +1 -1
  160. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +5 -0
  161. data/webpack/ForemanInventoryUpload/{__snapshots__ → __tests__/__snapshots__}/ForemanInventoryUpload.test.js.snap +0 -0
  162. data/webpack/ForemanRhCloudHelpers.js +6 -0
  163. data/webpack/ForemanRhCloudPages.js +7 -0
  164. data/webpack/ForemanRhCloudReducers.js +10 -0
  165. data/webpack/ForemanRhCloudSelectors.js +5 -0
  166. data/webpack/ForemanRhCloudTestHelpers.js +15 -0
  167. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +33 -0
  168. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +60 -0
  169. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +10 -0
  170. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +28 -0
  171. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsSelectors.js +6 -0
  172. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +18 -0
  173. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +46 -0
  174. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +56 -0
  175. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +21 -0
  176. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +15 -0
  177. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +31 -0
  178. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +33 -0
  179. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +9 -0
  180. data/webpack/InsightsCloudSync/Components/InsightsSettings/index.js +21 -0
  181. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +16 -0
  182. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +1 -0
  183. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +45 -0
  184. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +17 -0
  185. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +38 -0
  186. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +1 -0
  187. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +3 -0
  188. data/webpack/InsightsCloudSync/InsightsCloudSync.js +59 -0
  189. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +16 -0
  190. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +23 -0
  191. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +6 -0
  192. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +3 -0
  193. data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +8 -0
  194. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +65 -0
  195. data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncHelpers.test.js +11 -0
  196. data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncHelpers.test.js.snap +3 -0
  197. data/webpack/InsightsCloudSync/index.js +18 -0
  198. data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +1 -0
  199. data/webpack/__mocks__/foremanReact/constants.js +5 -0
  200. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
  201. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +11 -0
  202. data/webpack/__tests__/ForemanRhCloudSelectors.test.js +22 -0
  203. data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +20 -0
  204. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +3 -0
  205. data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +24 -0
  206. data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +36 -0
  207. data/webpack/index.js +3 -6
  208. data/webpack/subscriptions_extension_index.js +8 -0
  209. metadata +166 -7
  210. data/app/controllers/foreman_inventory_upload/react_controller.rb +0 -7
  211. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d3adffa464bc496cf7b3d80bf897e5f9720f343316af3a32e61b99f55f41655
4
- data.tar.gz: fabb5e4334b5c9d9f6c17d5c44cc70a27afb165fc5e2684f0609a280b40a61db
3
+ metadata.gz: be1ed5e65ca0dd0c2515ab70dcffa4ba5bb480a822b822d122ab6b126a5ec242
4
+ data.tar.gz: 9e7f83b694de9ffe66da0f86c781f869161c93aa92c426a16bb319601bc407f0
5
5
  SHA512:
6
- metadata.gz: 9eb34258b36236a537dfea9d5160f553cef3ffc4d39b2f95007cf4fab3d3d9aaaef29671cb056fcb73ade319ba847db47b9719c7fd5124f456a8d7ccca976481
7
- data.tar.gz: 8bb6f9bf92278d2ab534681fb6950c3169f1da6a5f543dcaa56946745ca6d626d3edd37c21d7d1d3ede5a30de5cc1790449c92e13f2859e99c756cadb9546e8d
6
+ metadata.gz: 33c3a9d35df67a9c7217d385ccb035673795ac0200c3aac6bc7695e28fd6360a737832ac929d010c866af71ab8e2a54ce11947c2aacd3135a1959326e1469ba2
7
+ data.tar.gz: e41fd42b654ba57a64fac11e6b77ab5caa55a511a3dfc5371ef329904f7c9989562aedb7d3f52044d28f744691f5795e4b45addbeba4015ae4094fb28942a0cc
@@ -1,12 +1,8 @@
1
1
  module ForemanInventoryUpload
2
2
  class AccountsController < ::ApplicationController
3
- # override default "welcome screen behavior, since we don't have a model"
4
- def welcome
5
- true
6
- end
7
-
8
3
  def index
9
- labels = Organization.all.pluck(:id, :name)
4
+ organizations = User.current.my_organizations
5
+ labels = organizations.pluck(:id, :name)
10
6
 
11
7
  accounts = Hash[
12
8
  labels.map do |id, label|
@@ -26,6 +22,8 @@ module ForemanInventoryUpload
26
22
 
27
23
  render json: {
28
24
  autoUploadEnabled: Setting[:allow_auto_inventory_upload],
25
+ hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
26
+ cloudToken: Setting[:rh_cloud_token],
29
27
  accounts: accounts,
30
28
  }, status: :ok
31
29
  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
@@ -26,13 +26,32 @@ module ForemanInventoryUpload
26
26
 
27
27
  def auto_upload
28
28
  Setting[:allow_auto_inventory_upload] = auto_upload_params
29
- render json: {
30
- autoUploadEnabled: Setting[:allow_auto_inventory_upload],
31
- }
29
+ render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
30
+ end
31
+
32
+ def show_auto_upload
33
+ render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
32
34
  end
33
35
 
34
36
  def auto_upload_params
35
37
  ActiveModel::Type::Boolean.new.cast(params.require(:value))
36
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
+ private
50
+
51
+ def render_setting(node_name, setting)
52
+ render json: {
53
+ node_name => Setting[setting],
54
+ }
55
+ end
37
56
  end
38
57
  end
@@ -0,0 +1,11 @@
1
+ module ForemanRhCloud
2
+ class ReactController < ::ApplicationController
3
+ layout "foreman_rh_cloud/application"
4
+
5
+ def inventory_upload
6
+ end
7
+
8
+ def insights_cloud
9
+ end
10
+ end
11
+ 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
@@ -0,0 +1,7 @@
1
+ module InsightsCloud
2
+ class TasksController < ::ApplicationController
3
+ def create
4
+ InsightsCloud::Async::InsightsFullSync.perform_now
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ module ForemanInventoryUploadHostHelper
2
+ def hits_counts
3
+ @hits_counts ||= InsightsHit.where(host_id: @hosts).group(:host_id).count
4
+ end
5
+
6
+ def hits_counts_cell(host)
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 class: ['hidden-xs', 'ellipsis'] do
10
+ if host_hits
11
+ link_to(
12
+ content,
13
+ InsightsCloud::WebUi.system_url(InsightsCloud::WebUi::ADVISOR, host.insights.uuid),
14
+ :rel => 'external noopener noreferrer',
15
+ :target => '_blank'
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ class InsightsFacet < HostFacets::Base
2
+ has_many :hits,
3
+ foreign_key: :host_id,
4
+ primary_key: :host_id,
5
+ class_name: 'InsightsHit',
6
+ dependent: :destroy
7
+ end
@@ -0,0 +1,6 @@
1
+ class InsightsHit < ApplicationRecord
2
+ has_one :host
3
+ # since the facet is one-to-one association with a host, we can connect
4
+ # through host_id column on both this model and facet.
5
+ has_one :insights_facet, foreign_key: 'host_id', primary_key: 'host_id'
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
@@ -5,7 +5,10 @@ class Setting::RhCloud < Setting
5
5
 
6
6
  transaction do
7
7
  [
8
- set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), true),
8
+ set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false),
9
+ set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false),
10
+ set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false),
11
+ 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),
9
12
  ].each { |s| create! s.update(:category => 'Setting::RhCloud')}
10
13
  end
11
14
 
@@ -0,0 +1,13 @@
1
+ Deface::Override.new(
2
+ virtual_path: 'hosts/_list',
3
+ name: 'insights_hits_header',
4
+ insert_before: 'thead tr th.hidden-xs:first-of-type',
5
+ text: '<th class="hidden-xs" width="10%"><%= _("Insights")%></th>'
6
+ )
7
+
8
+ Deface::Override.new(
9
+ virtual_path: 'hosts/_list',
10
+ name: 'insights_hits_cells',
11
+ insert_before: 'tbody tr td.hidden-xs:first-of-type',
12
+ text: '<%= hits_counts_cell(host) %>'
13
+ )
@@ -0,0 +1,6 @@
1
+ <%= mount_react_component(
2
+ 'InsightsCloudSync',
3
+ '#ForemanRhCloudReactRoot',
4
+ {
5
+ settingsUrl: settings_url(search: 'name = rh_cloud_token')
6
+ }.to_json) %>
@@ -0,0 +1 @@
1
+ <%= mount_react_component('ForemanInventoryUpload', '#ForemanRhCloudReactRoot') %>
@@ -10,7 +10,7 @@
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="ForemanInventoryUploadReactRoot"></div>
13
+ <div id="ForemanRhCloudReactRoot"></div>
14
+ <%= yield %>
14
15
  <% end %>
15
16
  <%= render file: "layouts/base" %>
16
- <%= mount_react_component('ForemanInventoryUpload', '#ForemanInventoryUploadReactRoot') %>
@@ -1,11 +1,24 @@
1
1
  Rails.application.routes.draw do
2
2
  namespace :foreman_inventory_upload do
3
- get 'index', to: 'react#index'
4
3
  get ':organization_id/reports/last', to: 'reports#last', constraints: { organization_id: %r{[^\/]+} }
5
4
  post ':organization_id/reports', to: 'reports#generate', constraints: { organization_id: %r{[^\/]+} }
6
5
  get ':organization_id/uploads/last', to: 'uploads#last', constraints: { organization_id: %r{[^\/]+} }
7
6
  get ':organization_id/uploads/file', to: 'uploads#download_file', constraints: { organization_id: %r{[^\/]+} }
8
7
  get 'accounts', to: 'accounts#index'
8
+ get 'auto_upload', to: 'uploads#show_auto_upload'
9
9
  post 'auto_upload', to: 'uploads#auto_upload'
10
+ post 'host_obfuscation', to: 'uploads#host_obfuscation'
11
+
12
+ resources :tasks, only: [:create]
13
+ end
14
+
15
+ namespace :insights_cloud do
16
+ resources :tasks, only: [:create]
17
+ resource :settings, only: [:show, :update]
18
+ end
19
+
20
+ namespace :foreman_rh_cloud do
21
+ get 'inventory_upload', to: 'react#inventory_upload'
22
+ get 'insights_cloud', to: 'react#insights_cloud'
10
23
  end
11
24
  end
@@ -0,0 +1,14 @@
1
+ class CreateInsightsHits < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :insights_hits do |t|
4
+ t.references :host, foreign_key: true, null: false
5
+ t.datetime :last_seen
6
+ t.string :title
7
+ t.string :solution_url
8
+ t.integer :total_risk
9
+ t.integer :likelihood
10
+ t.datetime :publish_date
11
+ t.string :results_url
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ class CreateInsightsFacets < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :insights_facets do |t|
4
+ t.references :host, foreign_key: true, null: false
5
+ end
6
+ end
7
+ end
@@ -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
@@ -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
@@ -0,0 +1,13 @@
1
+ module ForemanInventoryUpload
2
+ module Async
3
+ module AsyncHelpers
4
+ extend ActiveSupport::Concern
5
+
6
+ def hash_to_s(hash)
7
+ hash.each_with_object({}) do |(k, v), a|
8
+ a[k.to_s] = v.to_s
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,11 +3,13 @@ require 'open3'
3
3
  module ForemanInventoryUpload
4
4
  module Async
5
5
  class ShellProcess < ::ApplicationJob
6
+ include AsyncHelpers
7
+
6
8
  def perform(instance_label)
7
9
  klass_name = self.class.name
8
10
  logger.debug("Starting #{klass_name} with label #{instance_label}")
9
11
  progress_output = ProgressOutput.register(instance_label)
10
- Open3.popen2e(env, command) do |_stdin, stdout_stderr, wait_thread|
12
+ Open3.popen2e(hash_to_s(env), command) do |_stdin, stdout_stderr, wait_thread|
11
13
  progress_output.status = "Running in pid #{wait_thread.pid}"
12
14
 
13
15
  stdout_stderr.each do |out_line|
@@ -3,6 +3,11 @@ module ForemanInventoryUpload
3
3
  module FactHelpers
4
4
  extend ActiveSupport::Concern
5
5
 
6
+ CLOUD_AMAZON = 'aws'
7
+ CLOUD_GOOGLE = 'google'
8
+ CLOUD_AZURE = 'azure'
9
+ CLOUD_ALIBABA = 'alibaba'
10
+
6
11
  def fact_value(host, fact_name)
7
12
  value_record = host.fact_values.find do |fact_value|
8
13
  fact_value.fact_name_id == ForemanInventoryUpload::Generators::Queries.fact_names[fact_name]
@@ -13,6 +18,57 @@ module ForemanInventoryUpload
13
18
  def kilobytes_to_bytes(kilobytes)
14
19
  kilobytes * 1024
15
20
  end
21
+
22
+ def account_id(organization)
23
+ @organization_accounts ||= {}
24
+ @organization_accounts[organization.id] ||= organization.pools.where.not(account_number: nil).pluck(:account_number).first
25
+ end
26
+
27
+ def golden_ticket?(organization)
28
+ result = organization.try(:golden_ticket?)
29
+ result = organization.content_access_mode == 'org_environment' if result.nil?
30
+
31
+ @organization_golden_tickets ||= {}
32
+ @organization_golden_tickets[organization.id] ||= result
33
+ end
34
+
35
+ def cloud_provider(host)
36
+ bios_version = fact_value(host, 'dmi::bios::version')
37
+
38
+ if bios_version
39
+ return CLOUD_AMAZON if bios_version.downcase['amazon']
40
+ return CLOUD_GOOGLE if bios_version.downcase['google']
41
+ end
42
+
43
+ chassis_asset_tag = fact_value(host, 'dmi::chassis::asset_tag')
44
+ return CLOUD_AZURE if chassis_asset_tag && chassis_asset_tag['7783-7084-3265-9085-8269-3286-77']
45
+
46
+ system_manufacturer = fact_value(host, 'dmi::system::manufacturer')
47
+ return CLOUD_ALIBABA if system_manufacturer && system_manufacturer.downcase['alibaba cloud']
48
+
49
+ product_name = fact_value(host, 'dmi::system::product_name')
50
+ return CLOUD_ALIBABA if product_name && product_name.downcase['alibaba cloud ecs']
51
+
52
+ nil
53
+ end
54
+
55
+ def obfuscate_hostname?(host)
56
+ insights_client_setting = fact_value(host, 'insights_client::obfuscate_hostname_enabled')
57
+ insights_client_setting = ActiveModel::Type::Boolean.new.cast(insights_client_setting)
58
+ return insights_client_setting unless insights_client_setting.nil?
59
+
60
+ Setting[:obfuscate_inventory_hostnames]
61
+ end
62
+
63
+ def fqdn(host)
64
+ return host.fqdn unless obfuscate_hostname?(host)
65
+
66
+ fact_value(host, 'insights_client::hostname') || obfuscate_fqdn(host.fqdn)
67
+ end
68
+
69
+ def obfuscate_fqdn(fqdn)
70
+ "#{Digest::SHA1.hexdigest(fqdn)}.example.com"
71
+ end
16
72
  end
17
73
  end
18
74
  end
@@ -36,6 +36,16 @@ module ForemanInventoryUpload
36
36
  @out << ',' unless last
37
37
  end
38
38
 
39
+ def string_array_value(name, value, last = false)
40
+ return if value.empty?
41
+
42
+ string_value = value.map { |v| stringify_value(v) }
43
+
44
+ array_field(name, last) do
45
+ raw(string_value.join(', '))
46
+ end
47
+ end
48
+
39
49
  def object_field(name, last = false, &block)
40
50
  @out << "\"#{name}\": "
41
51
  object(&block)