foreman_rh_cloud 3.0.14 → 3.0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/controllers/concerns/insights_cloud/candlepin_cache.rb +28 -0
- data/app/controllers/concerns/insights_cloud/client_authentication.rb +23 -0
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +3 -7
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +4 -54
- data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +26 -0
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +73 -0
- data/app/controllers/insights_cloud/hits_controller.rb +24 -0
- data/app/controllers/insights_cloud/settings_controller.rb +8 -0
- data/app/controllers/insights_cloud/tasks_controller.rb +6 -1
- data/app/models/insights_hit.rb +20 -1
- data/app/models/insights_resolution.rb +3 -0
- data/app/models/insights_rule.rb +3 -0
- data/app/models/setting/rh_cloud.rb +19 -7
- data/app/overrides/layouts/base/styles.html.erb.deface +2 -0
- data/app/services/foreman_rh_cloud/branch_info.rb +46 -0
- data/app/services/foreman_rh_cloud/cloud_connector.rb +65 -0
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +115 -0
- data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -4
- data/config/Gemfile.lock.gh_test +845 -0
- data/config/database.yml.example +17 -0
- data/config/package-lock.json.gh_test +35459 -0
- data/config/routes.rb +23 -8
- data/db/migrate/20210214000001_create_rules_and_resolutions.foreman_rh_cloud.rb +24 -0
- data/db/migrate/20210214000002_add_rule_id_to_hits.foreman_rh_cloud.rb +5 -0
- data/db/migrate/20210307000001_add_unique_to_insights_facet.foreman_rh_cloud.rb +11 -0
- data/lib/foreman_inventory_upload.rb +3 -2
- data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
- data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +17 -24
- data/lib/foreman_inventory_upload/generators/tags.rb +59 -0
- data/lib/foreman_rh_cloud.rb +13 -0
- data/lib/foreman_rh_cloud/engine.rb +16 -5
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud.rb +4 -0
- data/lib/insights_cloud/async/insights_full_sync.rb +29 -0
- data/lib/insights_cloud/async/insights_rules_sync.rb +80 -0
- data/lib/insights_cloud/async/rules_result.rb +13 -0
- data/lib/tasks/rh_cloud_inventory.rake +23 -0
- data/package.json +19 -18
- data/test/controllers/accounts_controller_test.rb +1 -5
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +119 -0
- data/test/controllers/uploads_controller_test.rb +0 -13
- data/test/controllers/uploads_settings_controller_test.rb +31 -0
- data/test/factories/insights_factories.rb +2 -1
- data/test/factories/inventory_upload_factories.rb +12 -0
- data/test/jobs/insights_full_sync_test.rb +17 -0
- data/test/jobs/insights_rules_sync_test.rb +198 -0
- data/test/test_plugin_helper.rb +13 -0
- data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +60 -0
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +141 -0
- data/test/unit/slice_generator_test.rb +36 -5
- data/test/unit/tags_generator_test.rb +60 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +9 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +10 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +2 -34
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +6 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +6 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +14 -12
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +10 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +36 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +44 -41
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +6 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +5 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +19 -34
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +3 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +0 -30
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +1 -23
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +9 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +9 -8
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +9 -35
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +31 -6
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +6 -6
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +4 -2
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +16 -14
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +30 -16
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +1 -21
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +8 -2
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +1 -17
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +4 -9
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +0 -12
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +7 -2
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +1 -1
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingActions.js +7 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingsConstants.js +26 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/index.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +9 -10
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.scss +18 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsActions.js +23 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsConstants.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +19 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +17 -5
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +16 -1
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -5
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +12 -18
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +31 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +53 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/{components/DocsButton/__tests__/DocsButton.test.js → __tests__/PageTitle.test.js} +3 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +13 -38
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +43 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +59 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js +6 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +19 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +22 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +56 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js +64 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +30 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +25 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +9 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +7 -9
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -4
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +5 -2
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +8 -6
- data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +9 -7
- data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +4 -2
- data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +7 -5
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +15 -13
- data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +27 -24
- data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +2 -2
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +8 -14
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +13 -8
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +3 -3
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +21 -9
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +3 -8
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +6 -4
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +7 -10
- data/webpack/ForemanRhCloudPages.js +19 -0
- data/webpack/InsightsCloudSync/Components/InsightsHeader/InsightsHeader.scss +4 -0
- data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +16 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +2 -2
- data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +125 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +154 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +56 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +39 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableReducer.js +28 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +78 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/SelectAllAlert.js +59 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +13 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js +48 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +58 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +155 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +132 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +89 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +104 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/components/EmptyState.js +53 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/index.js +45 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +11 -0
- data/webpack/InsightsCloudSync/Components/NoTokenEmptyState.js +79 -0
- data/webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js +10 -0
- data/webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js +19 -0
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +13 -0
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +214 -0
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +47 -44
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +11 -3
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +23 -20
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +16 -2
- data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +7 -0
- data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +2 -0
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +44 -61
- data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncActions.test.js +9 -0
- data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +11 -0
- data/webpack/InsightsCloudSync/index.js +11 -3
- data/webpack/InsightsHostDetailsTab/InsightsTab.js +2 -1
- data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +1 -1
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +2 -2
- data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +1 -0
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutSelectors.js +1 -0
- data/webpack/__mocks__/foremanReact/constants.js +19 -0
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +24 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +12 -0
- data/webpack/__mocks__/foremanReact/routes/RouterSelector.js +2 -0
- data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +10 -0
- data/webpack/common/Switcher/HelpLabel.js +30 -0
- data/webpack/common/Switcher/SwitcherPF4.js +36 -0
- data/webpack/common/Switcher/SwitcherPF4.scss +10 -0
- data/webpack/common/Switcher/__tests__/HelpLabel.test.js +13 -0
- data/webpack/common/Switcher/__tests__/SwitcherPF4.test.js +14 -0
- data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +20 -0
- data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +22 -0
- data/webpack/global_index.js +2 -0
- metadata +155 -72
- data/app/controllers/foreman_rh_cloud/react_controller.rb +0 -11
- data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +0 -1
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +0 -16
- 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 -36
- 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/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/components/DocsButton/DocsButton.js +0 -18
- 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 -12
- 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/pageHeader.scss +0 -3
- data/webpack/__mocks__/foremanReact/API.js +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72303b7bc3f1bc2deb3972acde6131cdbe4d1760381d1eb8cdaa5704e3189481
|
4
|
+
data.tar.gz: 725efab879cee6224007359547068820882319d078089760cac43a8c763df754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28d7e810476e8202a62aa7381e8d3ef86cec5f2f6a7bc9580d5a116a543275183201ad573e848f30a65253bee2f20e7b0385f0cc6f0ab90637cfb03398557188
|
7
|
+
data.tar.gz: 52560a0917aecaed1c9897c593769c19b7dde9348c1b0450cd32fb4998d5c63e4232d671a1b767e33e6dcec960b3f4647bc23d56a80f15c1f18930db8b772409
|
data/README.md
CHANGED
@@ -19,10 +19,23 @@ In UI: Configure -> Inventory Upload -> Restart
|
|
19
19
|
|
20
20
|
From command-line:
|
21
21
|
|
22
|
+
# generate and upload report for all organizations
|
23
|
+
/usr/sbin/foreman-rake rh_cloud_inventory:report:generate_upload
|
24
|
+
|
25
|
+
# generate and upload report for specific organization
|
26
|
+
export organization_id=1
|
27
|
+
/usr/sbin/foreman-rake rh_cloud_inventory:report:generate_upload
|
28
|
+
|
29
|
+
# generate report for specific organization (don't upload)
|
22
30
|
export organization_id=1
|
23
31
|
export target=/var/lib/foreman/red_hat_inventory/generated_reports/
|
24
32
|
/usr/sbin/foreman-rake rh_cloud_inventory:report:generate
|
25
33
|
|
34
|
+
# upload previously generated report (needs to be named 'report_for_#{organization_id}.tar.gz')
|
35
|
+
export organization_id=1
|
36
|
+
export target=/var/lib/foreman/red_hat_inventory/generated_reports/
|
37
|
+
/usr/sbin/foreman-rake rh_cloud_inventory:report:upload
|
38
|
+
|
26
39
|
#### Fetch hosts remediation data
|
27
40
|
|
28
41
|
In UI: Configure -> Insights -> Sync now
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module InsightsCloud
|
2
|
+
module CandlepinCache
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def upstream_owner(org)
|
6
|
+
# We use a cache because owner_details is a call to Candlepin
|
7
|
+
Rails.cache.fetch("rh_cloud_upstream_owner_#{org.id}", expires_in: 1.minute) do
|
8
|
+
org.owner_details['upstreamConsumer']
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def cp_owner_id(org)
|
13
|
+
owner = upstream_owner(org)
|
14
|
+
owner['uuid'] if owner
|
15
|
+
end
|
16
|
+
|
17
|
+
def candlepin_id_cert(org)
|
18
|
+
owner = upstream_owner(org)
|
19
|
+
return unless owner
|
20
|
+
id_cert = {
|
21
|
+
cert: owner.dig('idCert', 'cert'),
|
22
|
+
key: owner.dig('idCert', 'key'),
|
23
|
+
}
|
24
|
+
return unless id_cert.values.all?
|
25
|
+
id_cert
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module InsightsCloud
|
2
|
+
module ClientAuthentication
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
include ::Katello::Authentication::ClientAuthentication
|
6
|
+
|
7
|
+
def authorize
|
8
|
+
client_authorized? || super
|
9
|
+
end
|
10
|
+
|
11
|
+
def client_authorized?
|
12
|
+
authenticate_client && valid_machine_user?
|
13
|
+
end
|
14
|
+
|
15
|
+
def valid_machine_user?
|
16
|
+
subscribed_host_by_uuid(User.current.uuid).present?
|
17
|
+
end
|
18
|
+
|
19
|
+
def subscribed_host_by_uuid(uuid)
|
20
|
+
@host = Host.unscoped.joins(:subscription_facet).where(:katello_subscription_facets => {:uuid => uuid }).first
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -10,23 +10,19 @@ module ForemanInventoryUpload
|
|
10
10
|
upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
|
11
11
|
|
12
12
|
[
|
13
|
-
|
13
|
+
label,
|
14
14
|
{
|
15
15
|
generate_report_status: generate_report_status,
|
16
16
|
upload_report_status: upload_report_status,
|
17
|
-
|
17
|
+
id: id,
|
18
18
|
},
|
19
19
|
]
|
20
20
|
end
|
21
21
|
]
|
22
22
|
|
23
23
|
render json: {
|
24
|
-
autoUploadEnabled: Setting[:allow_auto_inventory_upload],
|
25
|
-
hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
|
26
|
-
ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
|
27
|
-
cloudToken: Setting[:rh_cloud_token],
|
28
|
-
excludePackages: Setting[:exclude_installed_packages],
|
29
24
|
accounts: accounts,
|
25
|
+
CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
|
30
26
|
}, status: :ok
|
31
27
|
end
|
32
28
|
|
@@ -14,62 +14,12 @@ module ForemanInventoryUpload
|
|
14
14
|
files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]
|
15
15
|
|
16
16
|
return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
|
17
|
-
|
17
|
+
raise ::Foreman::Exception.new("The report file doesn't exist")
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
:error_msg => message
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def auto_upload
|
28
|
-
Setting[:allow_auto_inventory_upload] = auto_upload_params
|
29
|
-
render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
|
30
|
-
end
|
31
|
-
|
32
|
-
def show_auto_upload
|
33
|
-
render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
|
34
|
-
end
|
35
|
-
|
36
|
-
def auto_upload_params
|
37
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
38
|
-
end
|
39
|
-
|
40
|
-
def host_obfuscation
|
41
|
-
Setting[:obfuscate_inventory_hostnames] = host_obfuscation_params
|
42
|
-
render_setting(:hostObfuscationEnabled, :obfuscate_inventory_hostnames)
|
43
|
-
end
|
44
|
-
|
45
|
-
def host_obfuscation_params
|
46
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
47
|
-
end
|
48
|
-
|
49
|
-
def installed_packages_inclusion
|
50
|
-
Setting[:exclude_installed_packages] = host_obfuscation_params
|
51
|
-
render_setting(:excludePackages, :exclude_installed_packages)
|
52
|
-
end
|
53
|
-
|
54
|
-
def installed_packages_inclusion_params
|
55
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
56
|
-
end
|
57
|
-
|
58
|
-
def ips_obfuscation
|
59
|
-
Setting[:obfuscate_inventory_ips] = ips_obfuscation_params
|
60
|
-
render_setting(:ipsObfuscationEnabled, :obfuscate_inventory_ips)
|
61
|
-
end
|
62
|
-
|
63
|
-
def ips_obfuscation_params
|
64
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def render_setting(node_name, setting)
|
70
|
-
render json: {
|
71
|
-
node_name => Setting[setting],
|
72
|
-
}
|
20
|
+
def enable_cloud_connector
|
21
|
+
cloud_connector = ForemanRhCloud::CloudConnector.new
|
22
|
+
render json: cloud_connector.install.to_json
|
73
23
|
end
|
74
24
|
end
|
75
25
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
class UploadsSettingsController < ::ApplicationController
|
3
|
+
def index
|
4
|
+
render json: {
|
5
|
+
autoUploadEnabled: Setting[:allow_auto_inventory_upload],
|
6
|
+
hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
|
7
|
+
ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
|
8
|
+
excludePackagesEnabled: Setting[:exclude_installed_packages],
|
9
|
+
CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
|
10
|
+
cloudToken: !Setting[:rh_cloud_token].empty?,
|
11
|
+
}, status: :ok
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_advanced_setting
|
15
|
+
Setting[params.require(:setting)] = ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
16
|
+
index
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.cloud_connector_status
|
20
|
+
cloud_connector = ForemanRhCloud::CloudConnector.new
|
21
|
+
job = cloud_connector&.latest_job
|
22
|
+
return nil unless job
|
23
|
+
{ id: job.id, task: ForemanTasks::Task.where(:id => job.task_id).first }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module InsightsCloud::Api
|
2
|
+
class MachineTelemetriesController < ::Api::V2::BaseController
|
3
|
+
layout false
|
4
|
+
|
5
|
+
include ::InsightsCloud::ClientAuthentication
|
6
|
+
include ::InsightsCloud::CandlepinCache
|
7
|
+
|
8
|
+
before_action :cert_uuid, :ensure_org, :ensure_branch_id, :only => [:forward_request, :branch_info]
|
9
|
+
before_action :ensure_telemetry_enabled_for_consumer, :only => [:forward_request]
|
10
|
+
|
11
|
+
skip_after_action :log_response_body, :only => [:forward_request]
|
12
|
+
skip_before_action :check_media_type, :only => [:forward_request]
|
13
|
+
|
14
|
+
# The method that "proxies" requests over to Cloud
|
15
|
+
def forward_request
|
16
|
+
certs = candlepin_id_cert @organization
|
17
|
+
cloud_response = ::ForemanRhCloud::CloudRequestForwarder.new.forward_request(request, controller_name, @branch_id, certs)
|
18
|
+
|
19
|
+
if cloud_response.code == 401
|
20
|
+
return render json: {
|
21
|
+
:message => 'Authentication to the Insights Service failed.',
|
22
|
+
:headers => {},
|
23
|
+
}, status: :bad_gateway
|
24
|
+
end
|
25
|
+
|
26
|
+
if cloud_response.headers[:content_disposition]
|
27
|
+
return send_data cloud_response, disposition: cloud_response.headers[:content_disposition], type: cloud_response.headers[:content_type]
|
28
|
+
end
|
29
|
+
|
30
|
+
assign_header(response, cloud_response, :x_resource_count, true)
|
31
|
+
assign_header(response, cloud_response, :x_rh_insights_request_id, false)
|
32
|
+
|
33
|
+
render json: cloud_response, status: cloud_response.code
|
34
|
+
end
|
35
|
+
|
36
|
+
def branch_info
|
37
|
+
render :json => ForemanRhCloud::BranchInfo.new.generate(@uuid, @host, @branch_id, request.host).to_json
|
38
|
+
end
|
39
|
+
|
40
|
+
def assign_header(res, cloud_res, header, transform)
|
41
|
+
header_content = cloud_res.headers[header]
|
42
|
+
return unless header_content
|
43
|
+
new_header = transform ? header.to_s.tr('_', '-') : header.to_s
|
44
|
+
res.headers[new_header] = header_content
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def ensure_telemetry_enabled_for_consumer
|
50
|
+
render_message 'Telemetry is not enabled for your organization', :status => 403 unless telemetry_config
|
51
|
+
end
|
52
|
+
|
53
|
+
def telemetry_config
|
54
|
+
::RedhatAccess::TelemetryConfiguration.find_or_create_by(:organization_id => @organization.id) do |conf|
|
55
|
+
conf.enable_telemetry = true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def cert_uuid
|
60
|
+
@uuid ||= User.current.login
|
61
|
+
end
|
62
|
+
|
63
|
+
def ensure_org
|
64
|
+
@organization = @host.organization
|
65
|
+
return render_message 'Organization not found or invalid', :status => 400 unless @organization
|
66
|
+
end
|
67
|
+
|
68
|
+
def ensure_branch_id
|
69
|
+
@branch_id = cp_owner_id(@organization)
|
70
|
+
return render_message "Branch ID not found for organization #{@organization.title}", :status => 400 unless @branch_id
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,6 +1,18 @@
|
|
1
1
|
module InsightsCloud
|
2
2
|
class HitsController < ::ApplicationController
|
3
|
+
include Foreman::Controller::AutoCompleteSearch
|
4
|
+
|
3
5
|
def index
|
6
|
+
hits = resource_base_search_and_page.where(host: Host.authorized).preload(:host, :rule)
|
7
|
+
|
8
|
+
render json: {
|
9
|
+
hasToken: !Setting[:rh_cloud_token].empty?,
|
10
|
+
hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, has_playbook: hit.has_playbook?) },
|
11
|
+
itemCount: hits.count,
|
12
|
+
}, status: :ok
|
13
|
+
end
|
14
|
+
|
15
|
+
def show
|
4
16
|
host = Host.where(id: host_id_param).first
|
5
17
|
|
6
18
|
render json: {
|
@@ -8,6 +20,18 @@ module InsightsCloud
|
|
8
20
|
}, status: :ok
|
9
21
|
end
|
10
22
|
|
23
|
+
def model_of_controller
|
24
|
+
::InsightsHit
|
25
|
+
end
|
26
|
+
|
27
|
+
def resource_class
|
28
|
+
::InsightsHit
|
29
|
+
end
|
30
|
+
|
31
|
+
def controller_permission
|
32
|
+
:insights_hits
|
33
|
+
end
|
34
|
+
|
11
35
|
private
|
12
36
|
|
13
37
|
def host_id_param
|
@@ -9,6 +9,14 @@ module InsightsCloud
|
|
9
9
|
render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
|
10
10
|
end
|
11
11
|
|
12
|
+
def save_token_and_sync
|
13
|
+
token = Setting::RhCloud.find_by_name("rh_cloud_token")
|
14
|
+
token.value = params.require(:value)
|
15
|
+
token.save!
|
16
|
+
InsightsCloud::Async::InsightsFullSync.perform_now
|
17
|
+
redirect_to(:controller => "hits", :action => 'index')
|
18
|
+
end
|
19
|
+
|
12
20
|
private
|
13
21
|
|
14
22
|
def render_setting(node_name, setting)
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module InsightsCloud
|
2
2
|
class TasksController < ::ApplicationController
|
3
3
|
def create
|
4
|
-
InsightsCloud::Async::InsightsFullSync.
|
4
|
+
job = InsightsCloud::Async::InsightsFullSync.perform_later
|
5
|
+
task = ForemanTasks::Task.find_by(external_id: job.provider_job_id)
|
6
|
+
|
7
|
+
render json: {
|
8
|
+
task: task,
|
9
|
+
}, status: :ok
|
5
10
|
end
|
6
11
|
end
|
7
12
|
end
|
data/app/models/insights_hit.rb
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
class InsightsHit < ApplicationRecord
|
2
|
-
|
2
|
+
include ::Authorizable
|
3
|
+
belongs_to :host
|
3
4
|
# since the facet is one-to-one association with a host, we can connect
|
4
5
|
# through host_id column on both this model and facet.
|
5
6
|
belongs_to :insights_facet, foreign_key: 'host_id', primary_key: 'host_id', counter_cache: :hits_count
|
7
|
+
|
8
|
+
has_one :rule, class_name: 'InsightsRule', foreign_key: 'rule_id', primary_key: 'rule_id'
|
9
|
+
|
10
|
+
scope :with_playbook, -> { joins(:rule) }
|
11
|
+
|
12
|
+
scoped_search on: :title, complete_value: true
|
13
|
+
scoped_search on: :total_risk, complete_value: true
|
14
|
+
scoped_search on: :rule_id, complete_value: true, only_explicit: true
|
15
|
+
scoped_search relation: :host, on: :name, rename: :hostname, complete_value: true
|
16
|
+
scoped_search on: :rule_id, rename: :with_playbook, only_explicit: true, complete_value: false, ext_method: :find_with_playbook
|
17
|
+
|
18
|
+
def self.find_with_playbook(key, operator, value)
|
19
|
+
{ joins: :rule }
|
20
|
+
end
|
21
|
+
|
22
|
+
def has_playbook?
|
23
|
+
!rule.nil?
|
24
|
+
end
|
6
25
|
end
|
@@ -1,14 +1,26 @@
|
|
1
1
|
class Setting::RhCloud < Setting
|
2
|
+
::Setting::BLANK_ATTRS.concat %w{rh_cloud_token}
|
3
|
+
|
4
|
+
def self.load_defaults
|
5
|
+
return false unless table_exists?
|
6
|
+
transaction do
|
7
|
+
# If the user had auto_upload default setting, we will not surprise him, and force the value to false
|
8
|
+
# for new users, the default will be set to true and the value will remain nil
|
9
|
+
Setting.where(name: 'allow_auto_inventory_upload', value: nil).where("settings.default LIKE '%false%'").update_all(value: "--- false\n...")
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
2
14
|
def self.default_settings
|
3
15
|
return unless ActiveRecord::Base.connection.table_exists?('settings')
|
4
|
-
return unless super
|
5
16
|
[
|
6
|
-
set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'),
|
7
|
-
set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false),
|
8
|
-
set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false),
|
9
|
-
set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false),
|
10
|
-
set('rh_cloud_token', N_('Authentication token to Red Hat cloud services. Used to authenticate requests to cloud APIs'),
|
11
|
-
set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false),
|
17
|
+
set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), true, N_('Allow automatic inventory uploads')),
|
18
|
+
set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false, N_('Allow recommendations synchronization')),
|
19
|
+
set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false, N_('Obfuscate host names')),
|
20
|
+
set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false, N_('Obfuscate IPs')),
|
21
|
+
set('rh_cloud_token', N_('Authentication token to Red Hat cloud services. Used to authenticate requests to cloud APIs'), nil, N_('Red Hat Cloud token'), nil, encrypted: true),
|
22
|
+
set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false, N_("Don't upload installed packages")),
|
23
|
+
set('include_parameter_tags', N_('Should import include parameter tags from Foreman?'), false, N_('Include parameters in insights-client reports')),
|
12
24
|
]
|
13
25
|
end
|
14
26
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ForemanRhCloud
|
2
|
+
class BranchInfo
|
3
|
+
def generate(uuid, host, branch_id, request_hostname)
|
4
|
+
{
|
5
|
+
:remote_leaf => uuid,
|
6
|
+
:remote_branch => branch_id,
|
7
|
+
:display_name => host.organization.name,
|
8
|
+
:hostname => request_hostname,
|
9
|
+
:product => {
|
10
|
+
:type => core_app_name,
|
11
|
+
:major_version => core_app_version.major,
|
12
|
+
:minor_version => core_app_version.minor,
|
13
|
+
},
|
14
|
+
:organization_id => host.organization.id,
|
15
|
+
:satellite_instance_id => Foreman.instance_id,
|
16
|
+
:labels => host_labels(host),
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def core_app_name
|
21
|
+
'Foreman'
|
22
|
+
end
|
23
|
+
|
24
|
+
def core_app_version
|
25
|
+
Foreman::Version.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def new_label(key, value, namespace)
|
29
|
+
{
|
30
|
+
:namespace => namespace,
|
31
|
+
:key => key,
|
32
|
+
:value => value,
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def labels_from_items(items, label_namespace, label_lamb, label_value_method = :to_s)
|
37
|
+
items.map { |item| new_label(label_lamb.call(item), item.public_send(label_value_method), label_namespace) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def host_labels(host)
|
41
|
+
tags_generator = ForemanInventoryUpload::Generators::Tags.new(host)
|
42
|
+
tags_generator.generate.map { |key, value| new_label(key, value, ForemanInventoryUpload::Generators::Slice::SATELLITE_NAMESPACE) } +
|
43
|
+
tags_generator.generate_parameters.map { |key, value| new_label(key, value, ForemanInventoryUpload::Generators::Slice::SATELLITE_PARAMS_NAMESPACE) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|