foreman_rh_cloud 0.9.14 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -33
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +6 -7
  4. data/app/controllers/foreman_inventory_upload/react_controller.rb +7 -0
  5. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +7 -51
  6. data/app/views/{layouts/foreman_rh_cloud/application.html.erb → foreman_inventory_upload/layouts/react.html.erb} +2 -2
  7. data/config/routes.rb +1 -18
  8. data/lib/foreman_inventory_upload.rb +0 -16
  9. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +0 -8
  10. data/lib/foreman_inventory_upload/async/generate_report_job.rb +1 -1
  11. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +10 -5
  12. data/lib/foreman_inventory_upload/async/shell_process.rb +9 -17
  13. data/lib/foreman_inventory_upload/async/upload_report_job.rb +9 -21
  14. data/lib/foreman_inventory_upload/generators/archived_report.rb +3 -6
  15. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +0 -91
  16. data/lib/foreman_inventory_upload/generators/json_stream.rb +2 -17
  17. data/lib/foreman_inventory_upload/generators/metadata.rb +0 -3
  18. data/lib/foreman_inventory_upload/generators/queries.rb +4 -11
  19. data/lib/foreman_inventory_upload/generators/slice.rb +38 -88
  20. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +1 -0
  21. data/lib/foreman_rh_cloud.rb +0 -67
  22. data/lib/foreman_rh_cloud/engine.rb +6 -48
  23. data/lib/foreman_rh_cloud/version.rb +1 -1
  24. data/lib/tasks/generator.rake +29 -0
  25. data/package.json +1 -3
  26. data/test/controllers/accounts_controller_test.rb +3 -8
  27. data/test/controllers/uploads_controller_test.rb +0 -13
  28. data/test/unit/archived_report_generator_test.rb +0 -1
  29. data/test/unit/metadata_generator_test.rb +0 -2
  30. data/test/unit/slice_generator_test.rb +19 -454
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +2 -29
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +10 -13
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +15 -23
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -10
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -34
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +1 -18
  37. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +4 -1
  38. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +0 -1
  39. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +1 -15
  40. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +1 -1
  41. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +4 -32
  42. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +8 -29
  43. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +3 -2
  44. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +2 -40
  45. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +0 -32
  46. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +2 -14
  47. data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +0 -2
  48. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +3 -4
  49. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +1 -1
  50. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +3 -2
  51. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +1 -2
  52. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +2 -3
  53. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +1 -5
  54. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +0 -1
  55. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +13 -15
  56. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +0 -1
  57. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +2 -4
  58. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +1 -0
  59. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +2 -0
  60. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -12
  61. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +1 -1
  62. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +1 -1
  63. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +1 -1
  64. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +1 -1
  65. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +1 -6
  66. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +4 -2
  67. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +9 -18
  68. data/webpack/ForemanInventoryUpload/{__tests__/ForemanInventoryUpload.test.js → ForemanInventoryUpload.test.js} +1 -1
  69. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +4 -6
  70. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +4 -0
  71. data/webpack/ForemanInventoryUpload/{__tests__/__snapshots__ → __snapshots__}/ForemanInventoryUpload.test.js.snap +5 -6
  72. data/webpack/index.js +6 -3
  73. data/webpack/stories/decorators/withCardsDecorator.js +1 -1
  74. metadata +48 -245
  75. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +0 -25
  76. data/app/controllers/foreman_rh_cloud/react_controller.rb +0 -11
  77. data/app/controllers/insights_cloud/hits_controller.rb +0 -17
  78. data/app/controllers/insights_cloud/settings_controller.rb +0 -24
  79. data/app/controllers/insights_cloud/tasks_controller.rb +0 -7
  80. data/app/helpers/foreman_inventory_upload_host_helper.rb +0 -19
  81. data/app/models/concerns/rh_cloud_host.rb +0 -15
  82. data/app/models/insights_facet.rb +0 -7
  83. data/app/models/insights_hit.rb +0 -6
  84. data/app/models/inventory_sync/inventory_status.rb +0 -30
  85. data/app/models/setting/rh_cloud.rb +0 -23
  86. data/app/overrides/hosts_list.rb +0 -13
  87. data/app/services/foreman_rh_cloud/cloud_auth.rb +0 -28
  88. data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +0 -6
  89. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +0 -1
  90. data/app/views/hosts/_insights_tab.html.erb +0 -15
  91. data/db/migrate/20191215104806_create_insights_hits.foreman_inventory_upload.rb +0 -14
  92. data/db/migrate/20191216062008_create_insights_facets.foreman_inventory_upload.rb +0 -7
  93. data/db/migrate/20200727111529_add_uuid_column_to_insights_facets.foreman_rh_cloud.rb +0 -5
  94. data/db/migrate/20201007115752_add_hits_count_to_insights_facets_table.foreman_rh_cloud.rb +0 -5
  95. data/db/migrate/20201007121540_setup_hits_count_cache.foreman_rh_cloud.rb +0 -10
  96. data/lib/foreman_inventory_upload/async/async_helpers.rb +0 -13
  97. data/lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb +0 -19
  98. data/lib/insights_cloud.rb +0 -15
  99. data/lib/insights_cloud/async/insights_full_sync.rb +0 -84
  100. data/lib/insights_cloud/async/insights_scheduled_sync.rb +0 -23
  101. data/lib/inventory_sync/async/host_result.rb +0 -50
  102. data/lib/inventory_sync/async/inventory_full_sync.rb +0 -80
  103. data/lib/tasks/insights.rake +0 -15
  104. data/lib/tasks/rh_cloud_inventory.rake +0 -37
  105. data/test/controllers/insights_sync/settings_controller_test.rb +0 -30
  106. data/test/factories/insights_factories.rb +0 -31
  107. data/test/jobs/insights_full_sync_test.rb +0 -94
  108. data/test/jobs/inventory_full_sync_test.rb +0 -91
  109. data/test/jobs/upload_report_job_test.rb +0 -34
  110. data/test/unit/fact_helpers_test.rb +0 -51
  111. data/test/unit/insights_facet_test.rb +0 -23
  112. data/test/unit/rh_cloud_http_proxy_test.rb +0 -52
  113. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js +0 -15
  114. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +0 -13
  115. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +0 -18
  116. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +0 -7
  117. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js +0 -1
  118. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +0 -12
  119. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +0 -3
  120. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +0 -32
  121. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +0 -29
  122. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
  123. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +0 -14
  124. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +0 -24
  125. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +0 -38
  126. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +0 -31
  127. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +0 -3
  128. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/index.js +0 -17
  129. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +0 -1
  130. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +0 -30
  131. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +0 -29
  132. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +0 -1
  133. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +0 -13
  134. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +0 -21
  135. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +0 -38
  136. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +0 -31
  137. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +0 -41
  138. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +0 -38
  139. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +0 -3
  140. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +0 -20
  141. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +0 -2
  142. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +0 -30
  143. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +0 -3
  144. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +0 -29
  145. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -1
  146. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcher.test.js +0 -14
  147. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +0 -24
  148. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +0 -38
  149. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +0 -31
  150. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/index.js +0 -20
  151. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +0 -26
  152. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js +0 -1
  153. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +0 -2
  154. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +0 -39
  155. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js +0 -16
  156. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +0 -3
  157. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +0 -36
  158. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js +0 -7
  159. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +0 -14
  160. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +0 -14
  161. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +0 -35
  162. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +0 -21
  163. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +0 -25
  164. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +0 -17
  165. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +0 -25
  166. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +0 -9
  167. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +0 -40
  168. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +0 -18
  169. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +0 -17
  170. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +0 -28
  171. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +0 -19
  172. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettings.test.js +0 -13
  173. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +0 -15
  174. data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +0 -1
  175. data/webpack/ForemanInventoryUpload/Components/InventorySettings/inventorySettings.scss +0 -15
  176. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +0 -1
  177. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +0 -29
  178. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +0 -29
  179. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +0 -1
  180. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +0 -13
  181. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +0 -21
  182. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +0 -38
  183. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +0 -31
  184. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +0 -20
  185. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +0 -40
  186. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +0 -13
  187. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +0 -61
  188. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +0 -18
  189. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/DocsButton.test.js +0 -13
  190. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +0 -21
  191. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +0 -1
  192. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +0 -19
  193. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +0 -14
  194. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +0 -22
  195. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +0 -1
  196. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +0 -24
  197. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js +0 -11
  198. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +0 -17
  199. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/index.js +0 -1
  200. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +0 -58
  201. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +0 -57
  202. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +0 -3
  203. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +0 -36
  204. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +0 -13
  205. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +0 -13
  206. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +0 -31
  207. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +0 -9
  208. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +0 -26
  209. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +0 -36
  210. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +0 -26
  211. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +0 -98
  212. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -18
  213. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +0 -18
  214. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +0 -63
  215. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +0 -41
  216. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +0 -20
  217. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +0 -22
  218. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +0 -15
  219. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +0 -12
  220. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +0 -11
  221. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/index.js +0 -1
  222. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +0 -12
  223. data/webpack/ForemanInventoryUpload/Components/PageHeader/index.js +0 -1
  224. data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +0 -3
  225. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +0 -9
  226. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +0 -20
  227. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
  228. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +0 -12
  229. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +0 -5
  230. data/webpack/ForemanRhCloudHelpers.js +0 -6
  231. data/webpack/ForemanRhCloudPages.js +0 -9
  232. data/webpack/ForemanRhCloudReducers.js +0 -12
  233. data/webpack/ForemanRhCloudSelectors.js +0 -10
  234. data/webpack/ForemanRhCloudTestHelpers.js +0 -20
  235. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +0 -33
  236. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +0 -57
  237. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +0 -4
  238. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +0 -24
  239. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsSelectors.js +0 -6
  240. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +0 -18
  241. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +0 -62
  242. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +0 -33
  243. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +0 -21
  244. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +0 -15
  245. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +0 -65
  246. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +0 -19
  247. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +0 -9
  248. data/webpack/InsightsCloudSync/Components/InsightsSettings/index.js +0 -21
  249. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +0 -16
  250. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +0 -1
  251. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +0 -45
  252. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +0 -17
  253. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +0 -38
  254. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +0 -1
  255. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +0 -3
  256. data/webpack/InsightsCloudSync/InsightsCloudSync.js +0 -59
  257. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -16
  258. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +0 -22
  259. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -4
  260. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +0 -3
  261. data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +0 -8
  262. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +0 -65
  263. data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncHelpers.test.js +0 -11
  264. data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncHelpers.test.js.snap +0 -3
  265. data/webpack/InsightsCloudSync/index.js +0 -18
  266. data/webpack/InsightsHostDetailsTab/InsightsTab.js +0 -64
  267. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -86
  268. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +0 -31
  269. data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +0 -2
  270. data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +0 -19
  271. data/webpack/InsightsHostDetailsTab/InsightsTabSelectors.js +0 -3
  272. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +0 -25
  273. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.test.js +0 -13
  274. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +0 -19
  275. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabIntegration.test.js +0 -17
  276. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +0 -26
  277. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js +0 -13
  278. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +0 -30
  279. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +0 -58
  280. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +0 -34
  281. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +0 -20
  282. data/webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js +0 -69
  283. data/webpack/InsightsHostDetailsTab/components/ListItem/index.js +0 -1
  284. data/webpack/InsightsHostDetailsTab/index.js +0 -20
  285. data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +0 -1
  286. data/webpack/__mocks__/foremanReact/constants.js +0 -5
  287. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +0 -8
  288. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +0 -11
  289. data/webpack/__tests__/ForemanRhCloudSelectors.test.js +0 -22
  290. data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +0 -20
  291. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -3
  292. data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +0 -25
  293. data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +0 -39
  294. data/webpack/subscriptions_extension_index.js +0 -8
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '0.9.14'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
@@ -0,0 +1,29 @@
1
+ require 'tempfile'
2
+
3
+ namespace :foreman_inventory_upload do
4
+ namespace :report do
5
+ desc 'Generate inventory report to be sent to Red Hat cloud'
6
+ task generate: :environment do
7
+ portal_user = ENV['portal_user']
8
+ organizations = [ENV['organization_id']]
9
+ base_folder = ENV['target'] || Dir.pwd
10
+
11
+ unless portal_user || organizations.empty?
12
+ puts "Must specify either portal_user or organization_id"
13
+ end
14
+
15
+ if portal_user
16
+ puts "Generating report for all organizations associated with #{portal_user}"
17
+ base_folder = File.join(base_folder, portal_user)
18
+ organizations = ForemanInventoryUpload::Generators::Queries.organizations_for_user(portal_user).pluck(:id)
19
+ end
20
+
21
+ organizations.each do |organization|
22
+ target = File.join(base_folder, ForemanInventoryUpload.facts_archive_name(organization))
23
+ archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
24
+ archived_report_generator.render(organization: organization)
25
+ puts "Successfully generated #{target} for organization id #{organization}"
26
+ end
27
+ end
28
+ end
29
+ end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "0.9.14",
3
+ "version": "0.0.1",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -47,8 +47,6 @@
47
47
  "eslint": "^4.10.0",
