foreman_rh_cloud 0.9.14 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -33
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +6 -7
- data/app/controllers/foreman_inventory_upload/react_controller.rb +7 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +7 -51
- data/app/views/{layouts/foreman_rh_cloud/application.html.erb → foreman_inventory_upload/layouts/react.html.erb} +2 -2
- data/config/routes.rb +1 -18
- data/lib/foreman_inventory_upload.rb +0 -16
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +0 -8
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +1 -1
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +10 -5
- data/lib/foreman_inventory_upload/async/shell_process.rb +9 -17
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +9 -21
- data/lib/foreman_inventory_upload/generators/archived_report.rb +3 -6
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +0 -91
- data/lib/foreman_inventory_upload/generators/json_stream.rb +2 -17
- data/lib/foreman_inventory_upload/generators/metadata.rb +0 -3
- data/lib/foreman_inventory_upload/generators/queries.rb +4 -11
- data/lib/foreman_inventory_upload/generators/slice.rb +38 -88
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +1 -0
- data/lib/foreman_rh_cloud.rb +0 -67
- data/lib/foreman_rh_cloud/engine.rb +6 -48
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/tasks/generator.rake +29 -0
- data/package.json +1 -3
- data/test/controllers/accounts_controller_test.rb +3 -8
- data/test/controllers/uploads_controller_test.rb +0 -13
- data/test/unit/archived_report_generator_test.rb +0 -1
- data/test/unit/metadata_generator_test.rb +0 -2
- data/test/unit/slice_generator_test.rb +19 -454
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +2 -29
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +10 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +15 -23
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -34
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +1 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +4 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +1 -15
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +4 -32
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +8 -29
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +3 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +2 -40
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +0 -32
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +2 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +3 -4
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +3 -2
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +1 -2
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +2 -3
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +1 -5
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +0 -1
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +13 -15
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +2 -4
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +2 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -12
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +1 -1
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +1 -6
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +4 -2
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +9 -18
- data/webpack/ForemanInventoryUpload/{__tests__/ForemanInventoryUpload.test.js → ForemanInventoryUpload.test.js} +1 -1
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +4 -6
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +4 -0
- data/webpack/ForemanInventoryUpload/{__tests__/__snapshots__ → __snapshots__}/ForemanInventoryUpload.test.js.snap +5 -6
- data/webpack/index.js +6 -3
- data/webpack/stories/decorators/withCardsDecorator.js +1 -1
- metadata +48 -245
- data/app/controllers/foreman_inventory_upload/tasks_controller.rb +0 -25
- data/app/controllers/foreman_rh_cloud/react_controller.rb +0 -11
- data/app/controllers/insights_cloud/hits_controller.rb +0 -17
- data/app/controllers/insights_cloud/settings_controller.rb +0 -24
- data/app/controllers/insights_cloud/tasks_controller.rb +0 -7
- data/app/helpers/foreman_inventory_upload_host_helper.rb +0 -19
- data/app/models/concerns/rh_cloud_host.rb +0 -15
- data/app/models/insights_facet.rb +0 -7
- data/app/models/insights_hit.rb +0 -6
- data/app/models/inventory_sync/inventory_status.rb +0 -30
- data/app/models/setting/rh_cloud.rb +0 -23
- data/app/overrides/hosts_list.rb +0 -13
- data/app/services/foreman_rh_cloud/cloud_auth.rb +0 -28
- data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +0 -6
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +0 -1
- data/app/views/hosts/_insights_tab.html.erb +0 -15
- data/db/migrate/20191215104806_create_insights_hits.foreman_inventory_upload.rb +0 -14
- data/db/migrate/20191216062008_create_insights_facets.foreman_inventory_upload.rb +0 -7
- data/db/migrate/20200727111529_add_uuid_column_to_insights_facets.foreman_rh_cloud.rb +0 -5
- data/db/migrate/20201007115752_add_hits_count_to_insights_facets_table.foreman_rh_cloud.rb +0 -5
- data/db/migrate/20201007121540_setup_hits_count_cache.foreman_rh_cloud.rb +0 -10
- data/lib/foreman_inventory_upload/async/async_helpers.rb +0 -13
- data/lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb +0 -19
- data/lib/insights_cloud.rb +0 -15
- data/lib/insights_cloud/async/insights_full_sync.rb +0 -84
- data/lib/insights_cloud/async/insights_scheduled_sync.rb +0 -23
- data/lib/inventory_sync/async/host_result.rb +0 -50
- data/lib/inventory_sync/async/inventory_full_sync.rb +0 -80
- data/lib/tasks/insights.rake +0 -15
- data/lib/tasks/rh_cloud_inventory.rake +0 -37
- data/test/controllers/insights_sync/settings_controller_test.rb +0 -30
- data/test/factories/insights_factories.rb +0 -31
- data/test/jobs/insights_full_sync_test.rb +0 -94
- data/test/jobs/inventory_full_sync_test.rb +0 -91
- data/test/jobs/upload_report_job_test.rb +0 -34
- data/test/unit/fact_helpers_test.rb +0 -51
- data/test/unit/insights_facet_test.rb +0 -23
- data/test/unit/rh_cloud_http_proxy_test.rb +0 -52
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js +0 -15
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +0 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +0 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +0 -12
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +0 -3
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +0 -32
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +0 -29
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +0 -24
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +0 -38
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +0 -31
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/index.js +0 -17
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +0 -30
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +0 -29
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +0 -21
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +0 -38
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +0 -31
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +0 -41
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +0 -38
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +0 -20
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +0 -30
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +0 -29
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcher.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +0 -24
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +0 -38
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +0 -31
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/index.js +0 -20
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +0 -26
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +0 -39
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js +0 -16
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +0 -3
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +0 -36
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js +0 -7
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +0 -35
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +0 -21
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +0 -25
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +0 -17
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +0 -25
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +0 -9
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +0 -40
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +0 -17
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +0 -28
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +0 -19
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettings.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +0 -15
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/inventorySettings.scss +0 -15
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +0 -29
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +0 -29
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +0 -21
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +0 -38
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +0 -31
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +0 -20
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +0 -40
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +0 -61
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/DocsButton.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +0 -21
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +0 -19
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +0 -22
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +0 -24
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js +0 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +0 -17
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +0 -58
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +0 -57
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +0 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +0 -36
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +0 -31
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +0 -9
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +0 -26
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +0 -36
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +0 -26
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +0 -98
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -18
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +0 -18
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +0 -63
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +0 -41
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +0 -20
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +0 -22
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +0 -15
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +0 -12
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +0 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +0 -12
- data/webpack/ForemanInventoryUpload/Components/PageHeader/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +0 -3
- data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +0 -9
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +0 -20
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +0 -12
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +0 -5
- data/webpack/ForemanRhCloudHelpers.js +0 -6
- data/webpack/ForemanRhCloudPages.js +0 -9
- data/webpack/ForemanRhCloudReducers.js +0 -12
- data/webpack/ForemanRhCloudSelectors.js +0 -10
- data/webpack/ForemanRhCloudTestHelpers.js +0 -20
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +0 -33
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +0 -57
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +0 -4
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +0 -24
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsSelectors.js +0 -6
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +0 -18
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +0 -62
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +0 -33
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +0 -21
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +0 -15
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +0 -65
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +0 -19
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +0 -9
- data/webpack/InsightsCloudSync/Components/InsightsSettings/index.js +0 -21
- data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +0 -16
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +0 -1
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +0 -45
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +0 -17
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +0 -38
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +0 -1
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +0 -3
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +0 -59
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -16
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +0 -22
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -4
- data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +0 -3
- data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +0 -8
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +0 -65
- data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncHelpers.test.js +0 -11
- data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncHelpers.test.js.snap +0 -3
- data/webpack/InsightsCloudSync/index.js +0 -18
- data/webpack/InsightsHostDetailsTab/InsightsTab.js +0 -64
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -86
- data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +0 -31
- data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +0 -2
- data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +0 -19
- data/webpack/InsightsHostDetailsTab/InsightsTabSelectors.js +0 -3
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +0 -25
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.test.js +0 -13
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +0 -19
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabIntegration.test.js +0 -17
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +0 -26
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js +0 -13
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +0 -30
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +0 -58
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +0 -34
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +0 -20
- data/webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js +0 -69
- data/webpack/InsightsHostDetailsTab/components/ListItem/index.js +0 -1
- data/webpack/InsightsHostDetailsTab/index.js +0 -20
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +0 -1
- data/webpack/__mocks__/foremanReact/constants.js +0 -5
- data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +0 -8
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +0 -11
- data/webpack/__tests__/ForemanRhCloudSelectors.test.js +0 -22
- data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +0 -20
- data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -3
- data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +0 -25
- data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +0 -39
- data/webpack/subscriptions_extension_index.js +0 -8
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module InsightsCloud
|
|
2
|
-
class HitsController < ::ApplicationController
|
|
3
|
-
def index
|
|
4
|
-
host = Host.where(id: host_id_param).first
|
|
5
|
-
|
|
6
|
-
render json: {
|
|
7
|
-
hits: host.insights.hits,
|
|
8
|
-
}, status: :ok
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def host_id_param
|
|
14
|
-
params.require(:host_id)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module InsightsCloud
|
|
2
|
-
class SettingsController < ::ApplicationController
|
|
3
|
-
def show
|
|
4
|
-
render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def update
|
|
8
|
-
Setting[:allow_auto_insights_sync] = settings_params
|
|
9
|
-
render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
def render_setting(node_name, setting)
|
|
15
|
-
render json: {
|
|
16
|
-
node_name => Setting[setting],
|
|
17
|
-
}
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def settings_params
|
|
21
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:insightsSyncEnabled))
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
tag.td class: ['hidden-xs', 'ellipsis', 'text-center'] do
|
|
9
|
-
if host_hits
|
|
10
|
-
link_to(
|
|
11
|
-
host_hits,
|
|
12
|
-
InsightsCloud::WebUi.system_url(InsightsCloud::WebUi::ADVISOR, host.insights.uuid),
|
|
13
|
-
:rel => 'external noopener noreferrer',
|
|
14
|
-
:target => '_blank'
|
|
15
|
-
)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module RhCloudHost
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
included do
|
|
5
|
-
has_many(
|
|
6
|
-
:inventory_upload_facts,
|
|
7
|
-
-> { where(fact_name_id: ForemanInventoryUpload::Generators::Queries.fact_names.values) },
|
|
8
|
-
class_name: 'FactValue',
|
|
9
|
-
foreign_key: :host_id
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
has_many :insights_hits, through: :insights, source: :hits
|
|
13
|
-
scoped_search :relation => :insights, :on => :hits_count, :only_explicit => true, :rename => :insights_recommendations_count
|
|
14
|
-
end
|
|
15
|
-
end
|
data/app/models/insights_hit.rb
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
belongs_to :insights_facet, foreign_key: 'host_id', primary_key: 'host_id', counter_cache: :hits_count
|
|
6
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
class Setting::RhCloud < Setting
|
|
2
|
-
def self.load_defaults
|
|
3
|
-
return unless ActiveRecord::Base.connection.table_exists?('settings')
|
|
4
|
-
return unless super
|
|
5
|
-
|
|
6
|
-
transaction do
|
|
7
|
-
[
|
|
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('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false),
|
|
12
|
-
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),
|
|
13
|
-
set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false),
|
|
14
|
-
].each { |s| create! s.update(:category => 'Setting::RhCloud')}
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
true
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.humanized_category
|
|
21
|
-
N_('RH Cloud')
|
|
22
|
-
end
|
|
23
|
-
end
|
data/app/overrides/hosts_list.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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 ellipsis" width="12%"><%= sort :insights_recommendations_count, :as => _("Recommendations")%></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
|
-
)
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module ForemanRhCloud
|
|
2
|
-
module CloudAuth
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
def rh_credentials
|
|
6
|
-
@rh_credentials ||= query_refresh_token
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def query_refresh_token
|
|
10
|
-
token_response = RestClient::Request.execute(
|
|
11
|
-
method: :post,
|
|
12
|
-
url: ForemanRhCloud.authentication_url,
|
|
13
|
-
verify_ssl: ForemanRhCloud.verify_ssl_method,
|
|
14
|
-
proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
|
|
15
|
-
payload: {
|
|
16
|
-
grant_type: 'refresh_token',
|
|
17
|
-
client_id: 'rhsm-api',
|
|
18
|
-
refresh_token: Setting[:rh_cloud_token],
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
JSON.parse(token_response)['access_token']
|
|
23
|
-
rescue RestClient::ExceptionWithResponse => e
|
|
24
|
-
Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
|
|
25
|
-
raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= mount_react_component('ForemanInventoryUpload', '#ForemanRhCloudReactRoot') %>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<% content_for(:javascripts) do %>
|
|
2
|
-
<%= webpacked_plugins_js_for :'foreman_rh_cloud' %>
|
|
3
|
-
<% end %>
|
|
4
|
-
|
|
5
|
-
<% content_for(:stylesheets) do %>
|
|
6
|
-
<%= webpacked_plugins_css_for :'foreman_rh_cloud' %>
|
|
7
|
-
<% end %>
|
|
8
|
-
|
|
9
|
-
<div id="host_details_insights_react_container"></div>
|
|
10
|
-
<%= mount_react_component(
|
|
11
|
-
'InsightsHostDetailsTab',
|
|
12
|
-
'#host_details_insights_react_container',
|
|
13
|
-
{ hostID: host.id }.to_json,
|
|
14
|
-
flatten_data: true
|
|
15
|
-
) %>
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
class SetupHitsCountCache < ActiveRecord::Migration[5.0]
|
|
2
|
-
def up
|
|
3
|
-
ActiveRecord::Base.connection.execute <<-SQL.squish
|
|
4
|
-
UPDATE insights_facets
|
|
5
|
-
SET hits_count = (SELECT count(1)
|
|
6
|
-
FROM insights_hits
|
|
7
|
-
WHERE insights_hits.host_id = insights_facets.host_id)
|
|
8
|
-
SQL
|
|
9
|
-
end
|
|
10
|
-
end
|
data/lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module ForemanInventoryUpload
|
|
2
|
-
module Notifications
|
|
3
|
-
module ManifestImportSuccessNotificationOverride
|
|
4
|
-
extend ActiveSupport::Concern
|
|
5
|
-
|
|
6
|
-
def actions
|
|
7
|
-
{
|
|
8
|
-
:links => [
|
|
9
|
-
{
|
|
10
|
-
:href => Rails.application.routes.url_helpers.foreman_rh_cloud_inventory_upload_path,
|
|
11
|
-
:title => _('Enable inventory upload'),
|
|
12
|
-
:external => false,
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
}
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
data/lib/insights_cloud.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module InsightsCloud
|
|
2
|
-
module WebUi
|
|
3
|
-
ADVISOR = 'advisor'
|
|
4
|
-
VULNERABILITY = 'vulnerability'
|
|
5
|
-
PATCH = 'patch'
|
|
6
|
-
|
|
7
|
-
def self.system_url(subsystem, host_uuid)
|
|
8
|
-
ForemanRhCloud.base_url + "/insights/#{subsystem}/systems/#{host_uuid}"
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.hits_export_url
|
|
13
|
-
ForemanRhCloud.base_url + '/api/insights/v1/export/hits/'
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
require 'rest-client'
|
|
2
|
-
|
|
3
|
-
module InsightsCloud
|
|
4
|
-
module Async
|
|
5
|
-
class InsightsFullSync < ::ApplicationJob
|
|
6
|
-
include ::ForemanRhCloud::CloudAuth
|
|
7
|
-
|
|
8
|
-
def perform
|
|
9
|
-
hits = query_insights_hits
|
|
10
|
-
|
|
11
|
-
@hits_host_names = Hash[hits.map { |hit| [hit['hostname'], hit['uuid']] }]
|
|
12
|
-
setup_host_names(@hits_host_names.keys)
|
|
13
|
-
|
|
14
|
-
replace_hits_data(hits)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def logger
|
|
18
|
-
Foreman::Logging.logger('background')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def query_insights_hits
|
|
24
|
-
hits_response = RestClient::Request.execute(
|
|
25
|
-
method: :get,
|
|
26
|
-
url: InsightsCloud.hits_export_url,
|
|
27
|
-
verify_ssl: ForemanRhCloud.verify_ssl_method,
|
|
28
|
-
proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
|
|
29
|
-
headers: {
|
|
30
|
-
Authorization: "Bearer #{rh_credentials}",
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
JSON.parse(hits_response)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def setup_host_names(host_names)
|
|
38
|
-
@host_ids = Hash[
|
|
39
|
-
Host.unscoped.where(name: host_names).pluck(:name, :id)
|
|
40
|
-
]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def host_id(host_name)
|
|
44
|
-
@host_ids[host_name]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def replace_hits_data(hits)
|
|
48
|
-
InsightsHit.transaction do
|
|
49
|
-
# create new facets for hosts that are missing one
|
|
50
|
-
hosts_with_existing_facets = InsightsFacet.where(host_id: @host_ids.values).pluck(:host_id)
|
|
51
|
-
InsightsFacet.create(
|
|
52
|
-
@host_ids.map do |host_name, host_id|
|
|
53
|
-
unless hosts_with_existing_facets.include?(host_id)
|
|
54
|
-
{
|
|
55
|
-
host_id: host_id,
|
|
56
|
-
uuid: @hits_host_names[host_name],
|
|
57
|
-
}
|
|
58
|
-
end
|
|
59
|
-
end.compact
|
|
60
|
-
)
|
|
61
|
-
InsightsHit.delete_all
|
|
62
|
-
InsightsHit.create(hits.map { |hits_hash| to_model_hash(hits_hash) }.compact)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def to_model_hash(hit_hash)
|
|
67
|
-
hit_host_id = host_id(hit_hash['hostname'])
|
|
68
|
-
|
|
69
|
-
return unless hit_host_id
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
host_id: hit_host_id,
|
|
73
|
-
last_seen: Time.parse(hit_hash['last_seen']),
|
|
74
|
-
publish_date: Time.parse(hit_hash['publish_date']),
|
|
75
|
-
title: hit_hash['title'],
|
|
76
|
-
solution_url: hit_hash['solution_url'],
|
|
77
|
-
total_risk: hit_hash['total_risk'].to_i,
|
|
78
|
-
likelihood: hit_hash['likelihood'].to_i,
|
|
79
|
-
results_url: hit_hash['results_url'],
|
|
80
|
-
}
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|