foreman_rh_cloud 0.9.5 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +4 -6
- data/app/controllers/foreman_inventory_upload/tasks_controller.rb +25 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +22 -3
- data/app/controllers/foreman_rh_cloud/react_controller.rb +11 -0
- data/app/controllers/insights_cloud/settings_controller.rb +24 -0
- data/app/controllers/insights_cloud/tasks_controller.rb +7 -0
- data/app/helpers/foreman_inventory_upload_host_helper.rb +20 -0
- data/app/models/insights_facet.rb +7 -0
- data/app/models/insights_hit.rb +6 -0
- data/app/models/inventory_sync/inventory_status.rb +30 -0
- data/app/models/setting/rh_cloud.rb +4 -1
- data/app/overrides/hosts_list.rb +13 -0
- data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +6 -0
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -0
- data/app/views/{foreman_inventory_upload/layouts/react.html.erb → layouts/foreman_rh_cloud/application.html.erb} +2 -2
- data/config/routes.rb +14 -1
- data/db/migrate/20191215104806_create_insights_hits.foreman_inventory_upload.rb +14 -0
- data/db/migrate/20191216062008_create_insights_facets.foreman_inventory_upload.rb +7 -0
- data/db/migrate/20200727111529_add_uuid_column_to_insights_facets.foreman_rh_cloud.rb +5 -0
- data/lib/foreman_inventory_upload.rb +4 -0
- data/lib/foreman_inventory_upload/async/async_helpers.rb +13 -0
- data/lib/foreman_inventory_upload/async/shell_process.rb +3 -1
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +56 -0
- data/lib/foreman_inventory_upload/generators/json_stream.rb +10 -0
- data/lib/foreman_inventory_upload/generators/queries.rb +6 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +54 -22
- data/lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb +19 -0
- data/lib/foreman_rh_cloud.rb +13 -0
- data/lib/foreman_rh_cloud/engine.rb +32 -5
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud.rb +15 -0
- data/lib/insights_cloud/async/insights_full_sync.rb +103 -0
- data/lib/insights_cloud/async/insights_scheduled_sync.rb +23 -0
- data/lib/inventory_sync/async/host_result.rb +50 -0
- data/lib/inventory_sync/async/inventory_full_sync.rb +99 -0
- data/test/controllers/insights_sync/settings_controller_test.rb +30 -0
- data/test/factories/insights_factories.rb +31 -0
- data/test/jobs/insights_full_sync_test.rb +94 -0
- data/test/jobs/inventory_full_sync_test.rb +91 -0
- data/test/unit/archived_report_generator_test.rb +1 -0
- data/test/unit/fact_helpers_test.rb +29 -0
- data/test/unit/insights_facet_test.rb +16 -0
- data/test/unit/slice_generator_test.rb +252 -25
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +14 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +13 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +6 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +10 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +11 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +10 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js +15 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +7 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +1 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +8 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +12 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +12 -8
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +2 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +21 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +3 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +6 -6
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +4 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +9 -9
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +4 -3
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +2 -3
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +3 -2
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +5 -1
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +15 -13
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +30 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcher.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +38 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +14 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/hostObfuscationSwitcher.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/index.js +20 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +26 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +39 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js +7 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +35 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +37 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +17 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +28 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +15 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettings.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +13 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/inventorySettings.scss +15 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +25 -6
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +33 -5
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/DocsButton.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +21 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +19 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +22 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +24 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js +11 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +17 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +52 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +59 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +33 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +36 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +63 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +41 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +20 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +22 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +15 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +12 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +12 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +3 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +9 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +12 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +16 -8
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +6 -4
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +34 -0
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +12 -0
- data/webpack/ForemanInventoryUpload/{ForemanInventoryUpload.test.js → __tests__/ForemanInventoryUpload.test.js} +1 -1
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +5 -0
- data/webpack/ForemanInventoryUpload/{__snapshots__ → __tests__/__snapshots__}/ForemanInventoryUpload.test.js.snap +0 -0
- data/webpack/ForemanRhCloudHelpers.js +6 -0
- data/webpack/ForemanRhCloudPages.js +7 -0
- data/webpack/ForemanRhCloudReducers.js +10 -0
- data/webpack/ForemanRhCloudSelectors.js +5 -0
- data/webpack/ForemanRhCloudTestHelpers.js +15 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +33 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +60 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +10 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +28 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsSelectors.js +6 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +18 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +46 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +56 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +21 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +15 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +31 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +33 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +9 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/index.js +21 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +16 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +45 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +17 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +38 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +3 -0
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +59 -0
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +16 -0
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +23 -0
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +6 -0
- data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +3 -0
- data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +8 -0
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +65 -0
- data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncHelpers.test.js +11 -0
- data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncHelpers.test.js.snap +3 -0
- data/webpack/InsightsCloudSync/index.js +18 -0
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +1 -0
- data/webpack/__mocks__/foremanReact/constants.js +5 -0
- data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +11 -0
- data/webpack/__tests__/ForemanRhCloudSelectors.test.js +22 -0
- data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +20 -0
- data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +3 -0
- data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +24 -0
- data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +36 -0
- data/webpack/index.js +3 -6
- data/webpack/subscriptions_extension_index.js +8 -0
- metadata +166 -7
- data/app/controllers/foreman_inventory_upload/react_controller.rb +0 -7
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +0 -4
@@ -19,6 +19,12 @@ module ForemanInventoryUpload
|
|
19
19
|
'lscpu::flags',
|
20
20
|
'distribution::version',
|
21
21
|
'distribution::id',
|
22
|
+
'virt::is_guest',
|
23
|
+
'dmi::system::manufacturer',
|
24
|
+
'dmi::system::product_name',
|
25
|
+
'dmi::chassis::asset_tag',
|
26
|
+
'insights_client::obfuscate_hostname_enabled',
|
27
|
+
'insights_client::hostname',
|
22
28
|
]).pluck(:name, :id)
|
23
29
|
]
|
24
30
|
end
|
@@ -3,6 +3,8 @@ module ForemanInventoryUpload
|
|
3
3
|
class Slice
|
4
4
|
include FactHelpers
|
5
5
|
|
6
|
+
SATELLITE_NAMESPACE = 'satellite'
|
7
|
+
|
6
8
|
attr_accessor :slice_id
|
7
9
|
attr_reader :hosts_count
|
8
10
|
|
@@ -26,7 +28,7 @@ module ForemanInventoryUpload
|
|
26
28
|
@stream.array_field('hosts', :last) do
|
27
29
|
first = true
|
28
30
|
hosts_batch.each do |host|
|
29
|
-
next unless host&.subscription_facet
|
31
|
+
next unless host&.subscription_facet
|
30
32
|
@stream.comma unless first
|
31
33
|
if report_host(host)
|
32
34
|
first = false
|
@@ -39,29 +41,20 @@ module ForemanInventoryUpload
|
|
39
41
|
|
40
42
|
def report_host(host)
|
41
43
|
@stream.object do
|
42
|
-
@stream.simple_field('
|
43
|
-
@stream.simple_field('
|
44
|
-
@stream.simple_field('
|
45
|
-
@stream.simple_field('
|
46
|
-
@stream.simple_field('satellite_id', host.subscription_facet.uuid)
|
44
|
+
@stream.simple_field('fqdn', fqdn(host))
|
45
|
+
@stream.simple_field('account', account_id(host.organization).to_s)
|
46
|
+
@stream.simple_field('subscription_manager_id', host.subscription_facet&.uuid)
|
47
|
+
@stream.simple_field('satellite_id', host.subscription_facet&.uuid)
|
47
48
|
@stream.simple_field('bios_uuid', fact_value(host, 'dmi::system::uuid'))
|
48
49
|
@stream.simple_field('vm_uuid', fact_value(host, 'virt::uuid'))
|
49
|
-
|
50
|
-
|
51
|
-
@stream.stringify_value(nic.ip) if nic.ip
|
52
|
-
end.compact.join(', '))
|
53
|
-
end
|
54
|
-
@stream.array_field('mac_addresses') do
|
55
|
-
@stream.raw(host.interfaces.map do |nic|
|
56
|
-
@stream.stringify_value(nic.mac) if nic.mac
|
57
|
-
end.compact.join(', '))
|
58
|
-
end
|
50
|
+
report_ip_addresses(host)
|
51
|
+
report_mac_addresses(host)
|
59
52
|
@stream.object_field('system_profile') do
|
60
53
|
report_system_profile(host)
|
61
54
|
end
|
62
55
|
@stream.array_field('facts') do
|
63
56
|
@stream.object do
|
64
|
-
@stream.simple_field('namespace',
|
57
|
+
@stream.simple_field('namespace', SATELLITE_NAMESPACE)
|
65
58
|
@stream.object_field('facts', :last) do
|
66
59
|
report_satellite_facts(host)
|
67
60
|
end
|
@@ -69,8 +62,15 @@ module ForemanInventoryUpload
|
|
69
62
|
end
|
70
63
|
|
71
64
|
@stream.array_field('tags', :last) do
|
72
|
-
|
73
|
-
|
65
|
+
report_satellite_tag('satellite_instance_id', Foreman.instance_id) if Foreman.respond_to?(:instance_id)
|
66
|
+
report_satellite_tag('lifecycle_environment', host.lifecycle_environment&.name)
|
67
|
+
report_satellite_tag('content_view', host.content_view&.name)
|
68
|
+
report_satellite_tag('activation_key', host.activation_keys) { |key| key.name }
|
69
|
+
report_satellite_tag('host_collection', host.host_collections) { |collection| collection.name }
|
70
|
+
report_satellite_tag('location', host.location.name)
|
71
|
+
report_satellite_tag('organization', host.organization.name)
|
72
|
+
report_satellite_tag('hostgroup', host.hostgroup&.name)
|
73
|
+
report_satellite_tag('organization_id', host.organization_id.to_s, :last)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -84,6 +84,18 @@ module ForemanInventoryUpload
|
|
84
84
|
@stream.comma unless last
|
85
85
|
end
|
86
86
|
|
87
|
+
def report_satellite_tag(key, value, last = nil)
|
88
|
+
return if value.nil?
|
89
|
+
|
90
|
+
array_value = Array(value)
|
91
|
+
last_index = array_value.count - 1
|
92
|
+
|
93
|
+
array_value.each_with_index do |value, index|
|
94
|
+
value = yield(value) if block_given?
|
95
|
+
report_tag(SATELLITE_NAMESPACE, key, value, last && index == last_index)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
87
99
|
def report_system_profile(host)
|
88
100
|
@stream.simple_field('number_of_cpus', fact_value(host, 'cpu::cpu(s)').to_i)
|
89
101
|
@stream.simple_field('number_of_sockets', fact_value(host, 'cpu::cpu_socket(s)').to_i)
|
@@ -123,6 +135,11 @@ module ForemanInventoryUpload
|
|
123
135
|
@stream.simple_field('subscription_status', host.subscription_status_label)
|
124
136
|
@stream.simple_field('katello_agent_running', host.content_facet&.katello_agent_installed?)
|
125
137
|
@stream.simple_field('satellite_managed', true)
|
138
|
+
@stream.simple_field(
|
139
|
+
'infrastructure_type',
|
140
|
+
ActiveModel::Type::Boolean.new.cast(fact_value(host, 'virt::is_guest')) ? 'virtual' : 'physical'
|
141
|
+
)
|
142
|
+
@stream.simple_field('cloud_provider', cloud_provider(host))
|
126
143
|
unless (installed_products = host.subscription_facet&.installed_products).empty?
|
127
144
|
@stream.array_field('installed_products') do
|
128
145
|
@stream.raw(installed_products.map do |product|
|
@@ -143,18 +160,33 @@ module ForemanInventoryUpload
|
|
143
160
|
end
|
144
161
|
|
145
162
|
def report_satellite_facts(host)
|
146
|
-
@stream.simple_field('virtual_host_name', host.subscription_facet
|
147
|
-
@stream.simple_field('virtual_host_uuid', host.subscription_facet
|
163
|
+
@stream.simple_field('virtual_host_name', host.subscription_facet&.hypervisor_host&.name)
|
164
|
+
@stream.simple_field('virtual_host_uuid', host.subscription_facet&.hypervisor_host&.subscription_facet&.uuid)
|
148
165
|
if defined?(ForemanThemeSatellite)
|
149
166
|
@stream.simple_field('satellite_version', ForemanThemeSatellite::SATELLITE_VERSION)
|
150
167
|
end
|
151
168
|
@stream.simple_field('system_purpose_usage', host.subscription_facet.purpose_usage)
|
152
169
|
@stream.simple_field('system_purpose_role', host.subscription_facet.purpose_role)
|
170
|
+
@stream.simple_field('system_purpose_sla', host.subscription_facet.service_level)
|
153
171
|
@stream.simple_field('distribution_version', fact_value(host, 'distribution::version'))
|
154
|
-
@stream.simple_field('satellite_instance_id', Foreman.
|
172
|
+
@stream.simple_field('satellite_instance_id', Foreman.try(:instance_id))
|
173
|
+
@stream.simple_field('is_simple_content_access', golden_ticket?(host.organization))
|
174
|
+
@stream.simple_field('is_hostname_obfuscated', !!obfuscate_hostname?(host))
|
155
175
|
@stream.simple_field('organization_id', host.organization_id, :last)
|
156
176
|
end
|
157
177
|
|
178
|
+
def report_ip_addresses(host)
|
179
|
+
ip_addresses = host.interfaces.map { |nic| nic.ip }.compact
|
180
|
+
|
181
|
+
@stream.string_array_value('ip_addresses', ip_addresses)
|
182
|
+
end
|
183
|
+
|
184
|
+
def report_mac_addresses(host)
|
185
|
+
macs = host.interfaces.map { |nic| nic.mac }.compact
|
186
|
+
|
187
|
+
@stream.string_array_value('mac_addresses', macs)
|
188
|
+
end
|
189
|
+
|
158
190
|
def os_release_value(name:, version:, codename:)
|
159
191
|
"#{name} #{version} (#{codename})"
|
160
192
|
end
|
data/lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb
ADDED
@@ -0,0 +1,19 @@
|
|
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/foreman_rh_cloud.rb
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
require 'foreman_rh_cloud/engine.rb'
|
2
2
|
|
3
3
|
module ForemanRhCloud
|
4
|
+
def self.base_url
|
5
|
+
# for testing set ENV to 'https://ci.cloud.redhat.com'
|
6
|
+
@base_url ||= ENV['SATELLITE_RH_CLOUD_URL'] || 'https://cloud.redhat.com'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.authentication_url
|
10
|
+
# https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
|
11
|
+
@authentication_url ||= ENV['SATELLITE_RH_CLOUD_SSO_URL'] || 'https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.verify_ssl_method
|
15
|
+
@verify_ssl_method ||= ENV['SATELLITE_RH_CLOUD_URL'] ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
|
16
|
+
end
|
4
17
|
end
|
@@ -30,23 +30,50 @@ module ForemanRhCloud
|
|
30
30
|
|
31
31
|
# Add permissions
|
32
32
|
security_block :foreman_rh_cloud do
|
33
|
-
permission
|
33
|
+
permission(
|
34
|
+
:generate_foreman_rh_cloud,
|
35
|
+
'foreman_inventory_upload/reports': [:generate]
|
36
|
+
)
|
37
|
+
permission(
|
38
|
+
:view_foreman_rh_cloud,
|
39
|
+
'foreman_inventory_upload/accounts': [:index],
|
40
|
+
'foreman_inventory_upload/reports': [:last],
|
41
|
+
'foreman_inventory_upload/uploads': [:auto_upload, :show_auto_upload, :download_file, :last],
|
42
|
+
'foreman_rh_cloud/react': [:inventory_upload]
|
43
|
+
)
|
34
44
|
end
|
35
45
|
|
36
|
-
|
37
|
-
|
46
|
+
plugin_permissions = [:view_foreman_rh_cloud, :generate_foreman_rh_cloud]
|
47
|
+
|
48
|
+
role 'ForemanRhCloud', plugin_permissions, 'Role granting permissions to view the hosts inventory,
|
49
|
+
generate a report, upload it to the cloud and download it locally'
|
50
|
+
|
51
|
+
add_permissions_to_default_roles Role::ORG_ADMIN => plugin_permissions,
|
52
|
+
Role::MANAGER => plugin_permissions,
|
53
|
+
Role::SYSTEM_ADMIN => plugin_permissions
|
38
54
|
|
39
55
|
# Adding a sub menu after hosts menu
|
40
|
-
|
41
|
-
|
56
|
+
divider :top_menu, caption: N_('RH Cloud'), parent: :configure_menu
|
57
|
+
menu :top_menu, :inventory_upload, :caption => N_('Inventory Upload'), :url_hash => { controller: :'foreman_rh_cloud/react', :action => :inventory_upload}, parent: :configure_menu
|
58
|
+
menu :top_menu, :insights_hits_import, :caption => N_('Insights'), :url_hash => { controller: :'foreman_rh_cloud/react', :action => :insights_cloud }, parent: :configure_menu
|
59
|
+
|
60
|
+
register_facet InsightsFacet, :insights do
|
61
|
+
set_dependent_action :destroy
|
42
62
|
end
|
63
|
+
|
64
|
+
register_global_js_file 'subscriptions_extension'
|
65
|
+
|
66
|
+
register_custom_status(InventorySync::InventoryStatus)
|
43
67
|
end
|
68
|
+
|
69
|
+
::Katello::UINotifications::Subscriptions::ManifestImportSuccess.include ForemanInventoryUpload::Notifications::ManifestImportSuccessNotificationOverride if defined?(Katello)
|
44
70
|
end
|
45
71
|
|
46
72
|
initializer "foreman_rh_cloud.set_dynflow.config.on_init", :before => :finisher_hook do |_app|
|
47
73
|
unless Rails.env.test?
|
48
74
|
ForemanTasks.dynflow.config.on_init do |world|
|
49
75
|
ForemanInventoryUpload::Async::GenerateAllReportsJob.spawn_if_missing(world)
|
76
|
+
InsightsCloud::Async::InsightsScheduledSync.spawn_if_missing(world)
|
50
77
|
end
|
51
78
|
end
|
52
79
|
end
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
|
3
|
+
module InsightsCloud
|
4
|
+
module Async
|
5
|
+
class InsightsFullSync < ::ApplicationJob
|
6
|
+
def perform
|
7
|
+
hits = query_insights_hits
|
8
|
+
|
9
|
+
@hits_host_names = Hash[hits.map { |hit| [hit['hostname'], hit['uuid']] }]
|
10
|
+
setup_host_names(@hits_host_names.keys)
|
11
|
+
|
12
|
+
replace_hits_data(hits)
|
13
|
+
end
|
14
|
+
|
15
|
+
def logger
|
16
|
+
Foreman::Logging.logger('background')
|
17
|
+
end
|
18
|
+
|
19
|
+
def rh_credentials
|
20
|
+
@rh_credentials ||= query_refresh_token
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def query_insights_hits
|
26
|
+
hits_response = RestClient::Request.execute(
|
27
|
+
method: :get,
|
28
|
+
url: InsightsCloud.hits_export_url,
|
29
|
+
verify_ssl: ForemanRhCloud.verify_ssl_method,
|
30
|
+
headers: {
|
31
|
+
Authorization: "Bearer #{rh_credentials}",
|
32
|
+
}
|
33
|
+
)
|
34
|
+
|
35
|
+
JSON.parse(hits_response)
|
36
|
+
end
|
37
|
+
|
38
|
+
def query_refresh_token
|
39
|
+
token_response = RestClient::Request.execute(
|
40
|
+
method: :post,
|
41
|
+
url: ForemanRhCloud.authentication_url,
|
42
|
+
verify_ssl: ForemanRhCloud.verify_ssl_method,
|
43
|
+
payload: {
|
44
|
+
grant_type: 'refresh_token',
|
45
|
+
client_id: 'rhsm-api',
|
46
|
+
refresh_token: Setting[:rh_cloud_token],
|
47
|
+
}
|
48
|
+
)
|
49
|
+
|
50
|
+
JSON.parse(token_response)['access_token']
|
51
|
+
rescue RestClient::ExceptionWithResponse => e
|
52
|
+
Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
|
53
|
+
raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup_host_names(host_names)
|
57
|
+
@host_ids = Hash[
|
58
|
+
Host.unscoped.where(name: host_names).pluck(:name, :id)
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
def host_id(host_name)
|
63
|
+
@host_ids[host_name]
|
64
|
+
end
|
65
|
+
|
66
|
+
def replace_hits_data(hits)
|
67
|
+
InsightsHit.transaction do
|
68
|
+
InsightsHit.delete_all
|
69
|
+
InsightsHit.create(hits.map { |hits_hash| to_model_hash(hits_hash) }.compact)
|
70
|
+
# create new facets for hosts that are missing one
|
71
|
+
hosts_with_existing_facets = InsightsFacet.where(host_id: @host_ids.values).pluck(:host_id)
|
72
|
+
InsightsFacet.create(
|
73
|
+
@host_ids.map do |host_name, host_id|
|
74
|
+
unless hosts_with_existing_facets.include?(host_id)
|
75
|
+
{
|
76
|
+
host_id: host_id,
|
77
|
+
uuid: @hits_host_names[host_name],
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end.compact
|
81
|
+
)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def to_model_hash(hit_hash)
|
86
|
+
hit_host_id = host_id(hit_hash['hostname'])
|
87
|
+
|
88
|
+
return unless hit_host_id
|
89
|
+
|
90
|
+
{
|
91
|
+
host_id: hit_host_id,
|
92
|
+
last_seen: Time.parse(hit_hash['last_seen']),
|
93
|
+
publish_date: Time.parse(hit_hash['publish_date']),
|
94
|
+
title: hit_hash['title'],
|
95
|
+
solution_url: hit_hash['solution_url'],
|
96
|
+
total_risk: hit_hash['total_risk'].to_i,
|
97
|
+
likelihood: hit_hash['likelihood'].to_i,
|
98
|
+
results_url: hit_hash['results_url'],
|
99
|
+
}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module InsightsCloud
|
2
|
+
module Async
|
3
|
+
class InsightsScheduledSync < ::ApplicationJob
|
4
|
+
def perform
|
5
|
+
unless Setting[:allow_auto_insights_sync]
|
6
|
+
logger.debug(
|
7
|
+
'The scheduled process is disabled due to the "allow_auto_insights_sync"
|
8
|
+
setting being set to false.'
|
9
|
+
)
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
13
|
+
InsightsFullSync.perform_later()
|
14
|
+
ensure
|
15
|
+
self.class.set(:wait => 24.hours).perform_later
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.singleton_job_name
|
19
|
+
name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module InventorySync
|
2
|
+
module Async
|
3
|
+
class HostResult
|
4
|
+
def initialize(result)
|
5
|
+
@total = result['total']
|
6
|
+
@count = result['count']
|
7
|
+
@page = result['page']
|
8
|
+
@per_page = result['per_page']
|
9
|
+
@fqdns = result["results"].map { |host| host['fqdn'] }
|
10
|
+
end
|
11
|
+
|
12
|
+
def status_hashes
|
13
|
+
@fqdns.map do |fqdn|
|
14
|
+
host_id = host_id(fqdn)
|
15
|
+
if host_id
|
16
|
+
touched << host_id
|
17
|
+
{
|
18
|
+
host_id: host_id,
|
19
|
+
status: InventorySync::InventoryStatus::SYNC,
|
20
|
+
reported_at: Time.current,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end.compact
|
24
|
+
end
|
25
|
+
|
26
|
+
def touched
|
27
|
+
@touched ||= []
|
28
|
+
end
|
29
|
+
|
30
|
+
def host_id(fqdn)
|
31
|
+
hosts[fqdn]
|
32
|
+
end
|
33
|
+
|
34
|
+
def hosts
|
35
|
+
@hosts ||= Hash[
|
36
|
+
Host.where(name: @fqdns).pluck(:name, :id)
|
37
|
+
]
|
38
|
+
end
|
39
|
+
|
40
|
+
def percentage
|
41
|
+
ratio = @per_page * @page * 1.0 / @total * 100
|
42
|
+
(ratio > 100) ? 100 : ratio.truncate(2)
|
43
|
+
end
|
44
|
+
|
45
|
+
def last?
|
46
|
+
@total <= @per_page * @page
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|