48
48
  "eslint-import-resolver-babel-module": "^4.0.0",
49
49
  "eslint-plugin-patternfly-react": "0.2.0",
50
- "eslint-plugin-promise": "^4.2.1",
51
- "eslint-plugin-spellcheck": "^0.0.17",
52
50
  "identity-obj-proxy": "^3.0.0",
53
51
  "jed": "^1.1.1",
54
52
  "jest-cli": "^23.6.0",
@@ -14,17 +14,12 @@ class AccountsControllerTest < ActionController::TestCase
14
14
  upload_label = ForemanInventoryUpload::Async::UploadReportJob.output_label(test_org.id)
15
15
  upload_output = ForemanInventoryUpload::Async::ProgressOutput.register(upload_label)
16
16
  upload_output.status = 'upload_status_test'
17
- FactoryBot.create(:setting, :name => 'allow_auto_inventory_upload', :value => true)
18
- assert_equal true, Setting[:allow_auto_inventory_upload]
19
17
 
20
18
  get :index, session: set_session_user
21
19
 
22
20
  assert_response :success
23
- actual = JSON.parse(response.body)
24
- actual_account_statuses = actual['accounts'][test_org.id.to_s]
25
- assert_equal 'generate_status_test', actual_account_statuses['generate_report_status']
26
- assert_equal 'upload_status_test', actual_account_statuses['upload_report_status']
27
-
28
- assert_equal true, actual['autoUploadEnabled']
21
+ actual = JSON.parse(response.body)['accounts'][test_org.id.to_s]
22
+ assert_equal 'generate_status_test', actual['generate_report_status']
23
+ assert_equal 'upload_status_test', actual['upload_report_status']
29
24
  end
