foreman_rh_cloud 3.0.17 → 3.0.18
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 +3 -15
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +0 -48
- data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +26 -0
- data/app/controllers/insights_cloud/hits_controller.rb +1 -1
- data/app/services/foreman_rh_cloud/branch_info.rb +3 -14
- data/app/services/foreman_rh_cloud/cloud_connector.rb +12 -7
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +31 -19
- data/config/routes.rb +2 -5
- data/db/migrate/20210307000001_add_unique_to_insights_facet.foreman_rh_cloud.rb +11 -0
- data/lib/foreman_inventory_upload.rb +2 -1
- data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +14 -21
- data/lib/foreman_inventory_upload/generators/tags.rb +59 -0
- data/lib/foreman_rh_cloud.rb +4 -0
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- data/test/controllers/accounts_controller_test.rb +1 -5
- data/test/controllers/uploads_controller_test.rb +0 -13
- data/test/controllers/uploads_settings_controller_test.rb +31 -0
- data/test/test_plugin_helper.rb +13 -0
- data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +5 -5
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +39 -4
- data/test/unit/slice_generator_test.rb +7 -2
- data/test/unit/tags_generator_test.rb +60 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +4 -19
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +7 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -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 +7 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +12 -9
- 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 +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +3 -8
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +3 -35
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +24 -22
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +1 -1
- 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 +1 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +3 -11
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +3 -3
- 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 +7 -8
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.scss +15 -9
- 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 +16 -4
- 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.scss +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +1 -1
- 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/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 -25
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +1 -1
- 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 +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +1 -1
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +1 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.js +2 -1
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +1 -1
- data/webpack/common/Switcher/SwitcherPF4.scss +1 -1
- metadata +55 -56
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +0 -3
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +0 -29
- 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 -15
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +0 -31
- 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 -27
- 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 -15
- 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 -46
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +0 -36
- 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 -27
- 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 -15
- 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/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +0 -27
- 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 -15
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +0 -31
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50f4cac8e85d4aa6a6f5311e0276277ee3de729dfe29954d2fb8e907c2996e65
|
4
|
+
data.tar.gz: 96a40dac10cabdcf362add97a29d841a88a16d96a9cfb2a59c10eab0a64b8b5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dee0e2da14903584e433cf39e5f21c0e6e913ee54a6c579d929dee1db8163d60990502d7404285d7df8fed49f2b2910e923d47adc529dbda0c5f9aada23174b
|
7
|
+
data.tar.gz: 9c468f95609d7d844ae0b0c1b8bbe697c4b43e55529a6dfc5030b74089b05c2d0fae0843e415cb98bec95dacd45c056d25b2130c8df141238059552303a62573
|
@@ -10,36 +10,24 @@ 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].empty?,
|
28
|
-
excludePackages: Setting[:exclude_installed_packages],
|
29
24
|
accounts: accounts,
|
30
|
-
CloudConnectorStatus: cloud_connector_status,
|
25
|
+
CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
|
31
26
|
}, status: :ok
|
32
27
|
end
|
33
28
|
|
34
29
|
private
|
35
30
|
|
36
|
-
def cloud_connector_status
|
37
|
-
cloud_connector = ForemanRhCloud::CloudConnector.new
|
38
|
-
job = cloud_connector&.latest_job
|
39
|
-
return nil unless job
|
40
|
-
{ id: job.id, task: ForemanTasks::Task.where(:id => job.task_id).first }
|
41
|
-
end
|
42
|
-
|
43
31
|
def status_for(label, job_class)
|
44
32
|
label = job_class.output_label(label)
|
45
33
|
ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
|
@@ -21,53 +21,5 @@ module ForemanInventoryUpload
|
|
21
21
|
cloud_connector = ForemanRhCloud::CloudConnector.new
|
22
22
|
render json: cloud_connector.install.to_json
|
23
23
|
end
|
24
|
-
|
25
|
-
def auto_upload
|
26
|
-
Setting[:allow_auto_inventory_upload] = auto_upload_params
|
27
|
-
render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
|
28
|
-
end
|
29
|
-
|
30
|
-
def show_auto_upload
|
31
|
-
render_setting(:autoUploadEnabled, :allow_auto_inventory_upload)
|
32
|
-
end
|
33
|
-
|
34
|
-
def auto_upload_params
|
35
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
36
|
-
end
|
37
|
-
|
38
|
-
def host_obfuscation
|
39
|
-
Setting[:obfuscate_inventory_hostnames] = host_obfuscation_params
|
40
|
-
render_setting(:hostObfuscationEnabled, :obfuscate_inventory_hostnames)
|
41
|
-
end
|
42
|
-
|
43
|
-
def host_obfuscation_params
|
44
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
45
|
-
end
|
46
|
-
|
47
|
-
def installed_packages_inclusion
|
48
|
-
Setting[:exclude_installed_packages] = host_obfuscation_params
|
49
|
-
render_setting(:excludePackages, :exclude_installed_packages)
|
50
|
-
end
|
51
|
-
|
52
|
-
def installed_packages_inclusion_params
|
53
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
54
|
-
end
|
55
|
-
|
56
|
-
def ips_obfuscation
|
57
|
-
Setting[:obfuscate_inventory_ips] = ips_obfuscation_params
|
58
|
-
render_setting(:ipsObfuscationEnabled, :obfuscate_inventory_ips)
|
59
|
-
end
|
60
|
-
|
61
|
-
def ips_obfuscation_params
|
62
|
-
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def render_setting(node_name, setting)
|
68
|
-
render json: {
|
69
|
-
node_name => Setting[setting],
|
70
|
-
}
|
71
|
-
end
|
72
24
|
end
|
73
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
|
@@ -3,7 +3,7 @@ module InsightsCloud
|
|
3
3
|
include Foreman::Controller::AutoCompleteSearch
|
4
4
|
|
5
5
|
def index
|
6
|
-
hits = resource_base_search_and_page.preload(:host, :rule)
|
6
|
+
hits = resource_base_search_and_page.where(host: Host.authorized).preload(:host, :rule)
|
7
7
|
|
8
8
|
render json: {
|
9
9
|
hasToken: !Setting[:rh_cloud_token].empty?,
|
@@ -38,20 +38,9 @@ module ForemanRhCloud
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def host_labels(host)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
labels += labels_from_items(host.host_collections, 'Satellite', ->(item) { 'Host Collection' }, :name)
|
45
|
-
|
46
|
-
if Setting[:include_parameter_tags]
|
47
|
-
labels += labels_from_items(
|
48
|
-
host.host_inherited_params_objects,
|
49
|
-
'SatelliteParameter',
|
50
|
-
->(item) { item.name },
|
51
|
-
:value)
|
52
|
-
end
|
53
|
-
|
54
|
-
labels
|
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) }
|
55
44
|
end
|
56
45
|
end
|
57
46
|
end
|
@@ -9,13 +9,18 @@ module ForemanRhCloud
|
|
9
9
|
def install
|
10
10
|
user = service_user
|
11
11
|
token_value = personal_access_token(user)
|
12
|
+
target_host = foreman_host
|
13
|
+
composer = nil
|
14
|
+
|
15
|
+
Taxonomy.as_taxonomy(target_host.organization, target_host.location) do
|
16
|
+
composer = ::JobInvocationComposer.for_feature(
|
17
|
+
CLOUD_CONNECTOR_FEATURE,
|
18
|
+
[target_host.id],
|
19
|
+
{:satellite_user => service_user.login, :satellite_password => token_value}
|
20
|
+
)
|
21
|
+
composer.trigger!
|
22
|
+
end
|
12
23
|
|
13
|
-
composer = ::JobInvocationComposer.for_feature(
|
14
|
-
CLOUD_CONNECTOR_FEATURE,
|
15
|
-
[foreman_host.id],
|
16
|
-
{:satellite_user => service_user.login, :satellite_password => token_value}
|
17
|
-
)
|
18
|
-
composer.trigger!
|
19
24
|
composer.job_invocation
|
20
25
|
end
|
21
26
|
|
@@ -54,7 +59,7 @@ module ForemanRhCloud
|
|
54
59
|
end
|
55
60
|
|
56
61
|
def foreman_host
|
57
|
-
::Host.friendly.find(::SmartProxy.default_capsule.name)
|
62
|
+
::Host.unscoped.friendly.find(::SmartProxy.default_capsule.name)
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|
@@ -29,25 +29,7 @@ module ForemanRhCloud
|
|
29
29
|
user_agent: http_user_agent(original_request),
|
30
30
|
},
|
31
31
|
}
|
32
|
-
|
33
|
-
if no_cert_paths.any? { |path| path.match original_request.path }
|
34
|
-
base_params.merge(url: prepare_forward_cloud_url(ForemanRhCloud.base_url, original_request.path))
|
35
|
-
else
|
36
|
-
base_params.merge(
|
37
|
-
url: prepare_forward_cloud_url(ForemanRhCloud.cert_base_url, original_request.path),
|
38
|
-
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
39
|
-
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key])
|
40
|
-
)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def no_cert_paths
|
45
|
-
[
|
46
|
-
"/redhat_access/r/insights/v1/static/release/insights-core.egg",
|
47
|
-
"/redhat_access/r/insights/v1/static/uploader.v2.json",
|
48
|
-
"/redhat_access/r/insights/v1/static/uploader.v2.json.asc",
|
49
|
-
"/redhat_access/r/insights/v1/static/core/insights-core.egg",
|
50
|
-
]
|
32
|
+
base_params.merge(path_params(original_request.path, certs))
|
51
33
|
end
|
52
34
|
|
53
35
|
def execute_cloud_request(request_opts)
|
@@ -76,6 +58,36 @@ module ForemanRhCloud
|
|
76
58
|
forward_params
|
77
59
|
end
|
78
60
|
|
61
|
+
def path_params(request_path, certs)
|
62
|
+
case request_path
|
63
|
+
when metadata_request?
|
64
|
+
{
|
65
|
+
url: ForemanRhCloud.base_url + request_path.sub('/redhat_access/r/insights', '/api'),
|
66
|
+
}
|
67
|
+
when platform_request?
|
68
|
+
{
|
69
|
+
url: ForemanRhCloud.cert_base_url + request_path.sub('/redhat_access/r/insights/platform', '/api'),
|
70
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
71
|
+
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
|
72
|
+
}
|
73
|
+
else # Legacy insights API
|
74
|
+
{
|
75
|
+
url: ForemanRhCloud.legacy_insights_url + request_path.sub('/redhat_access/r/insights', '/r/insights'),
|
76
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
77
|
+
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
|
78
|
+
ssl_ca_file: Class.new.include(RedhatAccess::Telemetry::LookUps).new.get_default_ssl_ca_file,
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def metadata_request?
|
84
|
+
->(request_path) { request_path.include? '/static' }
|
85
|
+
end
|
86
|
+
|
87
|
+
def platform_request?
|
88
|
+
->(request_path) { request_path.include? '/platform' }
|
89
|
+
end
|
90
|
+
|
79
91
|
def prepare_forward_cloud_url(base_url, request_path)
|
80
92
|
cloud_path = request_path.sub('/redhat_access/r/insights/platform/', '')
|
81
93
|
.sub('/redhat_access/r/insights/', '')
|
data/config/routes.rb
CHANGED
@@ -5,11 +5,8 @@ Rails.application.routes.draw do
|
|
5
5
|
get ':organization_id/uploads/last', to: 'uploads#last', constraints: { organization_id: %r{[^\/]+} }
|
6
6
|
get ':organization_id/uploads/file', to: 'uploads#download_file', constraints: { organization_id: %r{[^\/]+} }
|
7
7
|
get 'accounts', to: 'accounts#index'
|
8
|
-
get '
|
9
|
-
post '
|
10
|
-
post 'host_obfuscation', to: 'uploads#host_obfuscation'
|
11
|
-
post 'installed_packages_inclusion', to: 'uploads#installed_packages_inclusion'
|
12
|
-
post 'ips_obfuscation', to: 'uploads#ips_obfuscation'
|
8
|
+
get 'settings', to: 'uploads_settings#index'
|
9
|
+
post 'setting', to: 'uploads_settings#set_advanced_setting'
|
13
10
|
|
14
11
|
post 'cloud_connector', to: 'uploads#enable_cloud_connector'
|
15
12
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddUniqueToInsightsFacet < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
# Remove duplicate records
|
4
|
+
InsightsFacet.where.not(id: InsightsFacet.select('max(id)').group(:host_id)).delete_all
|
5
|
+
|
6
|
+
# remove old index
|
7
|
+
remove_index :insights_facets, [:host_id]
|
8
|
+
# add unique constraint
|
9
|
+
add_index :insights_facets, [:host_id], unique: true
|
10
|
+
end
|
11
|
+
end
|
@@ -62,6 +62,7 @@ module ForemanInventoryUpload
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.inventory_export_url
|
65
|
-
|
65
|
+
tags = URI.encode("satellite/satellite_instance_id=#{Foreman.instance_id}")
|
66
|
+
ForemanRhCloud.base_url + "/api/inventory/v1/hosts?tags=#{tags}"
|
66
67
|
end
|
67
68
|
end
|
@@ -4,6 +4,7 @@ module ForemanInventoryUpload
|
|
4
4
|
include FactHelpers
|
5
5
|
|
6
6
|
SATELLITE_NAMESPACE = 'satellite'
|
7
|
+
SATELLITE_PARAMS_NAMESPACE = 'satellite_parameter'
|
7
8
|
|
8
9
|
attr_accessor :slice_id
|
9
10
|
attr_reader :hosts_count
|
@@ -63,15 +64,19 @@ module ForemanInventoryUpload
|
|
63
64
|
end
|
64
65
|
|
65
66
|
@stream.array_field('tags', :last) do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
67
|
+
tags_generator = Tags.new(host)
|
68
|
+
|
69
|
+
host_params_tags = tags_generator.generate_parameters
|
70
|
+
host_params_tags.each do |key, value|
|
71
|
+
report_tag(SATELLITE_PARAMS_NAMESPACE, key, value)
|
72
|
+
end
|
73
|
+
|
74
|
+
tags = tags_generator.generate
|
75
|
+
last_index = tags.count - 1
|
76
|
+
tags.each_with_index do |pair, index|
|
77
|
+
key, value = pair
|
78
|
+
report_tag(SATELLITE_NAMESPACE, key, value, index == last_index)
|
79
|
+
end
|
75
80
|
end
|
76
81
|
end
|
77
82
|
end
|
@@ -85,18 +90,6 @@ module ForemanInventoryUpload
|
|
85
90
|
@stream.comma unless last
|
86
91
|
end
|
87
92
|
|
88
|
-
def report_satellite_tag(key, value, last = nil)
|
89
|
-
return if value.nil?
|
90
|
-
|
91
|
-
array_value = Array(value)
|
92
|
-
last_index = array_value.count - 1
|
93
|
-
|
94
|
-
array_value.each_with_index do |value, index|
|
95
|
-
value = yield(value) if block_given?
|
96
|
-
report_tag(SATELLITE_NAMESPACE, key, value, last && index == last_index)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
93
|
def report_system_profile(host, host_ips_cache)
|
101
94
|
@stream.simple_field('number_of_cpus', fact_value(host, 'cpu::cpu(s)')) { |v| v.to_i }
|
102
95
|
@stream.simple_field('number_of_sockets', fact_value(host, 'cpu::cpu_socket(s)')) { |v| v.to_i }
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
module Generators
|
3
|
+
class Tags
|
4
|
+
def initialize(host)
|
5
|
+
@host = host
|
6
|
+
end
|
7
|
+
|
8
|
+
def generate
|
9
|
+
locations +
|
10
|
+
hostgroups +
|
11
|
+
host_collections +
|
12
|
+
organizations +
|
13
|
+
content_data +
|
14
|
+
satellite_server_data
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_parameters
|
18
|
+
return [] unless Setting[:include_parameter_tags]
|
19
|
+
|
20
|
+
(@host.host_inherited_params_objects || []).map { |item| [item.name, item.value] }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def locations
|
26
|
+
return [] unless @host.location
|
27
|
+
@host.location.title.split('/').map { |item| ['location', item] }.push(['location', @host.location.title])
|
28
|
+
end
|
29
|
+
|
30
|
+
def hostgroups
|
31
|
+
return [] unless @host.hostgroup
|
32
|
+
@host.hostgroup.title.split('/').map { |item| ['hostgroup', item] }.push(['hostgroup', @host.hostgroup.title])
|
33
|
+
end
|
34
|
+
|
35
|
+
def host_collections
|
36
|
+
(@host.host_collections || []).map { |item| ['host collection', item.name] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def organizations
|
40
|
+
[['organization', @host.organization.name]]
|
41
|
+
end
|
42
|
+
|
43
|
+
def content_data
|
44
|
+
[
|
45
|
+
['lifecycle_environment', @host.lifecycle_environment&.name],
|
46
|
+
['content_view', @host.content_view&.name],
|
47
|
+
] +
|
48
|
+
(@host.activation_keys || []).map { |item| ['activation_key', item.name] }
|
49
|
+
end
|
50
|
+
|
51
|
+
def satellite_server_data
|
52
|
+
[
|
53
|
+
['satellite_instance_id', Foreman.instance_id],
|
54
|
+
['organization_id', @host.organization_id.to_s],
|
55
|
+
]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/foreman_rh_cloud.rb
CHANGED
@@ -12,6 +12,10 @@ module ForemanRhCloud
|
|
12
12
|
@cert_base_url ||= ENV['SATELLITE_CERT_RH_CLOUD_URL'] || 'https://cert.cloud.redhat.com'
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.legacy_insights_url
|
16
|
+
@legacy_insights_url ||= ENV['SATELLITE_LEGACY_INSIGHTS_URL'] || 'https://cert-api.access.redhat.com'
|
17
|
+
end
|
18
|
+
|
15
19
|
def self.authentication_url
|
16
20
|
# https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
|
17
21
|
@authentication_url ||= ENV['SATELLITE_RH_CLOUD_SSO_URL'] || 'https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token'
|