foreman_rh_cloud 2.0.11 → 3.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +18 -0
- data/app/helpers/foreman_inventory_upload_host_helper.rb +2 -10
- data/app/models/concerns/rh_cloud_host.rb +4 -1
- data/app/models/insights_hit.rb +1 -1
- data/app/models/setting/rh_cloud.rb +2 -0
- data/app/overrides/hosts_list.rb +1 -1
- data/app/services/foreman_rh_cloud/cloud_auth.rb +28 -0
- data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +1 -6
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -1
- data/app/views/hosts/_insights_tab.html.erb +1 -7
- data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -1
- data/config/routes.rb +2 -0
- data/db/migrate/20201007115752_add_hits_count_to_insights_facets_table.foreman_rh_cloud.rb +5 -0
- data/db/migrate/20201007121540_setup_hits_count_cache.foreman_rh_cloud.rb +10 -0
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +2 -32
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +35 -0
- data/lib/foreman_inventory_upload/generators/json_stream.rb +7 -2
- data/lib/foreman_inventory_upload/generators/queries.rb +2 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +27 -25
- data/lib/foreman_rh_cloud.rb +55 -0
- data/lib/foreman_rh_cloud/engine.rb +6 -4
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud/async/insights_full_sync.rb +5 -24
- data/lib/inventory_sync/async/inventory_full_sync.rb +3 -22
- data/lib/tasks/rh_cloud_inventory.rake +12 -10
- data/package.json +1 -1
- data/test/unit/fact_helpers_test.rb +22 -0
- data/test/unit/insights_facet_test.rb +7 -0
- data/test/unit/rh_cloud_http_proxy_test.rb +65 -0
- data/test/unit/slice_generator_test.rb +147 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +14 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +22 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +6 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +7 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +12 -8
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +19 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -0
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +10 -11
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +12 -2
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +17 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +30 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +38 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +31 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +41 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +20 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +10 -11
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +12 -2
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +18 -1
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +4 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +2 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +38 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +31 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +20 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +8 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +9 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +1 -8
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +62 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -7
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +6 -1
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +2 -4
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +8 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +92 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +17 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +106 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +60 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +28 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +22 -0
- data/webpack/ForemanRhCloudFills.js +23 -0
- data/webpack/ForemanRhCloudPages.js +6 -1
- data/webpack/ForemanRhCloudReducers.js +10 -1
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +17 -20
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +0 -6
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +0 -4
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +16 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +1 -24
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +38 -4
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +0 -14
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +3 -5
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +1 -3
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +10 -11
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -2
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.js +13 -13
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +2 -2
- data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +9 -8
- data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +0 -1
- data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +2 -9
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +12 -14
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +7 -1
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +0 -9
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +26 -22
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +38 -2
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +10 -19
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +10 -12
- data/webpack/__mocks__/foremanReact/common/MountingService.js +1 -0
- data/webpack/common/Switcher/index.js +79 -0
- data/webpack/global_index.js +5 -0
- data/webpack/index.js +4 -14
- metadata +54 -20
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/hostObfuscationSwitcher.scss +0 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
- data/webpack/subscriptions_extension_index.js +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b0882515e038d95959e1926b002f3caebb0b38ed0bd05951208d33cea7748ae
|
|
4
|
+
data.tar.gz: 29d8594297d6c4ed6936d568c7c7a8547186ab7390d03b81448cc5c563f5031d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71d58183a48ca30f148138bb036ba0cd7bea80dd1ce087b13605e884b763035b674207f91c359f193d658211f2e742f54b2f7e4fadac3f7bc723eb10dbd85f6e
|
|
7
|
+
data.tar.gz: ef3740403be8ab6cc6bb2848666833b424b41cabbc7fac78b06af573db3e59cfed40b01dad2deb88d3bfcba6b8ef86a5c7fe16f8dc48d6b68e821d8f5f2c3ddf
|
|
@@ -23,7 +23,9 @@ module ForemanInventoryUpload
|
|
|
23
23
|
render json: {
|
|
24
24
|
autoUploadEnabled: Setting[:allow_auto_inventory_upload],
|
|
25
25
|
hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
|
|
26
|
+
ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
|
|
26
27
|
cloudToken: Setting[:rh_cloud_token],
|
|
28
|
+
excludePackages: Setting[:exclude_installed_packages],
|
|
27
29
|
accounts: accounts,
|
|
28
30
|
}, status: :ok
|
|
29
31
|
end
|
|
@@ -46,6 +46,24 @@ module ForemanInventoryUpload
|
|
|
46
46
|
ActiveModel::Type::Boolean.new.cast(params.require(:value))
|
|
47
47
|
end
|
|
48
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
|
+
|
|
49
67
|
private
|
|
50
68
|
|
|
51
69
|
def render_setting(node_name, setting)
|
|
@@ -5,16 +5,8 @@ module ForemanInventoryUploadHostHelper
|
|
|
5
5
|
|
|
6
6
|
def hits_counts_cell(host)
|
|
7
7
|
host_hits = hits_counts[host.id]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if host_hits
|
|
11
|
-
link_to(
|
|
12
|
-
content,
|
|
13
|
-
InsightsCloud::WebUi.system_url(InsightsCloud::WebUi::ADVISOR, host.insights.uuid),
|
|
14
|
-
:rel => 'external noopener noreferrer',
|
|
15
|
-
:target => '_blank'
|
|
16
|
-
)
|
|
17
|
-
end
|
|
8
|
+
tag.td class: ['hidden-xs', 'ellipsis', 'text-center'] do
|
|
9
|
+
link_to(host_hits, "#{host_path(host)}#insights") if host_hits
|
|
18
10
|
end
|
|
19
11
|
end
|
|
20
12
|
end
|
|
@@ -6,7 +6,10 @@ module RhCloudHost
|
|
|
6
6
|
:inventory_upload_facts,
|
|
7
7
|
-> { where(fact_name_id: ForemanInventoryUpload::Generators::Queries.fact_names.values) },
|
|
8
8
|
class_name: 'FactValue',
|
|
9
|
-
:
|
|
9
|
+
foreign_key: :host_id
|
|
10
10
|
)
|
|
11
|
+
|
|
12
|
+
has_many :insights_hits, through: :insights, source: :hits
|
|
13
|
+
scoped_search :relation => :insights, :on => :hits_count, :only_explicit => true, :rename => :insights_recommendations_count
|
|
11
14
|
end
|
|
12
15
|
end
|
data/app/models/insights_hit.rb
CHANGED
|
@@ -2,5 +2,5 @@ class InsightsHit < ApplicationRecord
|
|
|
2
2
|
has_one :host
|
|
3
3
|
# since the facet is one-to-one association with a host, we can connect
|
|
4
4
|
# through host_id column on both this model and facet.
|
|
5
|
-
|
|
5
|
+
belongs_to :insights_facet, foreign_key: 'host_id', primary_key: 'host_id', counter_cache: :hits_count
|
|
6
6
|
end
|
|
@@ -6,7 +6,9 @@ class Setting::RhCloud < Setting
|
|
|
6
6
|
set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false),
|
|
7
7
|
set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false),
|
|
8
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),
|
|
9
10
|
set('rh_cloud_token', N_('Authentication token to Red Hat cloud services. Used to authenticate requests to cloud APIs'), 'DEFAULT', N_('Red Hat Cloud token'), nil, encrypted: true),
|
|
11
|
+
set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false),
|
|
10
12
|
]
|
|
11
13
|
end
|
|
12
14
|
|
data/app/overrides/hosts_list.rb
CHANGED
|
@@ -2,7 +2,7 @@ Deface::Override.new(
|
|
|
2
2
|
virtual_path: 'hosts/_list',
|
|
3
3
|
name: 'insights_hits_header',
|
|
4
4
|
insert_before: 'thead tr th.hidden-xs:first-of-type',
|
|
5
|
-
text: '<th class="hidden-xs" width="
|
|
5
|
+
text: '<th class="hidden-xs ellipsis" width="12%"><%= sort :insights_recommendations_count, :as => _("Recommendations")%></th>'
|
|
6
6
|
)
|
|
7
7
|
|
|
8
8
|
Deface::Override.new(
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module ForemanRhCloud
|
|
2
|
+
module CloudAuth
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
def rh_credentials
|
|
6
|
+
@rh_credentials ||= query_refresh_token
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def query_refresh_token
|
|
10
|
+
token_response = RestClient::Request.execute(
|
|
11
|
+
method: :post,
|
|
12
|
+
url: ForemanRhCloud.authentication_url,
|
|
13
|
+
verify_ssl: ForemanRhCloud.verify_ssl_method,
|
|
14
|
+
proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
|
|
15
|
+
payload: {
|
|
16
|
+
grant_type: 'refresh_token',
|
|
17
|
+
client_id: 'rhsm-api',
|
|
18
|
+
refresh_token: Setting[:rh_cloud_token],
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
JSON.parse(token_response)['access_token']
|
|
23
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
24
|
+
Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
|
|
25
|
+
raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
<%=
|
|
2
|
-
'InsightsCloudSync',
|
|
3
|
-
'#ForemanRhCloudReactRoot',
|
|
4
|
-
{
|
|
5
|
-
settingsUrl: settings_url(search: 'name = rh_cloud_token')
|
|
6
|
-
}.to_json) %>
|
|
1
|
+
<%= react_component('InsightsCloudSync', { settingsUrl: settings_url(search: 'name = rh_cloud_token') }) %>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%=
|
|
1
|
+
<%= react_component('ForemanInventoryUpload') %>
|
|
@@ -6,10 +6,4 @@
|
|
|
6
6
|
<%= webpacked_plugins_css_for :'foreman_rh_cloud' %>
|
|
7
7
|
<% end %>
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
<%= mount_react_component(
|
|
11
|
-
'InsightsHostDetailsTab',
|
|
12
|
-
'#host_details_insights_react_container',
|
|
13
|
-
{ hostID: host.id }.to_json,
|
|
14
|
-
flatten_data: true
|
|
15
|
-
) %>
|
|
9
|
+
<%= react_component('InsightsHostDetailsTab', { hostID: host.id }) %>
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
<%= notifications %>
|
|
11
11
|
<div id="organization-id" data-id="<%= Organization.current.id if Organization.current %>" ></div>
|
|
12
12
|
<div id="user-id" data-id="<%= User.current.id if User.current %>" ></div>
|
|
13
|
-
<div id="ForemanRhCloudReactRoot"></div>
|
|
14
13
|
<%= yield %>
|
|
15
14
|
<% end %>
|
|
16
15
|
<%= render file: "layouts/base" %>
|
data/config/routes.rb
CHANGED
|
@@ -8,6 +8,8 @@ Rails.application.routes.draw do
|
|
|
8
8
|
get 'auto_upload', to: 'uploads#show_auto_upload'
|
|
9
9
|
post 'auto_upload', to: 'uploads#auto_upload'
|
|
10
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'
|
|
11
13
|
|
|
12
14
|
resources :tasks, only: [:create]
|
|
13
15
|
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class SetupHitsCountCache < ActiveRecord::Migration[5.0]
|
|
2
|
+
def up
|
|
3
|
+
ActiveRecord::Base.connection.execute <<-SQL.squish
|
|
4
|
+
UPDATE insights_facets
|
|
5
|
+
SET hits_count = (SELECT count(1)
|
|
6
|
+
FROM insights_hits
|
|
7
|
+
WHERE insights_hits.host_id = insights_facets.host_id)
|
|
8
|
+
SQL
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -47,6 +47,8 @@ module ForemanInventoryUpload
|
|
|
47
47
|
'FILES' => @filename,
|
|
48
48
|
'CER_PATH' => @cer_path
|
|
49
49
|
)
|
|
50
|
+
|
|
51
|
+
http_proxy_string = ForemanRhCloud.http_proxy_string(logger: logger)
|
|
50
52
|
if http_proxy_string
|
|
51
53
|
env_vars['http_proxy'] = http_proxy_string
|
|
52
54
|
env_vars['https_proxy'] = http_proxy_string
|
|
@@ -54,13 +56,6 @@ module ForemanInventoryUpload
|
|
|
54
56
|
env_vars
|
|
55
57
|
end
|
|
56
58
|
|
|
57
|
-
def http_proxy_string
|
|
58
|
-
@http_proxy_string ||=
|
|
59
|
-
HttpProxy.default_global_content_proxy&.full_url ||
|
|
60
|
-
cdn_proxy ||
|
|
61
|
-
global_foreman_proxy
|
|
62
|
-
end
|
|
63
|
-
|
|
64
59
|
def rh_credentials
|
|
65
60
|
@rh_credentials ||= begin
|
|
66
61
|
candlepin_id_certificate = @organization.owner_details['upstreamConsumer']['idCert']
|
|
@@ -70,31 +65,6 @@ module ForemanInventoryUpload
|
|
|
70
65
|
}
|
|
71
66
|
end
|
|
72
67
|
end
|
|
73
|
-
|
|
74
|
-
def cdn_proxy
|
|
75
|
-
cdn_settings = SETTINGS[:katello][:cdn_proxy] || {}
|
|
76
|
-
|
|
77
|
-
return nil unless cdn_settings[:host]
|
|
78
|
-
|
|
79
|
-
proxy_uri = URI('')
|
|
80
|
-
|
|
81
|
-
original_uri = URI.parse(cdn_settings[:host])
|
|
82
|
-
|
|
83
|
-
proxy_uri.scheme = original_uri.scheme || 'http'
|
|
84
|
-
proxy_uri.host = original_uri.host || original_uri.path
|
|
85
|
-
proxy_uri.port = cdn_settings[:port]
|
|
86
|
-
proxy_uri.user = cdn_settings[:user]
|
|
87
|
-
proxy_uri.password = cdn_settings[:password]
|
|
88
|
-
|
|
89
|
-
proxy_uri.to_s
|
|
90
|
-
rescue URI::Error => e
|
|
91
|
-
logger.warn("cdn_proxy parsing failed: #{e}")
|
|
92
|
-
nil
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def global_foreman_proxy
|
|
96
|
-
Setting[:http_proxy]
|
|
97
|
-
end
|
|
98
68
|
end
|
|
99
69
|
end
|
|
100
70
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
1
3
|
module ForemanInventoryUpload
|
|
2
4
|
module Generators
|
|
3
5
|
module FactHelpers
|
|
@@ -69,6 +71,39 @@ module ForemanInventoryUpload
|
|
|
69
71
|
def obfuscate_fqdn(fqdn)
|
|
70
72
|
"#{Digest::SHA1.hexdigest(fqdn)}.example.com"
|
|
71
73
|
end
|
|
74
|
+
|
|
75
|
+
def obfuscate_ips?(host)
|
|
76
|
+
insights_client_setting = fact_value(host, 'insights_client::obfuscate_ip_enabled')
|
|
77
|
+
insights_client_setting = ActiveModel::Type::Boolean.new.cast(insights_client_setting)
|
|
78
|
+
return insights_client_setting unless insights_client_setting.nil?
|
|
79
|
+
|
|
80
|
+
Setting[:obfuscate_inventory_ips]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def host_ips(host)
|
|
84
|
+
return obfuscated_ips(host) if obfuscate_ips?(host)
|
|
85
|
+
|
|
86
|
+
# return a pass through proxy hash in case no obfuscation needed
|
|
87
|
+
Hash.new { |h, k| k }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def obfuscated_ips(host)
|
|
91
|
+
insights_client_ips = JSON.parse(fact_value(host, 'insights_client::ips') || '[]')
|
|
92
|
+
|
|
93
|
+
obfuscated_ips = Hash[
|
|
94
|
+
insights_client_ips.map { |ip_record| [ip_record['original'], ip_record['obfuscated']] }
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
obfuscated_ips.default_proc = proc do |hash, key|
|
|
98
|
+
hash[key] = obfuscate_ip(key, hash)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
obfuscated_ips
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def obfuscate_ip(ip, ips_dict)
|
|
105
|
+
"10.230.230.#{ips_dict.count + 1}"
|
|
106
|
+
end
|
|
72
107
|
end
|
|
73
108
|
end
|
|
74
109
|
end
|
|
@@ -26,8 +26,13 @@ module ForemanInventoryUpload
|
|
|
26
26
|
@out << string
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def simple_field(name, value, last = false)
|
|
30
|
-
|
|
29
|
+
def simple_field(name, value, last = false, &block)
|
|
30
|
+
return if value.nil? || value.try(:empty?)
|
|
31
|
+
return if value.kind_of?(Array) && value.compact.empty?
|
|
32
|
+
|
|
33
|
+
block ||= ->(value) { value }
|
|
34
|
+
|
|
35
|
+
@out << "\"#{name}\": #{stringify_value(block.call(value))}#{last ? '' : ','}"
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
def array_field(name, last = false, &block)
|
|
@@ -24,7 +24,9 @@ module ForemanInventoryUpload
|
|
|
24
24
|
'dmi::system::product_name',
|
|
25
25
|
'dmi::chassis::asset_tag',
|
|
26
26
|
'insights_client::obfuscate_hostname_enabled',
|
|
27
|
+
'insights_client::obfuscate_ip_enabled',
|
|
27
28
|
'insights_client::hostname',
|
|
29
|
+
'insights_client::ips',
|
|
28
30
|
]).pluck(:name, :id)
|
|
29
31
|
]
|
|
30
32
|
end
|
|
@@ -40,6 +40,7 @@ module ForemanInventoryUpload
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def report_host(host)
|
|
43
|
+
host_ips_cache = host_ips(host)
|
|
43
44
|
@stream.object do
|
|
44
45
|
@stream.simple_field('fqdn', fqdn(host))
|
|
45
46
|
@stream.simple_field('account', account_id(host.organization).to_s)
|
|
@@ -47,10 +48,10 @@ module ForemanInventoryUpload
|
|
|
47
48
|
@stream.simple_field('satellite_id', host.subscription_facet&.uuid)
|
|
48
49
|
@stream.simple_field('bios_uuid', fact_value(host, 'dmi::system::uuid'))
|
|
49
50
|
@stream.simple_field('vm_uuid', fact_value(host, 'virt::uuid'))
|
|
50
|
-
report_ip_addresses(host)
|
|
51
|
+
report_ip_addresses(host, host_ips_cache)
|
|
51
52
|
report_mac_addresses(host)
|
|
52
53
|
@stream.object_field('system_profile') do
|
|
53
|
-
report_system_profile(host)
|
|
54
|
+
report_system_profile(host, host_ips_cache)
|
|
54
55
|
end
|
|
55
56
|
@stream.array_field('facts') do
|
|
56
57
|
@stream.object do
|
|
@@ -96,17 +97,17 @@ module ForemanInventoryUpload
|
|
|
96
97
|
end
|
|
97
98
|
end
|
|
98
99
|
|
|
99
|
-
def report_system_profile(host)
|
|
100
|
-
@stream.simple_field('number_of_cpus', fact_value(host, 'cpu::cpu(s)').to_i
|
|
101
|
-
@stream.simple_field('number_of_sockets', fact_value(host, 'cpu::cpu_socket(s)').to_i
|
|
102
|
-
@stream.simple_field('cores_per_socket', fact_value(host, 'cpu::core(s)_per_socket').to_i
|
|
103
|
-
@stream.simple_field('system_memory_bytes',
|
|
100
|
+
def report_system_profile(host, host_ips_cache)
|
|
101
|
+
@stream.simple_field('number_of_cpus', fact_value(host, 'cpu::cpu(s)')) { |v| v.to_i }
|
|
102
|
+
@stream.simple_field('number_of_sockets', fact_value(host, 'cpu::cpu_socket(s)')) { |v| v.to_i }
|
|
103
|
+
@stream.simple_field('cores_per_socket', fact_value(host, 'cpu::core(s)_per_socket')) { |v| v.to_i }
|
|
104
|
+
@stream.simple_field('system_memory_bytes', fact_value(host, 'memory::memtotal')) { |v| kilobytes_to_bytes(v.to_i) }
|
|
104
105
|
@stream.array_field('network_interfaces') do
|
|
105
106
|
@stream.raw(host.interfaces.map do |nic|
|
|
106
107
|
{
|
|
107
|
-
'ipv4_addresses': [nic.ip].compact,
|
|
108
|
+
'ipv4_addresses': [host_ips_cache[nic.ip]].compact,
|
|
108
109
|
'ipv6_addresses': [nic.ip6].compact,
|
|
109
|
-
'mtu': nic.try(:mtu),
|
|
110
|
+
'mtu': nic.try(:mtu) && nic.mtu.to_i,
|
|
110
111
|
'mac_address': nic.mac,
|
|
111
112
|
'name': nic.identifier,
|
|
112
113
|
}.compact.to_json
|
|
@@ -123,18 +124,16 @@ module ForemanInventoryUpload
|
|
|
123
124
|
end
|
|
124
125
|
end
|
|
125
126
|
@stream.simple_field(
|
|
126
|
-
'os_release',
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
)
|
|
127
|
+
'os_release', [
|
|
128
|
+
fact_value(host, 'distribution::name'),
|
|
129
|
+
fact_value(host, 'distribution::version'),
|
|
130
|
+
fact_value(host, 'distribution::id'),
|
|
131
|
+
]
|
|
132
|
+
) { |v| os_release_value(*v) }
|
|
133
133
|
@stream.simple_field('os_kernel_version', fact_value(host, 'uname::release'))
|
|
134
134
|
@stream.simple_field('arch', host.architecture&.name)
|
|
135
135
|
@stream.simple_field('subscription_status', host.subscription_status_label)
|
|
136
136
|
@stream.simple_field('katello_agent_running', host.content_facet&.katello_agent_installed?)
|
|
137
|
-
@stream.simple_field('satellite_managed', true)
|
|
138
137
|
@stream.simple_field(
|
|
139
138
|
'infrastructure_type',
|
|
140
139
|
ActiveModel::Type::Boolean.new.cast(fact_value(host, 'virt::is_guest')) ? 'virtual' : 'physical'
|
|
@@ -150,13 +149,16 @@ module ForemanInventoryUpload
|
|
|
150
149
|
end.join(', '))
|
|
151
150
|
end
|
|
152
151
|
end
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
152
|
+
unless Setting[:exclude_installed_packages]
|
|
153
|
+
@stream.array_field('installed_packages') do
|
|
154
|
+
first = true
|
|
155
|
+
host.installed_packages.each do |package|
|
|
156
|
+
@stream.raw("#{first ? '' : ', '}#{@stream.stringify_value(package.nvra)}")
|
|
157
|
+
first = false
|
|
158
|
+
end
|
|
158
159
|
end
|
|
159
160
|
end
|
|
161
|
+
@stream.simple_field('satellite_managed', true, :last)
|
|
160
162
|
end
|
|
161
163
|
|
|
162
164
|
def report_satellite_facts(host)
|
|
@@ -175,8 +177,8 @@ module ForemanInventoryUpload
|
|
|
175
177
|
@stream.simple_field('organization_id', host.organization_id, :last)
|
|
176
178
|
end
|
|
177
179
|
|
|
178
|
-
def report_ip_addresses(host)
|
|
179
|
-
ip_addresses = host.interfaces.map { |nic| nic.ip }.compact
|
|
180
|
+
def report_ip_addresses(host, host_ips_cache)
|
|
181
|
+
ip_addresses = host.interfaces.map { |nic| host_ips_cache[nic.ip] }.compact
|
|
180
182
|
|
|
181
183
|
@stream.string_array_value('ip_addresses', ip_addresses)
|
|
182
184
|
end
|
|
@@ -187,7 +189,7 @@ module ForemanInventoryUpload
|
|
|
187
189
|
@stream.string_array_value('mac_addresses', macs)
|
|
188
190
|
end
|
|
189
191
|
|
|
190
|
-
def os_release_value(name
|
|
192
|
+
def os_release_value(name, version, codename)
|
|
191
193
|
"#{name} #{version} (#{codename})"
|
|
192
194
|
end
|
|
193
195
|
end
|
data/lib/foreman_rh_cloud.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'foreman_rh_cloud/engine.rb'
|
|
2
|
+
require 'cgi'
|
|
3
|
+
require 'uri'
|
|
2
4
|
|
|
3
5
|
module ForemanRhCloud
|
|
4
6
|
def self.base_url
|
|
@@ -14,4 +16,57 @@ module ForemanRhCloud
|
|
|
14
16
|
def self.verify_ssl_method
|
|
15
17
|
@verify_ssl_method ||= ENV['SATELLITE_RH_CLOUD_URL'] ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
|
|
16
18
|
end
|
|
19
|
+
|
|
20
|
+
def self.http_proxy_string(logger: Foreman::Logging.logger('background'))
|
|
21
|
+
ForemanRhCloud.proxy_setting(logger: logger)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.transformed_http_proxy_string(logger: Foreman::Logging.logger('background'))
|
|
25
|
+
ForemanRhCloud.transform_scheme(ForemanRhCloud.proxy_setting(logger: logger))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.proxy_setting(logger: Foreman::Logging.logger('background'))
|
|
29
|
+
HttpProxy.default_global_content_proxy&.full_url ||
|
|
30
|
+
ForemanRhCloud.cdn_proxy(logger: logger) ||
|
|
31
|
+
ForemanRhCloud.global_foreman_proxy ||
|
|
32
|
+
''
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.cdn_proxy(logger: Foreman::Logging.logger('app'))
|
|
36
|
+
proxy_config = SETTINGS[:katello][:cdn_proxy]
|
|
37
|
+
return nil unless proxy_config
|
|
38
|
+
|
|
39
|
+
uri = URI('')
|
|
40
|
+
uri.host = proxy_config[:host]
|
|
41
|
+
uri.port = proxy_config[:port]
|
|
42
|
+
uri.scheme = proxy_config[:scheme] || 'http'
|
|
43
|
+
|
|
44
|
+
if proxy_config[:user]
|
|
45
|
+
uri.user = CGI.escape(proxy_config[:user])
|
|
46
|
+
uri.password = CGI.escape(proxy_config[:password])
|
|
47
|
+
end
|
|
48
|
+
uri.to_s
|
|
49
|
+
rescue URI::Error => e
|
|
50
|
+
logger.warn("cdn_proxy parsing failed: #{e}")
|
|
51
|
+
nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.global_foreman_proxy
|
|
55
|
+
Setting[:http_proxy]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# This method assumes uri_string contains uri-encoded username and p@$$word:
|
|
59
|
+
# http://user:p%40%24%24word@localhost:8888
|
|
60
|
+
def self.transform_scheme(uri_string)
|
|
61
|
+
transformed_uri = URI.parse(uri_string)
|
|
62
|
+
|
|
63
|
+
case transformed_uri.scheme
|
|
64
|
+
when "http"
|
|
65
|
+
transformed_uri.scheme = 'proxy'
|
|
66
|
+
when "https"
|
|
67
|
+
transformed_uri.scheme = 'proxys'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
transformed_uri.to_s
|
|
71
|
+
end
|
|
17
72
|
end
|