30
25
  end
@@ -18,17 +18,4 @@ class UploadsControllerTest < ActionController::TestCase
18
18
  actual = JSON.parse(response.body)
19
19
  assert_equal 'test output', actual['output']
20
20
  end
21
-
22
- test 'should update allow_auto_inventory_upload setting' do
23
- FactoryBot.create(:setting, :name => 'allow_auto_inventory_upload', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
24
-
25
- assert_equal false, Setting[:allow_auto_inventory_upload]
26
-
27
- post :auto_upload, params: { value: true }, session: set_session_user
28
-
29
- assert_response :success
30
- actual = JSON.parse(response.body)
31
- assert_equal true, actual['autoUploadEnabled']
32
- assert_equal true, Setting[:allow_auto_inventory_upload]
33
- end
34
21
  end
@@ -49,7 +49,6 @@ class ArchivedReportGeneratorTest < ActiveSupport::TestCase
49
49
  test_org = FactoryBot.create(:organization)
50
50
 
51
51
  ForemanInventoryUpload::Generators::Queries.expects(:for_org).with(test_org.id).returns(batches)
52
- ForemanInventoryUpload::Generators::Slice.any_instance.stubs(:golden_ticket?).returns(false)
53
52
  Dir.mktmpdir do |tmpdir|
54
53
  target = File.join(tmpdir, 'test.tar.gz')
55
54
  generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
@@ -13,8 +13,6 @@ class MetadataGeneratorTest < ActiveSupport::TestCase
13
13
 
14
14
  assert_not_nil actual['report_id']
15
15
  assert_equal 'Satellite', actual['source']
16
- assert_not_nil (actual_metadata = actual['source_metadata'])
17
- assert_equal ForemanRhCloud::VERSION, actual_metadata['foreman_rh_cloud_version']
18
16
  assert_equal({}, actual['report_slices'])
19
17
  end
20
18
 
@@ -1,6 +1,6 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- class SliceGeneratorTest < ActiveSupport::TestCase
3
+ class ReportGeneratorTest < ActiveSupport::TestCase
4
4
  setup do
5
5
  User.current = User.find_by(login: 'secret_admin')
6
6
 
@@ -9,7 +9,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
9
9
 
10
10
  @host = FactoryBot.create(
11
11
  :host,
12
- :redhat,
13
12
  :with_subscription,
14
13
  :with_content,
15
14
  content_view: cv.first,
@@ -17,9 +16,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
17
16
  organization: env.organization
18
17
  )
19
18
 
20
- @host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
21
-
22
- ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
19
+ @host.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
23
20
  end
24
21
 
25
22
  def interesting_facts
@@ -33,19 +30,9 @@ class SliceGeneratorTest < ActiveSupport::TestCase
33
30
  'dmi::bios::vendor',
34
31
  'dmi::bios::version',
35
32
  'dmi::bios::relase_date',
33
+ 'distribution::name',
36
34
  'uname::release',
37
35
  'lscpu::flags',
38
- 'distribution::name',
39
- 'distribution::version',
40
- 'distribution::id',
41
- 'virt::is_guest',
42
- 'dmi::system::manufacturer',
43
- 'dmi::system::product_name',
44
- 'dmi::chassis::asset_tag',
45
- 'insights_client::obfuscate_hostname_enabled',
46
- 'insights_client::hostname',
47
- 'insights_client::obfuscate_ip_enabled',
48
- 'insights_client::ips',
49
36
  ]
