foreman_rh_cloud 5.0.33 → 5.0.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +6 -1
- data/app/controllers/insights_cloud/hits_controller.rb +8 -1
- data/app/services/foreman_rh_cloud/cloud_connector.rb +1 -1
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +16 -5
- data/app/views/job_templates/cloud_connector.erb +30 -0
- data/lib/foreman_rh_cloud/engine.rb +7 -0
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +6 -11
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +22 -0
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationActions.js +6 -1
- data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +3 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0389d4bf9e9af791b23a3ea7b271feca1385e2fcf4fc6acc7d954283477c8706'
|
4
|
+
data.tar.gz: 839cc45d7b92a308841f995152ae4a68503acd69feb95cd95b19772f99cec6c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b37d242c63e0260a76d06a6096ac569423237bf62f6e8685f79d6cf7b3e85246cfa92f35f0907a18b10539deb09f991189ea5914fa519236786aa2456e8aed6
|
7
|
+
data.tar.gz: e2baeab2eceeae447276db3ce9c8fa6c7236ff082eab418b835afea4c97ea9172a86eabeeb8ba430012f9662c26bd5a95cc86cc5f45e67a8f6ee4bb2d3a76ac8
|
@@ -37,8 +37,13 @@ module InsightsCloud::Api
|
|
37
37
|
return send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
|
38
38
|
end
|
39
39
|
|
40
|
+
# Append redhat-specific headers
|
41
|
+
@cloud_response.headers.each do |key, value|
|
42
|
+
assign_header(response, @cloud_response, key, false) if key.to_s.start_with?('x_rh_')
|
43
|
+
end
|
44
|
+
# Append general headers
|
40
45
|
assign_header(response, @cloud_response, :x_resource_count, true)
|
41
|
-
|
46
|
+
headers[Rack::ETAG] = @cloud_response.headers[:etag]
|
42
47
|
|
43
48
|
render json: @cloud_response, status: @cloud_response.code
|
44
49
|
end
|
@@ -14,9 +14,16 @@ module InsightsCloud
|
|
14
14
|
|
15
15
|
def show
|
16
16
|
host = Host.where(id: host_id_param).first
|
17
|
+
hits = host.insights&.hits
|
18
|
+
|
19
|
+
unless hits
|
20
|
+
return render json: {
|
21
|
+
error: 'No recommendations were found for this host',
|
22
|
+
}, status: :not_found
|
23
|
+
end
|
17
24
|
|
18
25
|
render json: {
|
19
|
-
hits:
|
26
|
+
hits: hits,
|
20
27
|
}, status: :ok
|
21
28
|
end
|
22
29
|
|
@@ -16,7 +16,7 @@ module ForemanRhCloud
|
|
16
16
|
composer = ::JobInvocationComposer.for_feature(
|
17
17
|
CLOUD_CONNECTOR_FEATURE,
|
18
18
|
[target_host.id],
|
19
|
-
{:
|
19
|
+
{:satellite_cloud_connector_user => service_user.login, :satellite_cloud_connector_password => token_value}
|
20
20
|
)
|
21
21
|
composer.trigger!
|
22
22
|
end
|
@@ -25,11 +25,12 @@ module ForemanRhCloud
|
|
25
25
|
base_params = {
|
26
26
|
method: original_request.method,
|
27
27
|
payload: forward_payload,
|
28
|
-
headers:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
headers: original_headers(original_request).merge(
|
29
|
+
{
|
30
|
+
params: forward_params,
|
31
|
+
user_agent: http_user_agent(original_request),
|
32
|
+
content_type: original_request.media_type.presence || original_request.format.to_s,
|
33
|
+
}),
|
33
34
|
}
|
34
35
|
base_params.merge(path_params(original_request.path, certs))
|
35
36
|
end
|
@@ -80,6 +81,16 @@ module ForemanRhCloud
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
84
|
+
def original_headers(original_request)
|
85
|
+
headers = {
|
86
|
+
if_none_match: original_request.if_none_match,
|
87
|
+
if_modified_since: original_request.if_modified_since,
|
88
|
+
}.compact
|
89
|
+
|
90
|
+
logger.debug("Sending headers: #{headers}")
|
91
|
+
headers
|
92
|
+
end
|
93
|
+
|
83
94
|
def platform_request?
|
84
95
|
->(request_path) { request_path.include? '/platform' }
|
85
96
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%#
|
2
|
+
name: Configure Cloud Connector
|
3
|
+
snippet: false
|
4
|
+
template_inputs:
|
5
|
+
- name: satellite_cloud_connector_user
|
6
|
+
required: true
|
7
|
+
input_type: user
|
8
|
+
advanced: false
|
9
|
+
value_type: plain
|
10
|
+
hidden_value: false
|
11
|
+
- name: satellite_cloud_connector_password
|
12
|
+
required: true
|
13
|
+
input_type: user
|
14
|
+
advanced: false
|
15
|
+
value_type: plain
|
16
|
+
hidden_value: true
|
17
|
+
model: JobTemplate
|
18
|
+
job_category: Maintenance Operations
|
19
|
+
description_format: "%{template_name}"
|
20
|
+
provider_type: Ansible
|
21
|
+
kind: job_template
|
22
|
+
feature: ansible_configure_cloud_connector
|
23
|
+
%>
|
24
|
+
|
25
|
+
---
|
26
|
+
- hosts: all
|
27
|
+
vars:
|
28
|
+
satellite_cloud_connector_url: "<%= foreman_server_url %>"
|
29
|
+
roles:
|
30
|
+
- redhat.satellite_operations.cloud_connector
|
@@ -156,6 +156,13 @@ module ForemanRhCloud
|
|
156
156
|
host_action_button: false,
|
157
157
|
provided_inputs: ['playbook_url', 'report_url', 'correlation_id', 'report_interval']
|
158
158
|
)
|
159
|
+
RemoteExecutionFeature.register(
|
160
|
+
:ansible_configure_cloud_connector,
|
161
|
+
N_('Configure Cloud Connector on given hosts'),
|
162
|
+
:description => N_('Configure Cloud Connector on given hosts'),
|
163
|
+
:proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
|
164
|
+
)
|
165
|
+
|
159
166
|
# skip object creation when admin user is not present, for example in test DB
|
160
167
|
if User.unscoped.find_by_login(User::ANONYMOUS_ADMIN).present?
|
161
168
|
::ForemanTasks.dynflow.config.on_init(false) do |world|
|
data/package.json
CHANGED
@@ -8,8 +8,11 @@ import {
|
|
8
8
|
INSIGHTS_SET_SELECTED_IDS,
|
9
9
|
INSIGHTS_SET_SELECT_ALL_ALERT,
|
10
10
|
INSIGHTS_SET_SELECT_ALL,
|
11
|
-
NEW_HOST_PATH,
|
12
11
|
} from './InsightsTableConstants';
|
12
|
+
import {
|
13
|
+
getServerQueryForHostname,
|
14
|
+
isNewHostPage,
|
15
|
+
} from './InsightsTableHelpers';
|
13
16
|
|
14
17
|
export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
|
15
18
|
const state = getState();
|
@@ -34,13 +37,7 @@ export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
|
|
34
37
|
dispatch(setSelectAllAlert(false));
|
35
38
|
}
|
36
39
|
|
37
|
-
|
38
|
-
if (isNewHostPage(uri)) {
|
39
|
-
const hostname = uri.pathname().split('/new/hosts/')[1];
|
40
|
-
const hostQuery = `hostname = ${hostname}`;
|
41
|
-
const q = query?.trim();
|
42
|
-
search = q ? `${hostQuery} AND (${q})` : hostQuery;
|
43
|
-
}
|
40
|
+
const search = getServerQueryForHostname(query);
|
44
41
|
|
45
42
|
return dispatch(
|
46
43
|
get({
|
@@ -151,11 +148,9 @@ const setSelectAllUrl = selectAllValue => dispatch => {
|
|
151
148
|
|
152
149
|
const updateUrl = (uri, dispatch) => {
|
153
150
|
const nextUrlParams = { search: uri.search() };
|
154
|
-
if (isNewHostPage(
|
151
|
+
if (isNewHostPage()) {
|
155
152
|
// we need to keep the hash so the insights tab will remain selected in the new host details page.
|
156
153
|
nextUrlParams.hash = '/Insights';
|
157
154
|
}
|
158
155
|
dispatch(push(nextUrlParams));
|
159
156
|
};
|
160
|
-
|
161
|
-
const isNewHostPage = uri => uri.pathname().includes(NEW_HOST_PATH);
|
@@ -1,4 +1,7 @@
|
|
1
1
|
/* eslint-disable camelcase */
|
2
|
+
import URI from 'urijs';
|
3
|
+
import { NEW_HOST_PATH } from './InsightsTableConstants';
|
4
|
+
|
2
5
|
export const modifySelectedRows = (
|
3
6
|
hits,
|
4
7
|
selectedIds,
|
@@ -54,3 +57,22 @@ export const getPerPageOptions = (urlPerPage, appPerPage) => {
|
|
54
57
|
const options = [...initialValues].sort((a, b) => a - b);
|
55
58
|
return options.map(value => ({ title: value.toString(), value }));
|
56
59
|
};
|
60
|
+
|
61
|
+
export const isNewHostPage = () => {
|
62
|
+
const uri = new URI();
|
63
|
+
const pathname = uri.pathname();
|
64
|
+
const isIncluded = pathname.includes(NEW_HOST_PATH);
|
65
|
+
return isIncluded ? pathname.split('/new/hosts/')[1] : false; // return hostname or false
|
66
|
+
};
|
67
|
+
|
68
|
+
// return query or specific hostname with query if it's in the new host page.
|
69
|
+
export const getServerQueryForHostname = query => {
|
70
|
+
const isNewHost = isNewHostPage();
|
71
|
+
let serverQuery = query;
|
72
|
+
if (isNewHost) {
|
73
|
+
const hostQuery = `hostname = ${isNewHost}`;
|
74
|
+
const q = query?.trim();
|
75
|
+
serverQuery = q ? `${hostQuery} AND (${q})` : hostQuery;
|
76
|
+
}
|
77
|
+
return serverQuery;
|
78
|
+
};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { get } from 'foremanReact/redux/API';
|
2
|
+
import { getServerQueryForHostname } from '../InsightsTable/InsightsTableHelpers';
|
2
3
|
import {
|
3
4
|
REMEDIATIONS_API_KEY,
|
4
5
|
REMEDIATIONS_PATH,
|
@@ -8,5 +9,9 @@ export const fetchRemediations = ({ selectedIds, isAllSelected, query }) =>
|
|
8
9
|
get({
|
9
10
|
key: REMEDIATIONS_API_KEY,
|
10
11
|
url: REMEDIATIONS_PATH,
|
11
|
-
params: {
|
12
|
+
params: {
|
13
|
+
ids: Object.keys(selectedIds),
|
14
|
+
isAllSelected,
|
15
|
+
query: getServerQueryForHostname(query),
|
16
|
+
},
|
12
17
|
});
|
@@ -19,10 +19,11 @@ const InsightsTotalRiskCard = ({ hostDetails: { id } }) => {
|
|
19
19
|
const dispatch = useDispatch();
|
20
20
|
const API_KEY = `HOST_${id}_RECOMMENDATIONS`;
|
21
21
|
const API_OPTIONS = useMemo(() => ({ key: API_KEY }), [API_KEY]);
|
22
|
+
const url = id && insightsCloudUrl(`hits/${id}`); // This will keep the API call from being triggered if there's no host id.
|
22
23
|
const {
|
23
24
|
status = STATUS.PENDING,
|
24
25
|
response: { hits = [] },
|
25
|
-
} = useAPI('get',
|
26
|
+
} = useAPI('get', url, API_OPTIONS);
|
26
27
|
|
27
28
|
useEffect(() => {
|
28
29
|
if (status === STATUS.RESOLVED) {
|
@@ -116,7 +117,7 @@ const InsightsTotalRiskCard = ({ hostDetails: { id } }) => {
|
|
116
117
|
|
117
118
|
return (
|
118
119
|
<CardTemplate
|
119
|
-
header={__('Total
|
120
|
+
header={__('Total risks')}
|
120
121
|
dropdownItems={[
|
121
122
|
<DropdownItem
|
122
123
|
key="insights-tab"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rh_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Red Hat Cloud team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- app/services/foreman_rh_cloud/template_renderer_helper.rb
|
177
177
|
- app/services/foreman_rh_cloud/url_remediations_retriever.rb
|
178
178
|
- app/views/hosts/_insights_tab.html.erb
|
179
|
+
- app/views/job_templates/cloud_connector.erb
|
179
180
|
- app/views/job_templates/rh_cloud_download_playbook.erb
|
180
181
|
- app/views/job_templates/rh_cloud_remediations.erb
|
181
182
|
- app/views/layouts/foreman_rh_cloud/application.html.erb
|