foreman_acd 0.9.5 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +5 -3
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
- data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
- data/webpack/components/ApplicationDefinition/index.js +0 -1
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
- data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
- data/webpack/components/ApplicationInstance/components/Service.js +7 -18
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
- data/webpack/components/ApplicationInstance/index.js +0 -1
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
- data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
- data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
- data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
- data/webpack/components/ParameterSelection/index.js +1 -4
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
- data/webpack/components/SyncGitRepo/index.js +2 -5
- data/webpack/components/common/AddTableEntry.js +3 -10
- data/webpack/components/common/DeleteTableEntry.js +7 -15
- data/webpack/components/common/EditTableEntry.js +7 -7
- data/webpack/components/common/ExtSelect.js +12 -8
- data/webpack/components/common/ExtTextInput.js +12 -7
- data/webpack/components/common/LockTableEntry.js +6 -6
- data/webpack/components/common/RailsData.js +6 -16
- data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
- data/webpack/components/common/__tests__/RailsData.test.js +0 -2
- data/webpack/global_test_setup.js +11 -0
- data/webpack/helper.js +10 -21
- data/webpack/helper.test.js +17 -29
- data/webpack/index.js +25 -7
- data/webpack/js-yaml.js +1563 -1135
- data/webpack/reducer.js +52 -27
- metadata +13 -11
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
@@ -5,9 +5,7 @@ import {
|
|
5
5
|
selectActiveHostId,
|
6
6
|
} from '../ApplicationInstanceReportSelectors';
|
7
7
|
|
8
|
-
import {
|
9
|
-
applicationInstanceReportData_1,
|
10
|
-
} from '../__fixtures__/applicationInstanceReportData_1.fixtures';
|
8
|
+
import { applicationInstanceReportData1 } from '../__fixtures__/applicationInstanceReportData1.fixtures';
|
11
9
|
|
12
10
|
const stateFactory = obj => ({
|
13
11
|
foremanAcd: {
|
@@ -16,10 +14,10 @@ const stateFactory = obj => ({
|
|
16
14
|
});
|
17
15
|
|
18
16
|
const fixtures = {
|
19
|
-
'should return hosts from
|
20
|
-
selectHosts(stateFactory(
|
21
|
-
'should return activeHostId from
|
22
|
-
selectActiveHostId(stateFactory(
|
17
|
+
'should return hosts from applicationInstanceReportData1 fixtures': () =>
|
18
|
+
selectHosts(stateFactory(applicationInstanceReportData1)),
|
19
|
+
'should return activeHostId from applicationInstanceReportData1 fixtures': () =>
|
20
|
+
selectActiveHostId(stateFactory(applicationInstanceReportData1)),
|
23
21
|
};
|
24
22
|
|
25
23
|
describe('ApplicationInstanceSelectors', () =>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
|
-
exports[`ApplicationInstanceSelectors should return activeHostId from
|
3
|
+
exports[`ApplicationInstanceSelectors should return activeHostId from applicationInstanceReportData1 fixtures 1`] = `undefined`;
|
4
4
|
|
5
|
-
exports[`ApplicationInstanceSelectors should return hosts from
|
5
|
+
exports[`ApplicationInstanceSelectors should return hosts from applicationInstanceReportData1 fixtures 1`] = `
|
6
6
|
Array [
|
7
7
|
Object {
|
8
8
|
"build": false,
|
@@ -1,10 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
|
4
|
-
const ReportViewer= ({
|
5
|
-
hidden,
|
6
|
-
report,
|
7
|
-
}) =>{
|
4
|
+
const ReportViewer = ({ hidden, report }) => {
|
8
5
|
if (hidden) {
|
9
6
|
return null;
|
10
7
|
}
|
@@ -14,7 +11,9 @@ const ReportViewer= ({
|
|
14
11
|
}
|
15
12
|
|
16
13
|
return report.map((task, id) => (
|
17
|
-
<div key={
|
14
|
+
<div key={`report_task_${id}`} className="report_task">
|
15
|
+
{task.name} -- {task.status}
|
16
|
+
</div>
|
18
17
|
));
|
19
18
|
};
|
20
19
|
|
@@ -23,4 +22,9 @@ ReportViewer.propTypes = {
|
|
23
22
|
report: PropTypes.array,
|
24
23
|
};
|
25
24
|
|
25
|
+
ReportViewer.defaultProps = {
|
26
|
+
hidden: false,
|
27
|
+
report: undefined,
|
28
|
+
};
|
29
|
+
|
26
30
|
export default ReportViewer;
|
@@ -2,11 +2,9 @@ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
|
2
2
|
|
3
3
|
import ReportViewer from '../ReportViewer';
|
4
4
|
|
5
|
-
const noop = () => {};
|
6
|
-
|
7
5
|
const data = [
|
8
6
|
{ name: 'report 1', status: 'done' },
|
9
|
-
{ name: 'report 2', status: 'pending' }
|
7
|
+
{ name: 'report 2', status: 'pending' },
|
10
8
|
];
|
11
9
|
|
12
10
|
const fixtures = {
|
@@ -1,41 +1,20 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
|
-
import {
|
3
|
+
import { cloneDeep } from 'lodash';
|
4
|
+
import { DualListControlled } from 'patternfly-react';
|
5
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
4
6
|
import ServiceSelector from './components/ServiceSelector';
|
5
7
|
import { arrayToObject } from '../../helper';
|
6
8
|
|
7
|
-
import {
|
8
|
-
cloneDeep,
|
9
|
-
} from 'lodash';
|
10
|
-
|
11
|
-
import {
|
12
|
-
Icon,
|
13
|
-
Button,
|
14
|
-
DualListControlled,
|
15
|
-
} from 'patternfly-react';
|
16
|
-
|
17
9
|
class ExistingHostSelection extends React.Component {
|
18
|
-
|
19
|
-
constructor(props) {
|
20
|
-
super(props);
|
21
|
-
}
|
22
|
-
|
23
10
|
componentDidMount() {
|
24
|
-
const {
|
25
|
-
location,
|
26
|
-
organization,
|
27
|
-
services,
|
28
|
-
initExistingHostSelection,
|
29
|
-
allHosts,
|
30
|
-
} = this.props;
|
11
|
+
const { allHosts, initExistingHostSelection } = this.props;
|
31
12
|
|
32
13
|
initExistingHostSelection(allHosts);
|
33
14
|
}
|
34
15
|
|
35
16
|
render() {
|
36
17
|
const {
|
37
|
-
location,
|
38
|
-
organization,
|
39
18
|
services,
|
40
19
|
serviceId,
|
41
20
|
availableHosts,
|
@@ -44,35 +23,39 @@ class ExistingHostSelection extends React.Component {
|
|
44
23
|
hostSelectionChanged,
|
45
24
|
} = this.props;
|
46
25
|
|
47
|
-
const serviceList = arrayToObject(services,
|
48
|
-
const
|
26
|
+
const serviceList = arrayToObject(services, 'id', 'name');
|
27
|
+
const loadHostgroupUrl = '/api/v2/hostgroups/__hostgroup_id__/hosts';
|
49
28
|
|
50
|
-
return(
|
29
|
+
return (
|
51
30
|
<div>
|
52
31
|
<div className="row">
|
53
32
|
<ServiceSelector
|
54
33
|
label="Service"
|
55
|
-
hidden={
|
56
|
-
selectValue={
|
57
|
-
options={
|
58
|
-
onChange={
|
59
|
-
additionalData={{ url:
|
34
|
+
hidden={false}
|
35
|
+
selectValue={serviceId ? serviceId.toString() : '0'}
|
36
|
+
options={serviceList}
|
37
|
+
onChange={loadHostsOfHostgroup}
|
38
|
+
additionalData={{ url: loadHostgroupUrl, services }}
|
39
|
+
/>
|
60
40
|
</div>
|
61
41
|
<div className="row">
|
62
|
-
<label className="col-md-2 control-label">{
|
63
|
-
{
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
42
|
+
<label className="col-md-2 control-label">{__('Hosts')}</label>
|
43
|
+
{serviceId !== undefined ? (
|
44
|
+
<div className="col-md-6">
|
45
|
+
<DualListControlled
|
46
|
+
onChange={hostSelectionChanged}
|
47
|
+
left={{
|
48
|
+
items: cloneDeep(availableHosts),
|
49
|
+
}}
|
50
|
+
right={{
|
51
|
+
items: cloneDeep(alreadyUsedHosts),
|
52
|
+
}}
|
53
|
+
allowHiddenInputs={false}
|
54
|
+
/>
|
55
|
+
</div>
|
56
|
+
) : (
|
57
|
+
<span>{__('Please select service first.')}</span>
|
58
|
+
)}
|
76
59
|
</div>
|
77
60
|
</div>
|
78
61
|
);
|
@@ -80,25 +63,21 @@ class ExistingHostSelection extends React.Component {
|
|
80
63
|
}
|
81
64
|
|
82
65
|
ExistingHostSelection.defaultProps = {
|
66
|
+
allHosts: [],
|
83
67
|
serviceId: undefined,
|
84
|
-
hostsInHostgroup: {},
|
85
68
|
availableHosts: [],
|
86
69
|
alreadyUsedHosts: [],
|
87
|
-
selectedHosts: [],
|
88
70
|
};
|
89
71
|
|
90
72
|
ExistingHostSelection.propTypes = {
|
91
|
-
|
92
|
-
organization: PropTypes.string.isRequired,
|
73
|
+
allHosts: PropTypes.array,
|
93
74
|
services: PropTypes.array.isRequired,
|
94
|
-
initExistingHostSelection: PropTypes.func,
|
75
|
+
initExistingHostSelection: PropTypes.func.isRequired,
|
95
76
|
serviceId: PropTypes.number,
|
96
|
-
hostsInHostgroup: PropTypes.object,
|
97
77
|
availableHosts: PropTypes.array,
|
98
78
|
alreadyUsedHosts: PropTypes.array,
|
99
|
-
|
100
|
-
|
101
|
-
hostSelectionChanged: PropTypes.func,
|
79
|
+
loadHostsOfHostgroup: PropTypes.func.isRequired,
|
80
|
+
hostSelectionChanged: PropTypes.func.isRequired,
|
102
81
|
};
|
103
82
|
|
104
83
|
export default ExistingHostSelection;
|
@@ -1,14 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import * as sort from 'sortabular';
|
3
1
|
import { translate as __ } from 'foremanReact/common/I18n';
|
4
2
|
|
5
3
|
import api from 'foremanReact/API';
|
6
4
|
|
7
|
-
import {
|
8
|
-
propsToSnakeCase,
|
9
|
-
propsToCamelCase,
|
10
|
-
} from 'foremanReact/common/helpers';
|
11
|
-
|
12
5
|
import {
|
13
6
|
EXISTING_HOST_SELECTION_INIT,
|
14
7
|
EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
|
@@ -16,9 +9,7 @@ import {
|
|
16
9
|
EXISTING_HOST_SELECTION_SELECTION_CHANGED,
|
17
10
|
} from './ExistingHostSelectionConstants';
|
18
11
|
|
19
|
-
export const initExistingHostSelection =
|
20
|
-
allHosts,
|
21
|
-
) => dispatch => {
|
12
|
+
export const initExistingHostSelection = allHosts => dispatch => {
|
22
13
|
const initialState = {};
|
23
14
|
|
24
15
|
initialState.alreadyUsedHosts = undefined;
|
@@ -31,35 +22,37 @@ export const initExistingHostSelection = (
|
|
31
22
|
type: EXISTING_HOST_SELECTION_INIT,
|
32
23
|
payload: initialState,
|
33
24
|
});
|
34
|
-
}
|
25
|
+
};
|
35
26
|
|
36
27
|
export const loadHostsOfHostgroup = (
|
37
28
|
serviceId,
|
38
29
|
additionalData
|
39
|
-
) => dispatch => {
|
30
|
+
) => async dispatch => {
|
31
|
+
const selService = additionalData.services.filter(s => s.id === serviceId)[0];
|
32
|
+
const realUrl = additionalData.url.replace(
|
33
|
+
'__hostgroup_id__',
|
34
|
+
selService.hostgroup
|
35
|
+
);
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
})
|
54
|
-
)
|
55
|
-
.catch(error => dispatch(errorHandler(EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE, error)));
|
37
|
+
try {
|
38
|
+
const { data } = await api.get(realUrl, {}, {});
|
39
|
+
dispatch({
|
40
|
+
type: EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
|
41
|
+
payload: {
|
42
|
+
hosts: data.results,
|
43
|
+
serviceId: parseInt(serviceId, 10),
|
44
|
+
},
|
45
|
+
});
|
46
|
+
} catch (error) {
|
47
|
+
dispatch(errorHandler(EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE, error));
|
48
|
+
}
|
56
49
|
};
|
57
50
|
|
58
51
|
export const hostSelectionChanged = ({ left, right }) => ({
|
59
52
|
type: EXISTING_HOST_SELECTION_SELECTION_CHANGED,
|
60
53
|
payload: {
|
61
54
|
selection: right.items,
|
62
|
-
}
|
55
|
+
},
|
63
56
|
});
|
64
57
|
|
65
58
|
const errorHandler = (msg, err) => {
|
@@ -1,4 +1,7 @@
|
|
1
1
|
export const EXISTING_HOST_SELECTION_INIT = 'EXISTING_HOST_SELECTION_INIT';
|
2
|
-
export const EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS =
|
3
|
-
|
4
|
-
export const
|
2
|
+
export const EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS =
|
3
|
+
'EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS';
|
4
|
+
export const EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE =
|
5
|
+
'EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE';
|
6
|
+
export const EXISTING_HOST_SELECTION_SELECTION_CHANGED =
|
7
|
+
'EXISTING_HOST_SELECTION_SELECTION_CHANGED';
|
@@ -1,13 +1,7 @@
|
|
1
1
|
import Immutable from 'seamless-immutable';
|
2
|
-
|
3
|
-
import {
|
4
|
-
cloneDeep,
|
5
|
-
findIndex,
|
6
|
-
findLastIndex,
|
7
|
-
} from 'lodash';
|
2
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
8
3
|
|
9
4
|
import { shortHostname } from '../../helper';
|
10
|
-
import * as sort from 'sortabular';
|
11
5
|
|
12
6
|
import {
|
13
7
|
EXISTING_HOST_SELECTION_INIT,
|
@@ -29,10 +23,13 @@ const existingHostSelectionConf = (state = initialState, action) => {
|
|
29
23
|
return state.merge(payload);
|
30
24
|
}
|
31
25
|
case EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS: {
|
32
|
-
|
26
|
+
const alreadyUsedHosts = [];
|
33
27
|
|
34
28
|
state.allHosts.forEach(host => {
|
35
|
-
if (
|
29
|
+
if (
|
30
|
+
host.service === payload.serviceId &&
|
31
|
+
host.isExistingHost === true
|
32
|
+
) {
|
36
33
|
alreadyUsedHosts.push({
|
37
34
|
value: host.hostname,
|
38
35
|
label: host.hostname,
|
@@ -42,11 +39,11 @@ const existingHostSelectionConf = (state = initialState, action) => {
|
|
42
39
|
}
|
43
40
|
});
|
44
41
|
|
45
|
-
|
46
|
-
|
42
|
+
const availableHosts = [];
|
43
|
+
const hostsInHostgroup = {};
|
47
44
|
payload.hosts.forEach(host => {
|
48
|
-
|
49
|
-
if (state.allHosts.find(h => h.hostname
|
45
|
+
const shortName = shortHostname(host.name);
|
46
|
+
if (state.allHosts.find(h => h.hostname === shortName) === undefined) {
|
50
47
|
availableHosts.push({
|
51
48
|
value: shortName,
|
52
49
|
label: shortName,
|
@@ -56,9 +53,9 @@ const existingHostSelectionConf = (state = initialState, action) => {
|
|
56
53
|
});
|
57
54
|
|
58
55
|
return state.merge({
|
59
|
-
hostsInHostgroup
|
60
|
-
availableHosts
|
61
|
-
alreadyUsedHosts
|
56
|
+
hostsInHostgroup,
|
57
|
+
availableHosts,
|
58
|
+
alreadyUsedHosts,
|
62
59
|
serviceId: payload.serviceId,
|
63
60
|
});
|
64
61
|
}
|
@@ -66,10 +63,10 @@ const existingHostSelectionConf = (state = initialState, action) => {
|
|
66
63
|
return state.merge({ error: payload.error });
|
67
64
|
}
|
68
65
|
case EXISTING_HOST_SELECTION_SELECTION_CHANGED: {
|
69
|
-
|
66
|
+
const selectedHosts = [];
|
70
67
|
|
71
68
|
payload.selection.forEach(selHost => {
|
72
|
-
|
69
|
+
const hostData = state.hostsInHostgroup[selHost.value];
|
73
70
|
selectedHosts.push({
|
74
71
|
fqdn: hostData.name,
|
75
72
|
hostname: shortHostname(hostData.name),
|
@@ -79,7 +76,7 @@ const existingHostSelectionConf = (state = initialState, action) => {
|
|
79
76
|
});
|
80
77
|
|
81
78
|
return state.merge({
|
82
|
-
selectedHosts
|
79
|
+
selectedHosts,
|
83
80
|
});
|
84
81
|
}
|
85
82
|
default:
|
@@ -2,7 +2,11 @@ const existingHostState = state => state.foremanAcd.existingHostSelectionConf;
|
|
2
2
|
|
3
3
|
export const selectServiceId = state => existingHostState(state).serviceId;
|
4
4
|
export const selectAllHosts = state => existingHostState(state).allHosts;
|
5
|
-
export const selectHostsInHostgroup = state =>
|
6
|
-
|
7
|
-
export const
|
8
|
-
|
5
|
+
export const selectHostsInHostgroup = state =>
|
6
|
+
existingHostState(state).selectHostsInHostgroup;
|
7
|
+
export const selectAvailableHosts = state =>
|
8
|
+
existingHostState(state).availableHosts;
|
9
|
+
export const selectAlreadyUsedHosts = state =>
|
10
|
+
existingHostState(state).alreadyUsedHosts;
|
11
|
+
export const selectSelectedHosts = state =>
|
12
|
+
existingHostState(state).selectedHosts;
|
@@ -0,0 +1,187 @@
|
|
1
|
+
export const existingHostSelectionConfData1 = {
|
2
|
+
serviceId: 2,
|
3
|
+
error: {
|
4
|
+
errorMsg: '',
|
5
|
+
status: '',
|
6
|
+
statusText: '',
|
7
|
+
},
|
8
|
+
allHosts: [
|
9
|
+
{
|
10
|
+
id: 5,
|
11
|
+
hostname: 'isaac-anselm',
|
12
|
+
service: '1',
|
13
|
+
description: '',
|
14
|
+
foremanParameters: [],
|
15
|
+
ansibleParameters: [],
|
16
|
+
},
|
17
|
+
],
|
18
|
+
alreadyUsedHosts: [
|
19
|
+
{
|
20
|
+
value: 'isaac-anselm',
|
21
|
+
label: 'isaac-anselm',
|
22
|
+
disabled: true,
|
23
|
+
tooltipText: 'Host already used for this application instance',
|
24
|
+
},
|
25
|
+
],
|
26
|
+
selectedHosts: [],
|
27
|
+
hostsInHostgroup: {
|
28
|
+
'3': {
|
29
|
+
ip: null,
|
30
|
+
ip6: '',
|
31
|
+
environment_id: null,
|
32
|
+
environment_name: null,
|
33
|
+
last_report: null,
|
34
|
+
mac: '00:11:22:33:44:a1',
|
35
|
+
realm_id: null,
|
36
|
+
realm_name: null,
|
37
|
+
sp_mac: null,
|
38
|
+
sp_ip: null,
|
39
|
+
sp_name: null,
|
40
|
+
domain_id: 1,
|
41
|
+
domain_name: 'mylocal',
|
42
|
+
architecture_id: 1,
|
43
|
+
architecture_name: 'x86_64',
|
44
|
+
operatingsystem_id: 1,
|
45
|
+
operatingsystem_name: 'centos 7',
|
46
|
+
subnet_id: 1,
|
47
|
+
subnet_name: 'mylocal',
|
48
|
+
subnet6_id: null,
|
49
|
+
subnet6_name: null,
|
50
|
+
sp_subnet_id: null,
|
51
|
+
ptable_id: 118,
|
52
|
+
ptable_name: 'Kickstart default',
|
53
|
+
medium_id: 1,
|
54
|
+
medium_name: 'CentOS 7 mirror',
|
55
|
+
pxe_loader: 'PXELinux BIOS',
|
56
|
+
build: true,
|
57
|
+
comment: '',
|
58
|
+
disk: '',
|
59
|
+
installed_at: null,
|
60
|
+
model_id: null,
|
61
|
+
hostgroup_id: 1,
|
62
|
+
owner_id: 4,
|
63
|
+
owner_name: 'Admin User',
|
64
|
+
owner_type: 'User',
|
65
|
+
enabled: true,
|
66
|
+
managed: true,
|
67
|
+
use_image: null,
|
68
|
+
image_file: '',
|
69
|
+
uuid: null,
|
70
|
+
compute_resource_id: null,
|
71
|
+
compute_resource_name: null,
|
72
|
+
compute_profile_id: null,
|
73
|
+
compute_profile_name: null,
|
74
|
+
capabilities: ['build'],
|
75
|
+
provision_method: 'build',
|
76
|
+
certname: 'isaac-anselm.mylocal',
|
77
|
+
image_id: null,
|
78
|
+
image_name: null,
|
79
|
+
created_at: '2021-08-05 11:16:34 +0200',
|
80
|
+
updated_at: '2021-08-05 11:16:34 +0200',
|
81
|
+
last_compile: null,
|
82
|
+
global_status: 0,
|
83
|
+
global_status_label: 'Error',
|
84
|
+
uptime_seconds: null,
|
85
|
+
organization_id: 1,
|
86
|
+
organization_name: 'Default Organization',
|
87
|
+
location_id: 2,
|
88
|
+
location_name: 'Default Location',
|
89
|
+
puppet_status: 0,
|
90
|
+
model_name: null,
|
91
|
+
build_status: 2,
|
92
|
+
build_status_label: 'Token expired',
|
93
|
+
name: 'isaac-anselm.mylocal',
|
94
|
+
id: 3,
|
95
|
+
puppet_proxy_id: null,
|
96
|
+
puppet_proxy_name: null,
|
97
|
+
puppet_ca_proxy_id: null,
|
98
|
+
puppet_ca_proxy_name: null,
|
99
|
+
puppet_proxy: null,
|
100
|
+
puppet_ca_proxy: null,
|
101
|
+
hostgroup_name: 'base',
|
102
|
+
hostgroup_title: 'base',
|
103
|
+
},
|
104
|
+
'7': {
|
105
|
+
ip: null,
|
106
|
+
ip6: null,
|
107
|
+
environment_id: null,
|
108
|
+
environment_name: null,
|
109
|
+
last_report: null,
|
110
|
+
mac: '00:11:22:33:60:15',
|
111
|
+
realm_id: null,
|
112
|
+
realm_name: null,
|
113
|
+
sp_mac: null,
|
114
|
+
sp_ip: null,
|
115
|
+
sp_name: null,
|
116
|
+
domain_id: 1,
|
117
|
+
domain_name: 'mylocal',
|
118
|
+
architecture_id: 1,
|
119
|
+
architecture_name: 'x86_64',
|
120
|
+
operatingsystem_id: 1,
|
121
|
+
operatingsystem_name: 'centos 7',
|
122
|
+
subnet_id: 1,
|
123
|
+
subnet_name: 'mylocal',
|
124
|
+
subnet6_id: null,
|
125
|
+
subnet6_name: null,
|
126
|
+
sp_subnet_id: null,
|
127
|
+
ptable_id: 118,
|
128
|
+
ptable_name: 'Kickstart default',
|
129
|
+
medium_id: 1,
|
130
|
+
medium_name: 'CentOS 7 mirror',
|
131
|
+
pxe_loader: 'PXELinux BIOS',
|
132
|
+
build: true,
|
133
|
+
comment: null,
|
134
|
+
disk: null,
|
135
|
+
installed_at: null,
|
136
|
+
model_id: null,
|
137
|
+
hostgroup_id: 1,
|
138
|
+
owner_id: 4,
|
139
|
+
owner_name: 'Admin User',
|
140
|
+
owner_type: 'User',
|
141
|
+
enabled: true,
|
142
|
+
managed: true,
|
143
|
+
use_image: null,
|
144
|
+
image_file: '',
|
145
|
+
uuid: null,
|
146
|
+
compute_resource_id: null,
|
147
|
+
compute_resource_name: null,
|
148
|
+
compute_profile_id: null,
|
149
|
+
compute_profile_name: null,
|
150
|
+
capabilities: ['build'],
|
151
|
+
provision_method: 'build',
|
152
|
+
certname: 'lllllll.mylocal',
|
153
|
+
image_id: null,
|
154
|
+
image_name: null,
|
155
|
+
created_at: '2021-08-19 14:00:20 +0200',
|
156
|
+
updated_at: '2021-08-19 14:00:20 +0200',
|
157
|
+
last_compile: null,
|
158
|
+
global_status: 0,
|
159
|
+
global_status_label: 'Error',
|
160
|
+
uptime_seconds: null,
|
161
|
+
organization_id: 1,
|
162
|
+
organization_name: 'Default Organization',
|
163
|
+
location_id: 2,
|
164
|
+
location_name: 'Default Location',
|
165
|
+
puppet_status: 0,
|
166
|
+
model_name: null,
|
167
|
+
build_status: 2,
|
168
|
+
build_status_label: 'Token expired',
|
169
|
+
name: 'lllllll.mylocal',
|
170
|
+
id: 7,
|
171
|
+
puppet_proxy_id: null,
|
172
|
+
puppet_proxy_name: null,
|
173
|
+
puppet_ca_proxy_id: null,
|
174
|
+
puppet_ca_proxy_name: null,
|
175
|
+
puppet_proxy: null,
|
176
|
+
puppet_ca_proxy: null,
|
177
|
+
hostgroup_name: 'base',
|
178
|
+
hostgroup_title: 'base',
|
179
|
+
},
|
180
|
+
},
|
181
|
+
availableHosts: [
|
182
|
+
{
|
183
|
+
value: 'lllllll',
|
184
|
+
label: 'lllllll',
|
185
|
+
},
|
186
|
+
],
|
187
|
+
};
|