50
37
  end
51
38
 
@@ -59,218 +46,22 @@ class SliceGeneratorTest < ActiveSupport::TestCase
59
46
 
60
47
  test 'generates a report for a single host' do
61
48
  batch = Host.where(id: @host.id).in_batches.first
62
- generator = create_generator(batch)
63
-
64
- json_str = generator.render
65
- actual = JSON.parse(json_str.join("\n"))
66
-
67
- assert_equal 'slice_123', actual['report_slice_id']
68
- assert_not_nil(actual_host = actual['hosts'].first)
69
- assert_nil actual_host['ip_addresses']
70
- assert_nil actual_host['mac_addresses']
71
- assert_equal @host.fqdn, actual_host['fqdn']
72
- assert_equal '1234', actual_host['account']
73
- assert_equal 1, generator.hosts_count
74
- assert_not_nil(actual_system_profile = actual_host['system_profile'])
75
- assert_nil actual_system_profile['number_of_cpus']
76
- assert_nil actual_system_profile['number_of_sockets']
77
- assert_nil actual_system_profile['cores_per_socket']
78
- assert_nil actual_system_profile['system_memory_bytes']
79
- assert_nil actual_system_profile['os_release']
80
- assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
81
- assert_not_nil(actual_nic = actual_network_interfaces.first)
82
- refute actual_nic.key?('mtu')
83
- refute actual_nic.key?('mac_address')
84
- refute actual_nic.key?('name')
85
- end
86
-
87
- test 'hosts report fields should be present if fact exist' do
88
- FactoryBot.create(:fact_value, fact_name: fact_names['cpu::cpu(s)'], value: '4', host: @host)
89
- FactoryBot.create(:fact_value, fact_name: fact_names['cpu::cpu_socket(s)'], value: '2', host: @host)
90
- FactoryBot.create(:fact_value, fact_name: fact_names['cpu::core(s)_per_socket'], value: '1', host: @host)
91
-
92
- batch = Host.where(id: @host.id).in_batches.first
93
- generator = create_generator(batch)
94
-
95
- json_str = generator.render
96
- actual = JSON.parse(json_str.join("\n"))
97
-
98
- assert_equal 'slice_123', actual['report_slice_id']
99
- assert_not_nil(actual_host = actual['hosts'].first)
100
- assert_not_nil(actual_system_profile = actual_host['system_profile'])
101
- assert_equal 4, actual_system_profile['number_of_cpus']
102
- assert_equal 2, actual_system_profile['number_of_sockets']
103
- assert_equal 1, actual_system_profile['cores_per_socket']
104
- end
105
-
106
- test 'generates ip_address and mac_address fields' do
107
- nic = FactoryBot.build(:nic_managed)
108
- nic.attrs['mtu'] = '1500'
109
- @host.interfaces << nic
110
- batch = Host.where(id: @host.id).in_batches.first
111
- generator = create_generator(batch)
112
-
113
- json_str = generator.render
114
- actual = JSON.parse(json_str.join("\n"))
115
-
116
- assert_equal 'slice_123', actual['report_slice_id']
117
- assert_not_nil(actual_host = actual['hosts'].first)
118
- assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
119
- assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
120
- assert_equal @host.fqdn, actual_host['fqdn']
121
- assert_equal '1234', actual_host['account']
122
- assert_equal 1, generator.hosts_count
123
- end
124
-
125
- test 'generates nic fields' do
126
- ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
127
- nic = FactoryBot.build(:nic_managed, ip6: ip6)
128
- nic.attrs['mtu'] = '1500'
129
- @host.interfaces << nic
130
- batch = Host.where(id: @host.id).in_batches.first
131
- generator = create_generator(batch)
132
-
133
- json_str = generator.render
134
- actual = JSON.parse(json_str.join("\n"))
135
-
136
- assert_equal 'slice_123', actual['report_slice_id']
137
- assert_not_nil(actual_host = actual['hosts'].first)
138
- expected_ip = @host.interfaces.where.not(ip: nil).first.ip
139
- assert_not_nil actual_host['ip_addresses'].find { |addr| addr == expected_ip }
140
- expected_mac = @host.interfaces.where.not(mac: nil).first.mac
141
- assert_not_nil actual_host['mac_addresses'].find { |mac| mac == expected_mac }
142
- assert_not_nil(actual_system_profile = actual_host['system_profile'])
143
- assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
144
- assert_not_nil(actual_nic = actual_network_interfaces.find { |nic_node| nic_node['ipv4_addresses'].first == nic.ip })
145
- assert_equal nic.ip, actual_nic['ipv4_addresses'].first
146
- assert_equal nic.ip6, actual_nic['ipv6_addresses'].first
147
- assert_equal 1500, actual_nic['mtu']
148
- assert_equal nic.mac, actual_nic['mac_address']
149
- assert_equal nic.identifier, actual_nic['name']
150
- assert_equal @host.fqdn, actual_host['fqdn']
151
- assert_equal '1234', actual_host['account']
152
- assert_equal 1, generator.hosts_count
153
- end
154
-
155
- test 'generates obfuscated ip_address fields without inisghts-client' do
156
- FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
157
-
158
- @host.interfaces << FactoryBot.build(:nic_managed)
159
- batch = Host.where(id: @host.id).in_batches.first
160
- generator = create_generator(batch)
161
-
162
- json_str = generator.render
163
- actual = JSON.parse(json_str.join("\n"))
164
-
165
- assert_equal 'slice_123', actual['report_slice_id']
166
- assert_not_nil(actual_host = actual['hosts'].first)
167
- assert_equal '10.230.230.1', actual_host['ip_addresses'].first
168
- assert_not_nil(actual_system_profile = actual_host['system_profile'])
169
- assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
170
- assert_not_nil(actual_nic = actual_network_interfaces.first)
171
- assert_equal '10.230.230.1', actual_nic['ipv4_addresses'].first
172
- assert_equal @host.fqdn, actual_host['fqdn']
173
- assert_equal '1234', actual_host['account']
174
- assert_equal 1, generator.hosts_count
175
- end
176
-
177
- test 'generates obfuscated ip_address fields with inisghts-client' do
178
- nic = FactoryBot.build(:nic_primary_and_provision)
179
- @host.interfaces = [nic]
180
- @host.save!
181
-
182
- FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_ip_enabled'], value: 'true', host: @host)
183
- FactoryBot.create(
184
- :fact_value,
185
- fact_name: fact_names['insights_client::ips'],
186
- value: "[{\"obfuscated\": \"10.230.230.100\", \"original\": \"#{nic.ip}\"}]",
187
- host: @host
188
- )
189
-
190
- batch = Host.where(id: @host.id).in_batches.first
191
- generator = create_generator(batch)
49
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
192
50
 
