foreman_leapp 0.0.5 → 0.0.6
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/views/foreman_leapp/job_templates/upgrade.erb +12 -4
- data/app/views/job_invocations/_leapp_preupgrade_report.html.erb +2 -1
- data/lib/foreman_leapp/version.rb +1 -1
- data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +4 -0
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +2 -0
- data/webpack/components/PreupgradeReports/PreupgradeReports.js +32 -4
- data/webpack/components/PreupgradeReports/PreupgradeReportsHelpers.js +35 -0
- data/webpack/components/PreupgradeReports/PreupgradeReportsSelectors.js +1 -0
- data/webpack/components/PreupgradeReports/__tests__/PreupgradeReports.fixtures.js +34 -2
- data/webpack/components/PreupgradeReports/__tests__/PreupgradeReports.test.js +9 -0
- data/webpack/components/PreupgradeReports/__tests__/PreupgradeReportsHelpers.test.js +38 -0
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReports.test.js.snap +131 -24
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReportsHelpers.test.js.snap +82 -0
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReportsReducer.test.js.snap +19 -0
- data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReportsSelectors.test.js.snap +19 -0
- data/webpack/components/PreupgradeReports/components/FixAllButton.js +37 -0
- data/webpack/components/PreupgradeReports/components/FixAllButton.test.js +18 -0
- data/webpack/components/PreupgradeReports/components/__snapshots__/FixAllButton.test.js.snap +34 -0
- data/webpack/components/PreupgradeReports/index.js +7 -2
- data/webpack/components/PreupgradeReportsList/__tests__/PreupgradeReportsList.test.js +12 -2
- data/webpack/components/PreupgradeReportsList/__tests__/__snapshots__/PreupgradeReportsList.test.js.snap +81 -0
- data/webpack/components/PreupgradeReportsList/components/PreupgradeReportEntry.js +39 -5
- data/webpack/components/PreupgradeReportsList/components/__tests__/PreupgradeReportEntry.fixtures.js +38 -0
- data/webpack/components/PreupgradeReportsList/components/__tests__/__snapshots__/PreupgradeReportEntry.test.js.snap +97 -22
- data/webpack/components/PreupgradeReportsList/components/__tests__/__snapshots__/helpers.test.js.snap +196 -28
- data/webpack/components/PreupgradeReportsList/components/__tests__/helpers.test.js +21 -8
- data/webpack/components/PreupgradeReportsList/components/foreman_leapp.scss +9 -0
- data/webpack/components/PreupgradeReportsList/components/helpers.js +149 -21
- data/webpack/components/PreupgradeReportsList/index.js +21 -8
- data/webpack/csrf.js +4 -0
- metadata +27 -5
- data/webpack/components/PreupgradeReportsList/components/StringInfoItem.js +0 -49
- data/webpack/components/PreupgradeReportsList/components/__tests__/StringInfoItem.test.js +0 -13
- data/webpack/components/PreupgradeReportsList/components/__tests__/__snapshots__/StringInfoItem.test.js.snap +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a75680a7afc44c4a8e90727d2319a53b231748a6db1f8a1c3627c319b3483902
|
4
|
+
data.tar.gz: 8506877b49e172205eeadb3a898d9ee5e8e1235525155673d52b98efdfb7441f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a93546178c2252cd530f913d98633e24808dbf66698ddff5d4249d2eec0c9df2513447a304df59cd55e4b54c0bcefb31cae0713dd002ca1895bb78bb19be28
|
7
|
+
data.tar.gz: 4993f008708cdb78a9defd9cd311cadb7396e75ad16f0827675ab32e0361e5ad5154810d3e8b1d5f9504d1db2849c6aebe9addae16006a9ff8698b70719b2247
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%#
|
2
2
|
kind: job_template
|
3
3
|
name: Run upgrade via Leapp
|
4
|
-
job_category:
|
4
|
+
job_category: Ansible Playbook
|
5
5
|
description_format: 'Upgrade RHEL 7 host'
|
6
|
-
provider_type:
|
6
|
+
provider_type: Ansible
|
7
7
|
feature: leapp_upgrade
|
8
8
|
template_inputs:
|
9
9
|
- name: reboot
|
@@ -12,5 +12,13 @@ template_inputs:
|
|
12
12
|
required: false
|
13
13
|
options: "false\ntrue"
|
14
14
|
%>
|
15
|
-
|
16
|
-
|
15
|
+
---
|
16
|
+
- hosts: all
|
17
|
+
tasks:
|
18
|
+
- name: Run Leapp Upgrade
|
19
|
+
command: leapp upgrade
|
20
|
+
<% if input('reboot') == "true" %>
|
21
|
+
- name: Reboot the machine
|
22
|
+
reboot:
|
23
|
+
reboot_timeout: 1800
|
24
|
+
<% end %>
|
@@ -6,5 +6,6 @@
|
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<%= react_component('PreupgradeReports', {
|
9
|
-
:url => preupgrade_reports_path(:search => "job_invocation_id = #{@job_invocation.id}")
|
9
|
+
:url => preupgrade_reports_path(:search => "job_invocation_id = #{@job_invocation.id}"),
|
10
|
+
:newJobInvocationUrl => new_job_invocation_path
|
10
11
|
}) %>
|
@@ -1,12 +1,25 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import MessageBox from 'foremanReact/components/common/MessageBox';
|
3
|
-
import { LoadingState } from 'patternfly-react';
|
3
|
+
import { LoadingState, Row } from 'patternfly-react';
|
4
4
|
import PropTypes from 'prop-types';
|
5
5
|
|
6
6
|
import PreupgradeReportsList from '../PreupgradeReportsList';
|
7
|
+
import FixAllButton from './components/FixAllButton';
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
import {
|
10
|
+
flattenEntries,
|
11
|
+
isEmpty,
|
12
|
+
anyEntriesFixable,
|
13
|
+
} from './PreupgradeReportsHelpers';
|
14
|
+
|
15
|
+
const PreupgradeReports = ({
|
16
|
+
preupgradeReports,
|
17
|
+
loading,
|
18
|
+
error,
|
19
|
+
csrfToken,
|
20
|
+
newJobInvocationUrl,
|
21
|
+
}) => {
|
22
|
+
if (!isEmpty(error)) {
|
10
23
|
return (
|
11
24
|
<MessageBox
|
12
25
|
key="preupgrade-reports-error"
|
@@ -18,7 +31,20 @@ const PreupgradeReports = ({ preupgradeReports, loading, error }) => {
|
|
18
31
|
|
19
32
|
return (
|
20
33
|
<LoadingState loading={loading}>
|
21
|
-
<
|
34
|
+
<Row>
|
35
|
+
<div className="title-filter col-md-4"> </div>
|
36
|
+
<div id="title_action" className="col-md-8">
|
37
|
+
<div className="btn-toolbar pull-right">
|
38
|
+
<FixAllButton
|
39
|
+
postUrl={newJobInvocationUrl}
|
40
|
+
disabled={!anyEntriesFixable(preupgradeReports)}
|
41
|
+
csrfToken={csrfToken}
|
42
|
+
preupgradeReports={preupgradeReports}
|
43
|
+
/>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
</Row>
|
47
|
+
<PreupgradeReportsList allEntries={flattenEntries(preupgradeReports)} />
|
22
48
|
</LoadingState>
|
23
49
|
);
|
24
50
|
};
|
@@ -27,6 +53,8 @@ PreupgradeReports.propTypes = {
|
|
27
53
|
preupgradeReports: PropTypes.array.isRequired,
|
28
54
|
loading: PropTypes.bool.isRequired,
|
29
55
|
error: PropTypes.object.isRequired,
|
56
|
+
csrfToken: PropTypes.string.isRequired,
|
57
|
+
newJobInvocationUrl: PropTypes.string.isRequired,
|
30
58
|
};
|
31
59
|
|
32
60
|
export default PreupgradeReports;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
export const flattenEntries = reports =>
|
2
|
+
reports.reduce((memo, report) => [...memo, ...report.entries], []);
|
3
|
+
|
4
|
+
export const entryFixable = entry =>
|
5
|
+
entry.detail &&
|
6
|
+
entry.detail.remediations &&
|
7
|
+
entry.detail.remediations.some(remediation => remediation.type === 'command');
|
8
|
+
|
9
|
+
export const isEmpty = obj => Object.keys(obj).length === 0;
|
10
|
+
|
11
|
+
export const anyEntriesFixable = reports =>
|
12
|
+
flattenEntries(reports).some(entryFixable);
|
13
|
+
|
14
|
+
export const idsForInvocation = reports =>
|
15
|
+
reports.reduce(
|
16
|
+
(memo, report) => {
|
17
|
+
report.entries.forEach(entry => {
|
18
|
+
if (entryFixable(entry)) {
|
19
|
+
memo.entryIds = [...memo.entryIds, entry.id];
|
20
|
+
|
21
|
+
if (!memo.hostIds.includes(report.hostId)) {
|
22
|
+
memo.hostIds = [...memo.hostIds, report.hostId];
|
23
|
+
}
|
24
|
+
}
|
25
|
+
});
|
26
|
+
return memo;
|
27
|
+
},
|
28
|
+
{ hostIds: [], entryIds: [] }
|
29
|
+
);
|
30
|
+
|
31
|
+
export const entriesPage = (entries, pagination) => {
|
32
|
+
const offset = (pagination.page - 1) * pagination.perPage;
|
33
|
+
|
34
|
+
return entries.slice(offset, offset + pagination.perPage);
|
35
|
+
};
|
@@ -2,6 +2,7 @@ export const selectPreupgrade = state => state.foremanLeapp.preupgrade;
|
|
2
2
|
|
3
3
|
export const selectPreupgradeReports = state =>
|
4
4
|
selectPreupgrade(state).preupgradeReports;
|
5
|
+
|
5
6
|
export const selectLoadingPreupgradeReports = state =>
|
6
7
|
selectPreupgrade(state).loadingPreupgradeReports;
|
7
8
|
export const selectError = state => selectPreupgrade(state).error;
|
@@ -2,14 +2,46 @@ export const preupgradeReports = [
|
|
2
2
|
{
|
3
3
|
hostId: 5,
|
4
4
|
entries: [
|
5
|
-
{ title: 'Fix me!', severity: 'Too severe to talk about' },
|
5
|
+
{ title: 'Fix me!', severity: 'Too severe to talk about', id: 42 },
|
6
|
+
{ title: 'I am broken too', severity: 'medium', id: 43 },
|
7
|
+
],
|
8
|
+
},
|
9
|
+
{
|
10
|
+
hostId: 6,
|
11
|
+
entries: [
|
12
|
+
{ title: 'Octocat is not happy', severity: 'high', id: 44 },
|
13
|
+
{ title: 'Not enough credits', severity: 'low', id: 45 },
|
14
|
+
{ title: 'SELinux is turned off', severity: 'medium', id: 46 },
|
15
|
+
{ title: 'Root password is too short', severity: 'medium', id: 47 },
|
16
|
+
{
|
17
|
+
title: 'No chocolate chip cookies in cookie jar',
|
18
|
+
severity: 'high',
|
19
|
+
id: 49,
|
20
|
+
},
|
21
|
+
],
|
22
|
+
},
|
23
|
+
];
|
24
|
+
|
25
|
+
export const reportsWithRemediations = [
|
26
|
+
{
|
27
|
+
hostId: 5,
|
28
|
+
entries: [
|
29
|
+
{
|
30
|
+
title: 'Fix me!',
|
31
|
+
severity: 'Too severe to talk about',
|
32
|
+
detail: { remediations: [{ type: 'hint' }] },
|
33
|
+
},
|
6
34
|
{ title: 'I am broken too', severity: 'medium' },
|
7
35
|
],
|
8
36
|
},
|
9
37
|
{
|
10
38
|
hostId: 6,
|
11
39
|
entries: [
|
12
|
-
{
|
40
|
+
{
|
41
|
+
title: 'Octocat is not happy',
|
42
|
+
severity: 'high',
|
43
|
+
detail: { remediations: [{ type: 'command' }] },
|
44
|
+
},
|
13
45
|
{ title: 'Not enough credits', severity: 'low' },
|
14
46
|
],
|
15
47
|
},
|
@@ -4,16 +4,23 @@ import PreupgradeReports from '../PreupgradeReports';
|
|
4
4
|
|
5
5
|
import { preupgradeReports } from './PreupgradeReports.fixtures';
|
6
6
|
|
7
|
+
const csrfToken = 'xyz';
|
8
|
+
const newJobInvocationUrl = '/job_invocations/new';
|
9
|
+
|
7
10
|
const fixtures = {
|
8
11
|
'should render when loaded': {
|
9
12
|
loading: false,
|
10
13
|
error: {},
|
11
14
|
preupgradeReports,
|
15
|
+
csrfToken,
|
16
|
+
newJobInvocationUrl,
|
12
17
|
},
|
13
18
|
'should render when loading': {
|
14
19
|
loading: true,
|
15
20
|
error: {},
|
16
21
|
preupgradeReports: [],
|
22
|
+
csrfToken,
|
23
|
+
newJobInvocationUrl,
|
17
24
|
},
|
18
25
|
'should render error': {
|
19
26
|
loading: false,
|
@@ -22,6 +29,8 @@ const fixtures = {
|
|
22
29
|
errorMsg: 'Well, this is embarassing',
|
23
30
|
},
|
24
31
|
preupgradeReports: [],
|
32
|
+
csrfToken,
|
33
|
+
newJobInvocationUrl,
|
25
34
|
},
|
26
35
|
};
|
27
36
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { testSelectorsSnapshotWithFixtures } from '@theforeman/test';
|
2
|
+
|
3
|
+
import {
|
4
|
+
preupgradeReports,
|
5
|
+
reportsWithRemediations,
|
6
|
+
} from './PreupgradeReports.fixtures';
|
7
|
+
|
8
|
+
import {
|
9
|
+
flattenEntries,
|
10
|
+
isEmpty,
|
11
|
+
entryFixable,
|
12
|
+
anyEntriesFixable,
|
13
|
+
idsForInvocation,
|
14
|
+
entriesPage,
|
15
|
+
} from '../PreupgradeReportsHelpers';
|
16
|
+
|
17
|
+
const fixtures = {
|
18
|
+
'should return flattened entrues': () => flattenEntries(preupgradeReports),
|
19
|
+
'should detect empty object': () => isEmpty({}),
|
20
|
+
'should detect non-empty object': () => isEmpty({ foo: 'bar' }),
|
21
|
+
'should detect entry is fixable': () =>
|
22
|
+
entryFixable({ detail: { remediations: [{ type: 'command' }] } }),
|
23
|
+
'should detect entry is not fixable when not having a command': () =>
|
24
|
+
entryFixable({ detail: { remediations: [{ type: 'hint' }] } }),
|
25
|
+
'should detect entry is not fixable when not having remediations': () =>
|
26
|
+
!!entryFixable({ detail: {} }),
|
27
|
+
'should detect no entry is fixable': () =>
|
28
|
+
anyEntriesFixable(preupgradeReports),
|
29
|
+
'should detect a fixable entry in reports': () =>
|
30
|
+
anyEntriesFixable(reportsWithRemediations),
|
31
|
+
'should collect ids for job invocation': () =>
|
32
|
+
idsForInvocation(preupgradeReports),
|
33
|
+
'should return entries page': () =>
|
34
|
+
entriesPage(flattenEntries(preupgradeReports), { page: 2, perPage: 3 }),
|
35
|
+
};
|
36
|
+
|
37
|
+
describe('PreupgradeReportsHelpers', () =>
|
38
|
+
testSelectorsSnapshotWithFixtures(fixtures));
|
data/webpack/components/PreupgradeReports/__tests__/__snapshots__/PreupgradeReports.test.js.snap
CHANGED
@@ -16,34 +16,116 @@ exports[`PreupgradeReports should render when loaded 1`] = `
|
|
16
16
|
size="lg"
|
17
17
|
timeout={300}
|
18
18
|
>
|
19
|
+
<Row
|
20
|
+
bsClass="row"
|
21
|
+
componentClass="div"
|
22
|
+
>
|
23
|
+
<div
|
24
|
+
className="title-filter col-md-4"
|
25
|
+
>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
<div
|
29
|
+
className="col-md-8"
|
30
|
+
id="title_action"
|
31
|
+
>
|
32
|
+
<div
|
33
|
+
className="btn-toolbar pull-right"
|
34
|
+
>
|
35
|
+
<FixAllButton
|
36
|
+
csrfToken="xyz"
|
37
|
+
disabled={true}
|
38
|
+
postUrl="/job_invocations/new"
|
39
|
+
preupgradeReports={
|
40
|
+
Array [
|
41
|
+
Object {
|
42
|
+
"entries": Array [
|
43
|
+
Object {
|
44
|
+
"id": 42,
|
45
|
+
"severity": "Too severe to talk about",
|
46
|
+
"title": "Fix me!",
|
47
|
+
},
|
48
|
+
Object {
|
49
|
+
"id": 43,
|
50
|
+
"severity": "medium",
|
51
|
+
"title": "I am broken too",
|
52
|
+
},
|
53
|
+
],
|
54
|
+
"hostId": 5,
|
55
|
+
},
|
56
|
+
Object {
|
57
|
+
"entries": Array [
|
58
|
+
Object {
|
59
|
+
"id": 44,
|
60
|
+
"severity": "high",
|
61
|
+
"title": "Octocat is not happy",
|
62
|
+
},
|
63
|
+
Object {
|
64
|
+
"id": 45,
|
65
|
+
"severity": "low",
|
66
|
+
"title": "Not enough credits",
|
67
|
+
},
|
68
|
+
Object {
|
69
|
+
"id": 46,
|
70
|
+
"severity": "medium",
|
71
|
+
"title": "SELinux is turned off",
|
72
|
+
},
|
73
|
+
Object {
|
74
|
+
"id": 47,
|
75
|
+
"severity": "medium",
|
76
|
+
"title": "Root password is too short",
|
77
|
+
},
|
78
|
+
Object {
|
79
|
+
"id": 49,
|
80
|
+
"severity": "high",
|
81
|
+
"title": "No chocolate chip cookies in cookie jar",
|
82
|
+
},
|
83
|
+
],
|
84
|
+
"hostId": 6,
|
85
|
+
},
|
86
|
+
]
|
87
|
+
}
|
88
|
+
/>
|
89
|
+
</div>
|
90
|
+
</div>
|
91
|
+
</Row>
|
19
92
|
<PreupgradeReportsList
|
20
|
-
|
93
|
+
allEntries={
|
21
94
|
Array [
|
22
95
|
Object {
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
"title": "Fix me!",
|
27
|
-
},
|
28
|
-
Object {
|
29
|
-
"severity": "medium",
|
30
|
-
"title": "I am broken too",
|
31
|
-
},
|
32
|
-
],
|
33
|
-
"hostId": 5,
|
96
|
+
"id": 42,
|
97
|
+
"severity": "Too severe to talk about",
|
98
|
+
"title": "Fix me!",
|
34
99
|
},
|
35
100
|
Object {
|
36
|
-
"
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
"
|
101
|
+
"id": 43,
|
102
|
+
"severity": "medium",
|
103
|
+
"title": "I am broken too",
|
104
|
+
},
|
105
|
+
Object {
|
106
|
+
"id": 44,
|
107
|
+
"severity": "high",
|
108
|
+
"title": "Octocat is not happy",
|
109
|
+
},
|
110
|
+
Object {
|
111
|
+
"id": 45,
|
112
|
+
"severity": "low",
|
113
|
+
"title": "Not enough credits",
|
114
|
+
},
|
115
|
+
Object {
|
116
|
+
"id": 46,
|
117
|
+
"severity": "medium",
|
118
|
+
"title": "SELinux is turned off",
|
119
|
+
},
|
120
|
+
Object {
|
121
|
+
"id": 47,
|
122
|
+
"severity": "medium",
|
123
|
+
"title": "Root password is too short",
|
124
|
+
},
|
125
|
+
Object {
|
126
|
+
"id": 49,
|
127
|
+
"severity": "high",
|
128
|
+
"title": "No chocolate chip cookies in cookie jar",
|
47
129
|
},
|
48
130
|
]
|
49
131
|
}
|
@@ -59,8 +141,33 @@ exports[`PreupgradeReports should render when loading 1`] = `
|
|
59
141
|
size="lg"
|
60
142
|
timeout={300}
|
61
143
|
>
|
144
|
+
<Row
|
145
|
+
bsClass="row"
|
146
|
+
componentClass="div"
|
147
|
+
>
|
148
|
+
<div
|
149
|
+
className="title-filter col-md-4"
|
150
|
+
>
|
151
|
+
|
152
|
+
</div>
|
153
|
+
<div
|
154
|
+
className="col-md-8"
|
155
|
+
id="title_action"
|
156
|
+
>
|
157
|
+
<div
|
158
|
+
className="btn-toolbar pull-right"
|
159
|
+
>
|
160
|
+
<FixAllButton
|
161
|
+
csrfToken="xyz"
|
162
|
+
disabled={true}
|
163
|
+
postUrl="/job_invocations/new"
|
164
|
+
preupgradeReports={Array []}
|
165
|
+
/>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
</Row>
|
62
169
|
<PreupgradeReportsList
|
63
|
-
|
170
|
+
allEntries={Array []}
|
64
171
|
/>
|
65
172
|
</LoadingState>
|
66
173
|
`;
|