foreman_remote_execution 3.2.1 → 3.3.3
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/.eslintrc +5 -30
- data/.github/workflows/ci.yml +101 -0
- data/.gitignore +1 -0
- data/.rubocop_todo.yml +3 -0
- data/Gemfile +1 -0
- data/app/assets/stylesheets/foreman_remote_execution/job_invocations.scss +6 -5
- data/app/controllers/api/v2/job_invocations_controller.rb +22 -1
- data/app/controllers/api/v2/template_invocations_controller.rb +4 -1
- data/app/helpers/job_invocations_helper.rb +1 -1
- data/app/helpers/remote_execution_helper.rb +38 -33
- data/app/lib/actions/remote_execution/run_host_job.rb +3 -2
- data/app/models/concerns/foreman_remote_execution/host_extensions.rb +1 -1
- data/app/models/concerns/foreman_remote_execution/orchestration/ssh.rb +10 -5
- data/app/models/remote_execution_provider.rb +5 -0
- data/app/services/default_proxy_proxy_selector.rb +18 -0
- data/app/views/api/v2/job_invocations/main.json.rabl +8 -2
- data/app/views/job_invocations/_card_target_hosts.html.erb +1 -1
- data/app/views/job_invocations/_tab_hosts.html.erb +3 -23
- data/app/views/job_invocations/index.html.erb +2 -1
- data/app/views/job_invocations/show.html.erb +0 -6
- data/app/views/job_invocations/show.json.erb +4 -0
- data/app/views/templates/ssh/package_action.erb +1 -0
- data/app/views/templates/ssh/puppet_agent_disable.erb +3 -0
- data/app/views/templates/ssh/puppet_agent_enable.erb +3 -0
- data/app/views/templates/ssh/puppet_install_modules_from_forge.erb +3 -0
- data/app/views/templates/ssh/puppet_run_once.erb +3 -0
- data/db/seeds.d/70-job_templates.rb +1 -1
- data/foreman_remote_execution.gemspec +4 -5
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/locale/action_names.rb +0 -1
- data/package.json +16 -33
- data/test/functional/api/v2/job_invocations_controller_test.rb +42 -14
- data/test/models/orchestration/ssh_test.rb +32 -0
- data/test/unit/concerns/host_extensions_test.rb +7 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +1 -0
- data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
- data/webpack/__mocks__/foremanReact/constants.js +3 -0
- data/webpack/index.js +9 -7
- data/webpack/react_app/components/TargetingHosts/TargetingHosts.js +52 -0
- data/webpack/react_app/components/TargetingHosts/TargetingHostsActions.js +8 -0
- data/webpack/react_app/components/TargetingHosts/TargetingHostsConsts.js +1 -0
- data/webpack/react_app/components/TargetingHosts/TargetingHostsSelectors.js +12 -0
- data/webpack/react_app/components/TargetingHosts/__tests__/HostItem.test.js +6 -0
- data/webpack/react_app/components/TargetingHosts/__tests__/HostStatus.test.js +6 -0
- data/webpack/react_app/components/TargetingHosts/__tests__/TargetingHosts.test.js +6 -0
- data/webpack/react_app/components/TargetingHosts/__tests__/__snapshots__/HostItem.test.js.snap +31 -0
- data/webpack/react_app/components/TargetingHosts/__tests__/__snapshots__/HostStatus.test.js.snap +12 -0
- data/webpack/react_app/components/TargetingHosts/__tests__/__snapshots__/TargetingHosts.test.js.snap +81 -0
- data/webpack/react_app/components/TargetingHosts/__tests__/fixtures.js +43 -0
- data/webpack/react_app/components/TargetingHosts/components/HostItem.js +39 -0
- data/webpack/react_app/components/TargetingHosts/components/HostStatus.js +54 -0
- data/webpack/react_app/components/TargetingHosts/index.js +37 -0
- data/webpack/react_app/components/jobInvocations/AggregateStatus/index.js +10 -0
- data/webpack/react_app/components/jobInvocations/AggregateStatus/index.test.js +6 -3
- data/webpack/react_app/components/jobInvocations/index.js +19 -7
- data/webpack/react_app/redux/actions/jobInvocations/index.js +12 -8
- data/webpack/react_app/redux/consts.js +1 -2
- data/webpack/react_app/redux/reducers/jobInvocations/index.fixtures.js +8 -40
- data/webpack/react_app/redux/reducers/jobInvocations/index.test.js +17 -11
- data/webpack/test_setup.js +2 -1
- metadata +26 -12
- data/.hound.yml +0 -19
- data/.travis.yml +0 -6
- data/app/views/job_invocations/_host_actions_td.html.erb +0 -3
- data/app/views/job_invocations/_host_name_td.html.erb +0 -8
- data/app/views/job_invocations/_host_status_td.html.erb +0 -1
- data/app/views/job_invocations/show.js.erb +0 -23
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
|
4
|
+
import { LoadingState, Alert } from 'patternfly-react';
|
|
5
|
+
import { STATUS } from 'foremanReact/constants';
|
|
6
|
+
import HostItem from './components/HostItem';
|
|
7
|
+
|
|
8
|
+
const TargetingHosts = ({ status, items }) => {
|
|
9
|
+
if (status === STATUS.ERROR) {
|
|
10
|
+
return (
|
|
11
|
+
<Alert type="error">
|
|
12
|
+
{__(
|
|
13
|
+
'There was an error while updating the status, try refreshing the page.'
|
|
14
|
+
)}
|
|
15
|
+
</Alert>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<LoadingState loading={!items.length}>
|
|
21
|
+
<div>
|
|
22
|
+
<table className="table table-bordered table-striped table-hover">
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
<th>{__('Host')}</th>
|
|
26
|
+
<th>{__('Status')}</th>
|
|
27
|
+
<th>{__('Actions')}</th>
|
|
28
|
+
</tr>
|
|
29
|
+
</thead>
|
|
30
|
+
<tbody>
|
|
31
|
+
{items.map(host => (
|
|
32
|
+
<HostItem
|
|
33
|
+
key={host.name}
|
|
34
|
+
name={host.name}
|
|
35
|
+
link={host.link}
|
|
36
|
+
status={host.status}
|
|
37
|
+
actions={host.actions}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
</tbody>
|
|
41
|
+
</table>
|
|
42
|
+
</div>
|
|
43
|
+
</LoadingState>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
TargetingHosts.propTypes = {
|
|
48
|
+
status: PropTypes.string.isRequired,
|
|
49
|
+
items: PropTypes.array.isRequired,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default TargetingHosts;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getURI } from 'foremanReact/common/urlHelpers';
|
|
2
|
+
import { get } from 'foremanReact/redux/API';
|
|
3
|
+
import { withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
|
|
4
|
+
import { TARGETING_HOSTS } from './TargetingHostsConsts';
|
|
5
|
+
|
|
6
|
+
const url = getURI().addQuery('format', 'json');
|
|
7
|
+
export const getData = () =>
|
|
8
|
+
withInterval(get({ key: TARGETING_HOSTS, url }), 1000);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TARGETING_HOSTS = 'TARGETING_HOSTS';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
selectAPIStatus,
|
|
3
|
+
selectAPIResponse,
|
|
4
|
+
} from 'foremanReact/redux/API/APISelectors';
|
|
5
|
+
import { TARGETING_HOSTS } from './TargetingHostsConsts';
|
|
6
|
+
|
|
7
|
+
export const selectItems = state =>
|
|
8
|
+
selectAPIResponse(state, TARGETING_HOSTS).hosts || [];
|
|
9
|
+
|
|
10
|
+
export const selectAutoRefresh = state =>
|
|
11
|
+
selectAPIResponse(state, TARGETING_HOSTS).autoRefresh;
|
|
12
|
+
export const selectStatus = state => selectAPIStatus(state, TARGETING_HOSTS);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
import HostStatus from '../components/HostStatus';
|
|
3
|
+
import { HostStatusFixtures } from './fixtures';
|
|
4
|
+
|
|
5
|
+
describe('HostStatus', () =>
|
|
6
|
+
testComponentSnapshotsWithFixtures(HostStatus, HostStatusFixtures));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
import TargetingHosts from '../TargetingHosts';
|
|
3
|
+
import { TargetingHostsFixtures } from './fixtures';
|
|
4
|
+
|
|
5
|
+
describe('TargetingHosts', () =>
|
|
6
|
+
testComponentSnapshotsWithFixtures(TargetingHosts, TargetingHostsFixtures));
|
data/webpack/react_app/components/TargetingHosts/__tests__/__snapshots__/HostItem.test.js.snap
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`HostItem renders 1`] = `
|
|
4
|
+
<tr
|
|
5
|
+
id="targeting-host-Host1"
|
|
6
|
+
>
|
|
7
|
+
<td
|
|
8
|
+
className="host_name"
|
|
9
|
+
>
|
|
10
|
+
<a
|
|
11
|
+
href="/host1"
|
|
12
|
+
>
|
|
13
|
+
Host1
|
|
14
|
+
</a>
|
|
15
|
+
</td>
|
|
16
|
+
<td
|
|
17
|
+
className="host_status"
|
|
18
|
+
>
|
|
19
|
+
<HostStatus
|
|
20
|
+
status="success"
|
|
21
|
+
/>
|
|
22
|
+
</td>
|
|
23
|
+
<td
|
|
24
|
+
className="host_actions"
|
|
25
|
+
>
|
|
26
|
+
<ActionButtons
|
|
27
|
+
buttons={Array []}
|
|
28
|
+
/>
|
|
29
|
+
</td>
|
|
30
|
+
</tr>
|
|
31
|
+
`;
|
data/webpack/react_app/components/TargetingHosts/__tests__/__snapshots__/TargetingHosts.test.js.snap
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`TargetingHosts renders 1`] = `
|
|
4
|
+
<LoadingState
|
|
5
|
+
additionalClasses=""
|
|
6
|
+
loading={false}
|
|
7
|
+
loadingText="Loading"
|
|
8
|
+
size="lg"
|
|
9
|
+
timeout={300}
|
|
10
|
+
>
|
|
11
|
+
<div>
|
|
12
|
+
<table
|
|
13
|
+
className="table table-bordered table-striped table-hover"
|
|
14
|
+
>
|
|
15
|
+
<thead>
|
|
16
|
+
<tr>
|
|
17
|
+
<th>
|
|
18
|
+
Host
|
|
19
|
+
</th>
|
|
20
|
+
<th>
|
|
21
|
+
Status
|
|
22
|
+
</th>
|
|
23
|
+
<th>
|
|
24
|
+
Actions
|
|
25
|
+
</th>
|
|
26
|
+
</tr>
|
|
27
|
+
</thead>
|
|
28
|
+
<tbody>
|
|
29
|
+
<HostItem
|
|
30
|
+
actions={Array []}
|
|
31
|
+
key="host"
|
|
32
|
+
link="/link"
|
|
33
|
+
name="host"
|
|
34
|
+
status="success"
|
|
35
|
+
/>
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
</div>
|
|
39
|
+
</LoadingState>
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`TargetingHosts renders with error 1`] = `
|
|
43
|
+
<Alert
|
|
44
|
+
className=""
|
|
45
|
+
onDismiss={null}
|
|
46
|
+
type="error"
|
|
47
|
+
>
|
|
48
|
+
There was an error while updating the status, try refreshing the page.
|
|
49
|
+
</Alert>
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
exports[`TargetingHosts renders with loading 1`] = `
|
|
53
|
+
<LoadingState
|
|
54
|
+
additionalClasses=""
|
|
55
|
+
loading={true}
|
|
56
|
+
loadingText="Loading"
|
|
57
|
+
size="lg"
|
|
58
|
+
timeout={300}
|
|
59
|
+
>
|
|
60
|
+
<div>
|
|
61
|
+
<table
|
|
62
|
+
className="table table-bordered table-striped table-hover"
|
|
63
|
+
>
|
|
64
|
+
<thead>
|
|
65
|
+
<tr>
|
|
66
|
+
<th>
|
|
67
|
+
Host
|
|
68
|
+
</th>
|
|
69
|
+
<th>
|
|
70
|
+
Status
|
|
71
|
+
</th>
|
|
72
|
+
<th>
|
|
73
|
+
Actions
|
|
74
|
+
</th>
|
|
75
|
+
</tr>
|
|
76
|
+
</thead>
|
|
77
|
+
<tbody />
|
|
78
|
+
</table>
|
|
79
|
+
</div>
|
|
80
|
+
</LoadingState>
|
|
81
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const HostItemFixtures = {
|
|
2
|
+
renders: {
|
|
3
|
+
name: 'Host1',
|
|
4
|
+
link: '/host1',
|
|
5
|
+
status: 'success',
|
|
6
|
+
actions: [],
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const HostStatusFixtures = {
|
|
11
|
+
renders: {
|
|
12
|
+
status: 'success',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const TargetingHostsFixtures = {
|
|
17
|
+
renders: {
|
|
18
|
+
status: '',
|
|
19
|
+
items: [
|
|
20
|
+
{
|
|
21
|
+
name: 'host',
|
|
22
|
+
link: '/link',
|
|
23
|
+
status: 'success',
|
|
24
|
+
actions: [],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
'renders with error': {
|
|
29
|
+
status: 'ERROR',
|
|
30
|
+
items: [
|
|
31
|
+
{
|
|
32
|
+
name: 'host',
|
|
33
|
+
link: '/link',
|
|
34
|
+
status: 'success',
|
|
35
|
+
actions: [],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
'renders with loading': {
|
|
40
|
+
status: '',
|
|
41
|
+
items: [],
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { ActionButtons } from 'foremanReact/components/common/ActionButtons/ActionButtons';
|
|
4
|
+
import HostStatus from './HostStatus';
|
|
5
|
+
|
|
6
|
+
const HostItem = ({ name, link, status, actions }) => {
|
|
7
|
+
const hostLink = link ? (
|
|
8
|
+
<a href={link}>{name}</a>
|
|
9
|
+
) : (
|
|
10
|
+
<a href="#" className="disabled">
|
|
11
|
+
{name}
|
|
12
|
+
</a>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<tr id={`targeting-host-${name}`}>
|
|
17
|
+
<td className="host_name">{hostLink}</td>
|
|
18
|
+
<td className="host_status">
|
|
19
|
+
<HostStatus status={status} />
|
|
20
|
+
</td>
|
|
21
|
+
<td className="host_actions">
|
|
22
|
+
<ActionButtons buttons={[...actions]} />
|
|
23
|
+
</td>
|
|
24
|
+
</tr>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
HostItem.propTypes = {
|
|
29
|
+
name: PropTypes.string.isRequired,
|
|
30
|
+
link: PropTypes.string.isRequired,
|
|
31
|
+
status: PropTypes.string.isRequired,
|
|
32
|
+
actions: PropTypes.array,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
HostItem.defaultProps = {
|
|
36
|
+
actions: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default HostItem;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from 'patternfly-react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
|
5
|
+
|
|
6
|
+
const HostStatus = ({ status }) => {
|
|
7
|
+
switch (status) {
|
|
8
|
+
case 'cancelled':
|
|
9
|
+
return (
|
|
10
|
+
<div>
|
|
11
|
+
<Icon type="pf" name="warning-triangle-o" /> {status}
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
case 'N/A':
|
|
15
|
+
return (
|
|
16
|
+
<div>
|
|
17
|
+
<Icon type="fa" name="question" /> {status}
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
case 'running':
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<Icon type="pf" name="running" /> {status}
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
case 'planned':
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
<Icon type="pf" name="build" /> {status}
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
case 'warning':
|
|
33
|
+
case 'error':
|
|
34
|
+
return (
|
|
35
|
+
<div>
|
|
36
|
+
<Icon type="pf" name="error-circle-o" /> {__('failed')}
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
case 'success':
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<Icon type="pf" name="ok" /> {status}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
default:
|
|
46
|
+
return <span>{status}</span>;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
HostStatus.propTypes = {
|
|
51
|
+
status: PropTypes.string.isRequired,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default HostStatus;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useSelector, useDispatch } from 'react-redux';
|
|
3
|
+
import { stopInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
|
|
4
|
+
import TargetingHosts from './TargetingHosts';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
selectItems,
|
|
8
|
+
selectStatus,
|
|
9
|
+
selectAutoRefresh,
|
|
10
|
+
} from './TargetingHostsSelectors';
|
|
11
|
+
import { getData } from './TargetingHostsActions';
|
|
12
|
+
import { TARGETING_HOSTS } from './TargetingHostsConsts';
|
|
13
|
+
|
|
14
|
+
const WrappedTargetingHosts = () => {
|
|
15
|
+
const dispatch = useDispatch();
|
|
16
|
+
const autoRefresh = useSelector(selectAutoRefresh);
|
|
17
|
+
const items = useSelector(selectItems);
|
|
18
|
+
const status = useSelector(selectStatus);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
dispatch(getData());
|
|
22
|
+
|
|
23
|
+
return () => {
|
|
24
|
+
dispatch(stopInterval(TARGETING_HOSTS));
|
|
25
|
+
};
|
|
26
|
+
}, [dispatch]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (autoRefresh === 'false') {
|
|
30
|
+
dispatch(stopInterval(TARGETING_HOSTS));
|
|
31
|
+
}
|
|
32
|
+
}, [autoRefresh, dispatch]);
|
|
33
|
+
|
|
34
|
+
return <TargetingHosts status={status} items={items} />;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default WrappedTargetingHosts;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
|
|
3
4
|
const AggregateStatus = ({ statuses }) => (
|
|
4
5
|
<div id="aggregate_statuses">
|
|
@@ -31,4 +32,13 @@ const AggregateStatus = ({ statuses }) => (
|
|
|
31
32
|
</div>
|
|
32
33
|
);
|
|
33
34
|
|
|
35
|
+
AggregateStatus.propTypes = {
|
|
36
|
+
statuses: PropTypes.shape({
|
|
37
|
+
cancelled: PropTypes.number,
|
|
38
|
+
failed: PropTypes.number,
|
|
39
|
+
pending: PropTypes.number,
|
|
40
|
+
success: PropTypes.number,
|
|
41
|
+
}).isRequired,
|
|
42
|
+
};
|
|
43
|
+
|
|
34
44
|
export default AggregateStatus;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { shallow } from '
|
|
3
|
-
import AggregateStatus from './index
|
|
2
|
+
import { shallow } from '@theforeman/test';
|
|
3
|
+
import AggregateStatus from './index';
|
|
4
4
|
|
|
5
5
|
jest.unmock('./index.js');
|
|
6
6
|
|
|
@@ -20,7 +20,10 @@ describe('AggregateStatus', () => {
|
|
|
20
20
|
|
|
21
21
|
it('renders cards with props passed', () => {
|
|
22
22
|
const statuses = {
|
|
23
|
-
success: 19,
|
|
23
|
+
success: 19,
|
|
24
|
+
failed: 20,
|
|
25
|
+
cancelled: 31,
|
|
26
|
+
pending: 3,
|
|
24
27
|
};
|
|
25
28
|
const chartNumbers = shallow(<AggregateStatus statuses={statuses} />);
|
|
26
29
|
const success = chartNumbers.find('#success_count').text();
|