193
51
  json_str = generator.render
194
52
  actual = JSON.parse(json_str.join("\n"))
195
53
 
196
54
  assert_equal 'slice_123', actual['report_slice_id']
197
55
  assert_not_nil(actual_host = actual['hosts'].first)
198
- assert_equal '10.230.230.100', actual_host['ip_addresses'].first
199
- assert_not_nil(actual_system_profile = actual_host['system_profile'])
200
- assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
201
- assert_not_nil(actual_nic = actual_network_interfaces.first)
202
- assert_equal '10.230.230.100', actual_nic['ipv4_addresses'].first
56
+ assert_equal @host.name, actual_host['display_name']
203
57
  assert_equal @host.fqdn, actual_host['fqdn']
204
58
  assert_equal '1234', actual_host['account']
205
- assert_equal 1, generator.hosts_count
206
- end
207
-
208
- test 'obfuscates fqdn when instructed by insights-client' do
209
- FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_hostname_enabled'], value: 'true', host: @host)
210
- FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::hostname'], value: 'obfuscated_name', host: @host)
211
-
212
- batch = Host.where(id: @host.id).in_batches.first
213
- generator = create_generator(batch)
214
-
215
- json_str = generator.render
216
- actual = JSON.parse(json_str.join("\n"))
217
-
218
- assert_equal 'slice_123', actual['report_slice_id']
219
- assert_not_nil(actual_host = actual['hosts'].first)
220
- assert_equal 'obfuscated_name', actual_host['fqdn']
221
- assert_equal '1234', actual_host['account']
222
- assert_not_nil(actual_facts = actual_host['facts'].first['facts'])
223
- assert_equal true, actual_facts['is_hostname_obfuscated']
224
- assert_equal 1, generator.hosts_count
225
- end
226
-
227
- test 'obfuscates fqdn when setting set' do
228
- FactoryBot.create(:setting, :name => 'obfuscate_inventory_hostnames', :value => true)
229
-
230
- batch = Host.where(id: @host.id).in_batches.first
231
- generator = create_generator(batch)
232
-
233
- json_str = generator.render
234
- actual = JSON.parse(json_str.join("\n"))
235
-
236
- obfuscated_fqdn = Digest::SHA1.hexdigest(@host.fqdn) + '.example.com'
237
-
238
- assert_equal 'slice_123', actual['report_slice_id']
239
- assert_not_nil(actual_host = actual['hosts'].first)
240
- assert_equal obfuscated_fqdn, actual_host['fqdn']
241
- assert_equal '1234', actual_host['account']
242
- assert_not_nil(actual_facts = actual_host['facts'].first['facts'])
243
- assert_equal true, actual_facts['is_hostname_obfuscated']
244
- assert_equal 1, generator.hosts_count
245
- end
246
-
247
- test 'does not obfuscate fqdn when insights-client sets to false' do
248
- FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_hostname_enabled'], value: 'false', host: @host)
249
- FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::hostname'], value: 'obfuscated_name', host: @host)
250
-
251
- batch = Host.where(id: @host.id).in_batches.first
252
- generator = create_generator(batch)
253
-
254
- json_str = generator.render
255
- actual = JSON.parse(json_str.join("\n"))
256
-
257
- assert_equal 'slice_123', actual['report_slice_id']
258
- assert_not_nil(actual_host = actual['hosts'].first)
259
- assert_equal @host.fqdn, actual_host['fqdn']
260
- assert_equal '1234', actual_host['account']
261
- assert_not_nil(actual_facts = actual_host['facts'].first['facts'])
262
- assert_equal false, actual_facts['is_hostname_obfuscated']
263
- assert_equal 1, generator.hosts_count
264
59
  end
265
60
 
266
61
  test 'generates a report with satellite facts' do
267
- hostgroup = FactoryBot.create(:hostgroup)
268
- @host.hostgroup = hostgroup
269
- @host.save!
270
-
271
62
  Foreman.expects(:instance_id).twice.returns('satellite-id')
272
63
  batch = Host.where(id: @host.id).in_batches.first
273
- generator = create_generator(batch)
64
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice-123')
274
65
 
275
66
  json_str = generator.render
276
67
  actual = JSON.parse(json_str.join("\n"))
@@ -281,15 +72,13 @@ class SliceGeneratorTest < ActiveSupport::TestCase
281
72
  assert_equal 'satellite-id', satellite_facts['satellite_instance_id']
282
73
  assert_equal @host.organization_id, satellite_facts['organization_id']
283
74
 
284
- actual_host = actual['hosts'].first
285
- assert_tag('satellite-id', actual_host, 'satellite_instance_id')
286
- assert_tag(@host.organization_id.to_s, actual_host, 'organization_id')
287
- assert_tag(@host.content_view.name, actual_host, 'content_view')
288
- assert_tag(@host.location.name, actual_host, 'location')
289
- assert_tag(@host.organization.name, actual_host, 'organization')
290
- assert_tag(@host.hostgroup.name, actual_host, 'hostgroup')
75
+ instance_id_tag = actual['hosts'].first['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == 'satellite_instance_id'}
76
+ assert_not_nil instance_id_tag
77
+ assert_equal 'satellite-id', instance_id_tag['value']
291
78
 
292
- assert_equal false, satellite_facts['is_hostname_obfuscated']
79
+ org_id_tag = actual['hosts'].first['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == 'organization_id'}
80
+ assert_not_nil org_id_tag
81
+ assert_equal @host.organization_id, org_id_tag['value']
293
82
 
294
83
  version = satellite_facts['satellite_version']
295
84
  if defined?(ForemanThemeSatellite)
@@ -313,13 +102,14 @@ class SliceGeneratorTest < ActiveSupport::TestCase
313
102
  @host.save!
314
103
 
315
104
  batch = Host.where(id: @host.id).in_batches.first
316
- generator = create_generator(batch)
105
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
317
106
 
318
107
  json_str = generator.render
319
108
  actual = JSON.parse(json_str.join("\n"))
320
109
 
321
110
  assert_equal 'slice_123', actual['report_slice_id']
322
111
  assert_not_nil(actual_host = actual['hosts'].first)
112
+ assert_equal @host.name, actual_host['display_name']
323
113
  assert_equal @host.fqdn, actual_host['fqdn']
324
114
  assert_not_nil(host_facts = actual_host['facts']&.first)
325
115
  assert_equal 'satellite', host_facts['namespace']
@@ -331,40 +121,23 @@ class SliceGeneratorTest < ActiveSupport::TestCase
331
121
  test 'generates a report with system purpose' do
332
122
  @host.subscription_facet.purpose_usage = 'test_usage'
333
123
  @host.subscription_facet.purpose_role = 'test_role'
334
- @host.subscription_facet.service_level = 'test_sla'
335
124
  @host.subscription_facet.save!
336
125
 
337
126
  batch = Host.where(id: @host.id).in_batches.first
338
- generator = create_generator(batch)
127
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
339
128
 
340
129
  json_str = generator.render
341
130
  actual = JSON.parse(json_str.join("\n"))
342
131
 
343
132
  assert_equal 'slice_123', actual['report_slice_id']
344
133
  assert_not_nil(actual_host = actual['hosts'].first)
134
+ assert_equal @host.name, actual_host['display_name']
345
135
  assert_equal @host.fqdn, actual_host['fqdn']
346
136
  assert_not_nil(host_facts = actual_host['facts']&.first)
347
137
  assert_equal 'satellite', host_facts['namespace']
348
138
  assert_not_nil(fact_values = host_facts['facts'])
349
139
  assert_equal 'test_usage', fact_values['system_purpose_usage']
350
140
  assert_equal 'test_role', fact_values['system_purpose_role']
351
- assert_equal 'test_sla', fact_values['system_purpose_sla']
352
- end
353
-
354
- test 'generates a report for a golden ticket' do
355
- batch = Host.where(id: @host.id).in_batches.first
356
- generator = create_generator(batch) do |generator|
357
- generator.stubs(:golden_ticket?).returns(true)
358
- end
359
-
360
- json_str = generator.render
361
- actual = JSON.parse(json_str.join("\n"))
362
-
363
- assert_equal 'slice_123', actual['report_slice_id']
364
- assert_not_nil(actual_host = actual['hosts'].first)
365
- assert_equal @host.fqdn, actual_host['fqdn']
366
- assert_equal '1234', actual_host['account']
367
- assert_equal 1, generator.hosts_count
368
141
  end
369
142
 
370
143
  test 'skips hosts without subscription' do
@@ -375,39 +148,23 @@ class SliceGeneratorTest < ActiveSupport::TestCase
375
148
 
376
149
  # make a_host last
377
150
  batch = Host.where(id: [@host.id, a_host.id]).order(:name).in_batches.first
378
- generator = create_generator(batch)
151
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
379
152
 
380
153
  json_str = generator.render
381
154
  actual = JSON.parse(json_str.join("\n"))
382
155
 
383
156
  assert_equal 'slice_123', actual['report_slice_id']
384
157
  assert_not_nil(actual_host = actual['hosts'].first)
158
+ assert_equal @host.name, actual_host['display_name']
385
159
  assert_equal @host.fqdn, actual_host['fqdn']
386
160
  assert_equal '1234', actual_host['account']
387
- assert_equal 1, generator.hosts_count
388
- end
389
-
390
- test 'include also hosts with non-redhat OS' do
391
- os = @host.operatingsystem
392
- os.name = 'Centos'
393
- os.save!
394
-
395
- # make a_host last
396
- batch = ForemanInventoryUpload::Generators::Queries.for_org(@host.organization_id).first
397
- generator = create_generator(batch)
398
-
399
- json_str = generator.render
400
- actual = JSON.parse(json_str.join("\n"))
401
-
402
- assert_equal 'slice_123', actual['report_slice_id']
403
- assert_equal 1, generator.hosts_count
404
161
  end
405
162
 
406
163
  test 'shows system_memory_bytes in bytes' do
407
164
  FactoryBot.create(:fact_value, fact_name: fact_names['memory::memtotal'], value: '1', host: @host)
408
165
 
409
166
  batch = Host.where(id: @host.id).in_batches.first
410
- generator = create_generator(batch)
167
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
411
168
 
412
169
  json_str = generator.render
413
170
  actual = JSON.parse(json_str.join("\n"))
@@ -417,196 +174,4 @@ class SliceGeneratorTest < ActiveSupport::TestCase
417
174
  assert_not_nil(actual_profile = actual_host['system_profile'])
418
175
  assert_equal 1024, actual_profile['system_memory_bytes']
419
176
  end
420
-
421
- test 'reports an account for hosts with multiple pools' do
422
- first_pool = @host.organization.pools.first
423
- second_pool = FactoryBot.create(:katello_pool, account_number: nil, cp_id: 2)
424
- new_org = FactoryBot.create(:organization, pools: [first_pool, second_pool])
425
-
426
- another_host = FactoryBot.create(
427
- :host,
428
- :with_subscription,
429
- :with_content,
430
- content_view: @host.content_view,
431
- lifecycle_environment: @host.lifecycle_environment,
432
- organization: new_org
433
- )
434
-
435
- batch = Host.where(id: another_host.id).in_batches.first
436
- generator = create_generator(batch)
437
-
438
- json_str = generator.render
439
- actual = JSON.parse(json_str.join("\n"))
440
-
441
- assert_equal 'slice_123', actual['report_slice_id']
442
- assert_not_nil(actual_host = actual['hosts'].first)
443
- assert_not_nil(actual_host['account'])
444
- assert_not_empty(actual_host['account'])
445
- end
446
-
447
- test 'Generates os_release with version and id' do
448
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::name'], value: 'Red Hat Test Linux', host: @host)
449
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::version'], value: '7.1', host: @host)
450
- FactoryBot.create(:fact_value, fact_name: fact_names['distribution::id'], value: 'TestId', host: @host)
451
-
452
- batch = Host.where(id: @host.id).in_batches.first
453
- generator = create_generator(batch)
454
-
455
- json_str = generator.render
456
- actual = JSON.parse(json_str.join("\n"))
457
-
458
- assert_equal 'slice_123', actual['report_slice_id']
459
- assert_not_nil(actual_host = actual['hosts'].first)
460
- assert_not_nil(actual_profile = actual_host['system_profile'])
461
- assert_equal 'Red Hat Test Linux 7.1 (TestId)', actual_profile['os_release']
462
- end
463
-
464
- test 'sets infrastructure_type to "virtual" based on virt.is_guest fact' do
465
- FactoryBot.create(:fact_value, fact_name: fact_names['virt::is_guest'], value: true, host: @host)
466
-
467
- batch = Host.where(id: @host.id).in_batches.first
468
- generator = create_generator(batch)
469
-
470
- json_str = generator.render
471
- actual = JSON.parse(json_str.join("\n"))
472
-
473
- assert_equal 'slice_123', actual['report_slice_id']
474
- assert_not_nil(actual_host = actual['hosts'].first)
475
- assert_not_nil(actual_profile = actual_host['system_profile'])
476
- assert_equal 'virtual', actual_profile['infrastructure_type']
477
- end
478
-
479
- test 'sets infrastructure_type to "physical" based on virt.is_guest fact' do
480
- FactoryBot.create(:fact_value, fact_name: fact_names['virt::is_guest'], value: false, host: @host)
481
-
482
- batch = Host.where(id: @host.id).in_batches.first
483
- generator = create_generator(batch)
484
-
485
- json_str = generator.render
486
- actual = JSON.parse(json_str.join("\n"))
487
-
488
- assert_equal 'slice_123', actual['report_slice_id']
489
- assert_not_nil(actual_host = actual['hosts'].first)
490
- assert_not_nil(actual_profile = actual_host['system_profile'])
491
- assert_equal 'physical', actual_profile['infrastructure_type']
492
- end
493
-
494
- test 'Identifies Amazon cloud provider' do
495
- FactoryBot.create(:fact_value, fact_name: fact_names['dmi::bios::version'], value: 'Test Amazon version', host: @host)
496
-
497
- batch = Host.where(id: @host.id).in_batches.first
498
- generator = create_generator(batch)
499
-
500
- json_str = generator.render
501
- actual = JSON.parse(json_str.join("\n"))
502
-
503
- assert_equal 'slice_123', actual['report_slice_id']
504
- assert_not_nil(actual_host = actual['hosts'].first)
505
- assert_not_nil(actual_profile = actual_host['system_profile'])
506
- assert_equal 'aws', actual_profile['cloud_provider']
507
- end
508
-
509
- test 'Identifies Google cloud provider' do
510
- FactoryBot.create(:fact_value, fact_name: fact_names['dmi::bios::version'], value: 'Test Google version', host: @host)
511
-
512
- batch = Host.where(id: @host.id).in_batches.first
513
- generator = create_generator(batch)
514
-
515
- json_str = generator.render
516
- actual = JSON.parse(json_str.join("\n"))
517
-
518
- assert_equal 'slice_123', actual['report_slice_id']
519
- assert_not_nil(actual_host = actual['hosts'].first)
520
- assert_not_nil(actual_profile = actual_host['system_profile'])
521
- assert_equal 'google', actual_profile['cloud_provider']
522
- end
523
-
524
- test 'Identifies Azure cloud provider' do
525
- FactoryBot.create(:fact_value, fact_name: fact_names['dmi::chassis::asset_tag'], value: '7783-7084-3265-9085-8269-3286-77', host: @host)
526
-
527
- batch = Host.where(id: @host.id).in_batches.first
528
- generator = create_generator(batch)
529
-
530
- json_str = generator.render
531
- actual = JSON.parse(json_str.join("\n"))
532
-
533
- assert_equal 'slice_123', actual['report_slice_id']
534
- assert_not_nil(actual_host = actual['hosts'].first)
535
- assert_not_nil(actual_profile = actual_host['system_profile'])
536
- assert_equal 'azure', actual_profile['cloud_provider']
537
- end
538
-
539
- test 'Identifies Alibaba cloud provider via manufacturer' do
540
- FactoryBot.create(:fact_value, fact_name: fact_names['dmi::system::manufacturer'], value: 'Test Alibaba Cloud version', host: @host)
541
-
542
- batch = Host.where(id: @host.id).in_batches.first
543
- generator = create_generator(batch)
544
-
545
- json_str = generator.render
546
- actual = JSON.parse(json_str.join("\n"))
547
-
548
- assert_equal 'slice_123', actual['report_slice_id']
549
- assert_not_nil(actual_host = actual['hosts'].first)
550
- assert_not_nil(actual_profile = actual_host['system_profile'])
551
- assert_equal 'alibaba', actual_profile['cloud_provider']
552
- end
553
-
554
- test 'Identifies Alibaba cloud provider via product name' do
555
- FactoryBot.create(:fact_value, fact_name: fact_names['dmi::system::product_name'], value: 'Test Alibaba Cloud ECS product', host: @host)
556
-
557
- batch = Host.where(id: @host.id).in_batches.first
558
- generator = create_generator(batch)
559
-
560
- json_str = generator.render
561
- actual = JSON.parse(json_str.join("\n"))
562
-
563
- assert_equal 'slice_123', actual['report_slice_id']
564
- assert_not_nil(actual_host = actual['hosts'].first)
565
- assert_not_nil(actual_profile = actual_host['system_profile'])
566
- assert_equal 'alibaba', actual_profile['cloud_provider']
567
- end
568
-
569
- test 'include packages installed in the report' do
570
- FactoryBot.create(:setting, :name => 'exclude_installed_packages', :value => false)
571
- installed_package = ::Katello::InstalledPackage.create(name: 'test-package', nvra: 'test-package-1.0.x86_64')
572
-
573
- another_host = FactoryBot.create(
574
- :host,
575
- :with_subscription,
576
- :with_content,
577
- content_view: @host.content_view,
578
- lifecycle_environment: @host.lifecycle_environment,
579
- organization: @host.organization,
580
- installed_packages: [installed_package]
581
- )
582
-
583
- batch = Host.where(id: another_host.id).in_batches.first
584
- generator = create_generator(batch)
585
-
586
- json_str = generator.render
587
- actual = JSON.parse(json_str.join("\n"))
588
-
589
- assert_equal 'slice_123', actual['report_slice_id']
590
- assert_not_nil(actual_host = actual['hosts'].first)
591
- assert_not_nil(actual_profile = actual_host['system_profile'])
592
- assert_not_nil(actual_profile['installed_packages'])
593
- end
594
-
595
- private
596
-
597
- def create_generator(batch, name = 'slice_123')
598
- generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], name)
599
- if block_given?
600
- yield(generator)
601
- else
602
- generator.stubs(:golden_ticket?).returns(false)
603
- end
604
- generator
605
- end
606
-
607
- def assert_tag(expected_value, host, tag_id)
608
- actual_tag = host['tags'].find { |tag| tag['namespace'] == 'satellite' && tag['key'] == tag_id }
609
- assert_not_nil actual_tag
610
- assert_equal expected_value, actual_tag['value']
611
- end
612
177
  end