foreman_acd 0.4.0 → 0.9.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 +84 -84
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +103 -11
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +21 -3
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +9 -1
- data/app/controllers/foreman_acd/app_definitions_controller.rb +117 -15
- data/app/controllers/foreman_acd/app_instances_controller.rb +104 -30
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +36 -23
- data/app/controllers/ui_acd_controller.rb +46 -0
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +45 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +39 -0
- data/app/models/foreman_acd/acd_provider.rb +36 -0
- data/app/models/foreman_acd/ansible_playbook.rb +32 -14
- data/app/models/foreman_acd/app_definition.rb +24 -1
- data/app/models/foreman_acd/app_instance.rb +85 -5
- data/app/models/foreman_acd/foreman_host.rb +31 -0
- data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
- data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +64 -36
- data/app/services/foreman_acd/app_deployer.rb +83 -48
- data/app/services/foreman_acd/inventory_creator.rb +36 -25
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +50 -7
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +9 -1
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
- data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
- data/app/views/foreman_acd/app_definitions/index.html.erb +5 -8
- data/app/views/foreman_acd/app_instances/_form.html.erb +4 -4
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +93 -14
- data/app/views/foreman_acd/app_instances/report.html.erb +12 -4
- data/app/views/templates/job/run_acd_ansible_playbook.erb +28 -15
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/host_report.json.rabl +4 -0
- data/app/views/ui_acd/report_data.json.rabl +10 -0
- data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
- data/config/routes.rb +12 -3
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -0
- data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
- data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
- data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
- data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
- data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
- data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
- data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
- data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
- data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
- data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
- data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +6 -1
- data/lib/foreman_acd/engine.rb +40 -3
- data/lib/foreman_acd/plugin.rb +60 -45
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/foreman_acd.rb +30 -0
- data/lib/tasks/foreman_acd_tasks.rake +0 -12
- data/locale/en/foreman_acd.edit.po +326 -0
- data/locale/en/foreman_acd.po +232 -2
- data/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +8 -8
- data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
- data/test/controllers/app_instances_controller_test.rb +8 -3
- data/test/controllers/ui_acd_controller_test.rb +22 -6
- data/test/factories/foreman_acd_factories.rb +18 -4
- data/test/models/acd_provider_test.rb +37 -0
- data/test/models/ansible_playbook_test.rb +11 -0
- data/test/models/app_definition_test.rb +1 -1
- data/test/models/app_instance_test.rb +2 -0
- data/test/models/concerns/host_extensions_test.rb +26 -0
- data/test/models/foreman_host_test.rb +12 -0
- data/webpack/__mocks__/foremanReact/API.js +2 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
- data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
- data/webpack/__snapshots__/helper.test.js.snap +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +55 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +2 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +48 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +26 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +225 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +2 -1
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
- data/webpack/components/ApplicationDefinition/index.js +8 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
- data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +153 -45
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +120 -6
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +77 -22
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +299 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
- data/webpack/components/ApplicationInstance/components/Service.js +1 -1
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
- data/webpack/components/ApplicationInstance/helper.js +0 -0
- data/webpack/components/ApplicationInstance/index.js +8 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +128 -60
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +40 -50
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +5 -4
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -14
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -1
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +7 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
- data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
- data/webpack/components/ApplicationInstanceReport/index.js +8 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
- data/webpack/components/ExistingHostSelection/index.js +26 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +138 -15
- data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +52 -9
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +3 -0
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +62 -25
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +33 -25
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1488 -872
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
- data/webpack/components/ParameterSelection/index.js +2 -1
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
- data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +31 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +47 -0
- data/webpack/components/SyncGitRepo/index.js +28 -0
- data/webpack/components/common/DeleteTableEntry.js +18 -4
- data/webpack/components/common/EditTableEntry.js +50 -0
- data/webpack/components/common/ExtTextInput.js +43 -0
- data/webpack/components/common/LockTableEntry.js +60 -0
- data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
- data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +40 -2
- data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
- data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
- data/webpack/helper.js +20 -1
- data/webpack/helper.test.js +37 -0
- data/webpack/index.js +7 -0
- data/webpack/js-yaml.js +3874 -0
- data/webpack/reducer.js +16 -1
- metadata +182 -11
- data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
- data/webpack/components/common/EasyHeaderFormatter.js +0 -18
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -3,18 +3,24 @@ import PropTypes from 'prop-types';
|
|
3
3
|
import {
|
4
4
|
Icon,
|
5
5
|
Button,
|
6
|
+
MessageDialog,
|
6
7
|
} from 'patternfly-react';
|
7
8
|
import * as resolve from 'table-resolver';
|
8
9
|
import ForemanModal from 'foremanReact/components/ForemanModal';
|
10
|
+
import {
|
11
|
+
sprintf,
|
12
|
+
translate as __
|
13
|
+
} from 'foremanReact/common/I18n';
|
9
14
|
import Select from 'foremanReact/components/common/forms/Select';
|
10
15
|
import ParameterSelection from '../ParameterSelection';
|
16
|
+
import ExistingHostSelection from '../ExistingHostSelection';
|
11
17
|
import AddTableEntry from '../common/AddTableEntry';
|
12
18
|
import DeleteTableEntry from '../common/DeleteTableEntry';
|
13
19
|
import RailsData from '../common/RailsData';
|
14
|
-
import EasyHeaderFormatter from '../common/EasyHeaderFormatter';
|
15
20
|
import AppDefinitionSelector from './components/AppDefinitionSelector';
|
16
21
|
import ServiceCounter from './components/ServiceCounter';
|
17
22
|
import { arrayToObject } from '../../helper';
|
23
|
+
import { EasyHeaderFormatter } from '../../helper';
|
18
24
|
|
19
25
|
import {
|
20
26
|
Table,
|
@@ -37,16 +43,20 @@ class ApplicationInstance extends React.Component {
|
|
37
43
|
return (rowData.backup !== undefined);
|
38
44
|
}
|
39
45
|
|
46
|
+
changeDataAllowed() {
|
47
|
+
return this.props.editMode || this.props.appDefinition.id == ''
|
48
|
+
}
|
49
|
+
|
40
50
|
validateParameters() {
|
41
51
|
let result = true;
|
42
52
|
let msg = "";
|
43
53
|
|
44
54
|
this.props.hosts.forEach(h => {
|
45
|
-
if (h.
|
55
|
+
if (h.foremanParameters.map(e => e.value).filter(i => i == "").length > 0) {
|
46
56
|
result = false;
|
47
57
|
|
48
58
|
if (msg == "") {
|
49
|
-
msg += "For some hosts the values for some parameters are missing. Check the values for these hosts:\n";
|
59
|
+
msg += __("For some hosts the values for some parameters are missing. Check the values for these hosts:\n");
|
50
60
|
}
|
51
61
|
msg += "- "+ h.hostname +"\n";
|
52
62
|
}
|
@@ -61,16 +71,23 @@ class ApplicationInstance extends React.Component {
|
|
61
71
|
if (msg != "") {
|
62
72
|
msg += "\n";
|
63
73
|
}
|
64
|
-
msg += "Unachieved service counts: \n";
|
65
74
|
|
66
|
-
|
67
|
-
|
75
|
+
msg += __("Unachieved service counts:");
|
76
|
+
msg += "\n";
|
77
|
+
|
78
|
+
invalidMinServices.map(s => { msg += sprintf(
|
79
|
+
__(`- service ${s.name} expects at ${s.minCount} least configured hosts\n`)
|
80
|
+
)});
|
81
|
+
|
82
|
+
invalidMaxServices.map(s => { msg += sprintf(
|
83
|
+
__(`- service ${s.name} expects no more than ${s.axCount} configured hosts\n`)
|
84
|
+
)});
|
68
85
|
}
|
69
86
|
|
70
|
-
|
71
|
-
|
87
|
+
return {
|
88
|
+
validateResult: result,
|
89
|
+
validateMsg: msg
|
72
90
|
}
|
73
|
-
return result;
|
74
91
|
}
|
75
92
|
|
76
93
|
componentDidMount() {
|
@@ -90,30 +107,38 @@ class ApplicationInstance extends React.Component {
|
|
90
107
|
loadApplicationDefinition(appDefinition.id, { url: appDefinitionUrl });
|
91
108
|
}
|
92
109
|
|
110
|
+
const already_deployed_msg = __("This is an already deployed host. Changing the parameters is not possible!");
|
111
|
+
|
93
112
|
const inlineEditButtonsFormatter = inlineEditFormatterFactory({
|
94
113
|
isEditing: additionalData => this.props.editMode,
|
95
114
|
renderValue: (value, additionalData) => (
|
96
115
|
<td style={{ padding: '2px' }}>
|
116
|
+
{ additionalData.rowData.isExistingHost == true ? (
|
117
|
+
<Icon style={{marginRight: 8, marginLeft: 2}} type="pf" name="info" title={already_deployed_msg} />
|
118
|
+
) : (<span></span>)}
|
97
119
|
<Button
|
98
120
|
bsStyle="default"
|
99
121
|
onClick={() => activateEditApplicationInstanceHost(additionalData)}
|
100
122
|
>
|
101
|
-
<Icon type="pf" name="edit" title="
|
123
|
+
<Icon type="pf" name="edit" title={__("Edit entry")} />
|
102
124
|
</Button>
|
103
125
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
126
|
+
{ additionalData.rowData.isExistingHost == false ? (
|
127
|
+
<Button
|
128
|
+
bsStyle="default"
|
129
|
+
onClick={() => openForemanParameterSelectionModal(additionalData)}
|
130
|
+
>
|
131
|
+
<Icon type="pf" name="settings" title={__("Change parameters")} />
|
132
|
+
</Button>
|
133
|
+
) : (<span></span>)}
|
110
134
|
|
111
135
|
<Button
|
112
136
|
bsStyle="default"
|
113
137
|
onClick={() => openAnsibleParameterSelectionModal(additionalData)}
|
114
138
|
>
|
115
|
-
<span title="
|
139
|
+
<span title={__("Change ansible variables")}>A</span>
|
116
140
|
</Button>
|
141
|
+
|
117
142
|
<DeleteTableEntry
|
118
143
|
hidden={false}
|
119
144
|
disabled={false}
|
@@ -124,17 +149,23 @@ class ApplicationInstance extends React.Component {
|
|
124
149
|
),
|
125
150
|
renderEdit: (value, additionalData) => (
|
126
151
|
<td style={{ padding: '2px' }}>
|
152
|
+
{ additionalData.rowData.isExistingHost == true ? (
|
153
|
+
<Icon style={{marginRight: 8, marginLeft: 2}} type="pf" name="info" title={already_deployed_msg} />
|
154
|
+
) : (<span></span>)}
|
127
155
|
<Button bsStyle="default" disabled>
|
128
|
-
<Icon type="pf" name="edit" />
|
156
|
+
<Icon type="pf" name={__("edit")} />
|
129
157
|
</Button>
|
130
158
|
|
131
|
-
|
132
|
-
<
|
133
|
-
|
159
|
+
{ additionalData.rowData.isExistingHost == false ? (
|
160
|
+
<Button bsStyle="default" disabled>
|
161
|
+
<Icon type="pf" name={__("settings")} />
|
162
|
+
</Button>
|
163
|
+
) : (<span></span>)}
|
134
164
|
|
135
165
|
<Button bsStyle="default" disabled>
|
136
166
|
<span>A</span>
|
137
167
|
</Button>
|
168
|
+
|
138
169
|
<DeleteTableEntry
|
139
170
|
hidden={false}
|
140
171
|
disabled={true}
|
@@ -198,6 +229,12 @@ class ApplicationInstance extends React.Component {
|
|
198
229
|
prettyValue = serviceList[value];
|
199
230
|
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
|
200
231
|
}
|
232
|
+
if (additionalData.property == 'hostname') {
|
233
|
+
if (additionalData.rowData.newEntry === true) {
|
234
|
+
return inlineEditFormatterImpl.renderEditText(value, additionalData);
|
235
|
+
}
|
236
|
+
return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
|
237
|
+
}
|
201
238
|
return inlineEditFormatterImpl.renderEditText(prettyValue, additionalData);
|
202
239
|
}
|
203
240
|
});
|
@@ -216,6 +253,7 @@ class ApplicationInstance extends React.Component {
|
|
216
253
|
render() {
|
217
254
|
const {
|
218
255
|
data: { mode, applications, organization, location, foremanDataUrl, appDefinitionUrl },
|
256
|
+
showAlertModal, alertModalText, alertModalTitle, closeAlertModal,
|
219
257
|
appDefinition,
|
220
258
|
services,
|
221
259
|
hosts,
|
@@ -226,17 +264,33 @@ class ApplicationInstance extends React.Component {
|
|
226
264
|
closeForemanParameterSelectionModal,
|
227
265
|
openAnsibleParameterSelectionModal,
|
228
266
|
closeAnsibleParameterSelectionModal,
|
267
|
+
openAddExistingHostsModal,
|
268
|
+
closeAddExistingHostsModal,
|
269
|
+
changeParameterSelectionMode,
|
229
270
|
loadApplicationDefinition,
|
230
271
|
} = this.props;
|
231
272
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
273
|
+
let { validateResult, validateMsg } = this.validateParameters();
|
274
|
+
|
275
|
+
if (validateResult == false) {
|
276
|
+
$('input[type="submit"][name="commit"]').attr("disabled", true);
|
277
|
+
} else {
|
278
|
+
$('input[type="submit"][name="commit"]').attr("disabled", false);
|
279
|
+
}
|
236
280
|
|
237
281
|
return (
|
238
282
|
<span>
|
239
|
-
<
|
283
|
+
<MessageDialog
|
284
|
+
show={showAlertModal}
|
285
|
+
onHide={closeAlertModal}
|
286
|
+
primaryAction={closeAlertModal}
|
287
|
+
primaryActionButtonContent={__('OK')}
|
288
|
+
primaryActionButtonBsStyle={"danger"}
|
289
|
+
icon={<Icon type="pf" name="error-circle-o" />}
|
290
|
+
title={alertModalTitle}
|
291
|
+
primaryContent={alertModalText}
|
292
|
+
/>
|
293
|
+
<div className="service-counter">
|
240
294
|
<ServiceCounter
|
241
295
|
title="Service counts"
|
242
296
|
serviceList={ services }
|
@@ -246,6 +300,7 @@ class ApplicationInstance extends React.Component {
|
|
246
300
|
<div>
|
247
301
|
<AppDefinitionSelector
|
248
302
|
label="Application Definition"
|
303
|
+
hidden={ false }
|
249
304
|
editable={ mode == 'newInstance' }
|
250
305
|
viewText={ appDefinition.name }
|
251
306
|
options={ applications }
|
@@ -253,13 +308,13 @@ class ApplicationInstance extends React.Component {
|
|
253
308
|
selectValue={ appDefinition.id.toString() }
|
254
309
|
additionalData={{url: appDefinitionUrl}}
|
255
310
|
/>
|
311
|
+
{appDefinition.id == '' ? (
|
312
|
+
<div style={{ paddingTop: 25 }}>
|
313
|
+
<pre>{ "App Definition can't be blank" }</pre>
|
314
|
+
</div>
|
315
|
+
) : (<div></div>)}
|
256
316
|
</div>
|
257
317
|
<div className="form-group">
|
258
|
-
<AddTableEntry
|
259
|
-
hidden={ false }
|
260
|
-
disabled={ this.props.editMode }
|
261
|
-
onAddTableEntry={ addApplicationInstanceHost }
|
262
|
-
/>
|
263
318
|
<Table.PfProvider
|
264
319
|
striped
|
265
320
|
bordered
|
@@ -282,27 +337,38 @@ class ApplicationInstance extends React.Component {
|
|
282
337
|
role: 'row',
|
283
338
|
isEditing: () => this.isEditing({ rowData }),
|
284
339
|
onCancel: () => cancelEditApplicationInstanceHost({ rowData, rowIndex }),
|
285
|
-
onConfirm: () => confirmEditApplicationInstanceHost({ rowData, rowIndex }),
|
340
|
+
onConfirm: () => confirmEditApplicationInstanceHost({ rowData, rowIndex, appDefinition }),
|
286
341
|
last: rowIndex === services.length - 1
|
287
342
|
})}
|
288
343
|
/>
|
289
344
|
</Table.PfProvider>
|
290
345
|
<AddTableEntry
|
291
346
|
hidden={ false }
|
292
|
-
disabled={ this.
|
347
|
+
disabled={ this.changeDataAllowed() }
|
293
348
|
onAddTableEntry={ addApplicationInstanceHost }
|
294
349
|
/>
|
350
|
+
<span style={{ marginLeft: 10 }}>
|
351
|
+
<Button
|
352
|
+
bsStyle="default"
|
353
|
+
disabled={ this.changeDataAllowed() }
|
354
|
+
onClick={() => openAddExistingHostsModal({
|
355
|
+
isAllGroup: true
|
356
|
+
})}
|
357
|
+
>
|
358
|
+
<Icon title={__("Add existing hosts")} type="pf" name="server" />
|
359
|
+
</Button>
|
360
|
+
</span>
|
295
361
|
<span style={{ marginLeft: 30 }}>
|
296
362
|
Ansible group vars 'all':
|
297
363
|
<Button
|
298
364
|
style={{ marginLeft: 10 }}
|
299
365
|
bsStyle="default"
|
300
|
-
disabled={ this.
|
366
|
+
disabled={ this.changeDataAllowed() }
|
301
367
|
onClick={() => openAnsibleParameterSelectionModal({
|
302
368
|
isAllGroup: true
|
303
369
|
})}
|
304
370
|
>
|
305
|
-
<span title="
|
371
|
+
<span title={__("Change ansible variables for 'all'")}>A</span>
|
306
372
|
</Button>
|
307
373
|
</span>
|
308
374
|
</div>
|
@@ -310,13 +376,14 @@ class ApplicationInstance extends React.Component {
|
|
310
376
|
<ForemanModal
|
311
377
|
id="AppInstanceForemanParamSelection"
|
312
378
|
dialogClassName="param_selection_modal"
|
313
|
-
title="Foreman Parameter specification for Application Instance"
|
379
|
+
title={__("Foreman Parameter specification for Application Instance")}
|
314
380
|
>
|
315
381
|
<ForemanModal.Header closeButton={false}>
|
316
|
-
Parameter specification
|
382
|
+
{__("Parameter specification")}
|
317
383
|
</ForemanModal.Header>
|
318
384
|
{this.props.parametersData ? (
|
319
385
|
<ParameterSelection
|
386
|
+
editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
|
320
387
|
paramType={ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN }
|
321
388
|
location={ location }
|
322
389
|
organization={ organization }
|
@@ -327,8 +394,8 @@ class ApplicationInstance extends React.Component {
|
|
327
394
|
}
|
328
395
|
<ForemanModal.Footer>
|
329
396
|
<div>
|
330
|
-
<Button bsStyle="primary" onClick={() => closeForemanParameterSelectionModal({ mode: 'save' })}>Save</Button>
|
331
|
-
<Button bsStyle="default" onClick={() => closeForemanParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
|
397
|
+
<Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
|
398
|
+
<Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeForemanParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
|
332
399
|
</div>
|
333
400
|
</ForemanModal.Footer>
|
334
401
|
</ForemanModal>
|
@@ -337,13 +404,14 @@ class ApplicationInstance extends React.Component {
|
|
337
404
|
<ForemanModal
|
338
405
|
id="AppInstanceAnsibleParamSelection"
|
339
406
|
dialogClassName="param_selection_modal"
|
340
|
-
title="Ansible group variables for Application Instance"
|
407
|
+
title={__("Ansible group variables for Application Instance")}
|
341
408
|
>
|
342
409
|
<ForemanModal.Header closeButton={false}>
|
343
|
-
Parameter specification
|
410
|
+
{__("Parameter specification")}
|
344
411
|
</ForemanModal.Header>
|
345
412
|
{this.props.parametersData ? (
|
346
413
|
<ParameterSelection
|
414
|
+
editModeCallback={ (hide) => changeParameterSelectionMode({ mode: hide })}
|
347
415
|
paramType={ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE }
|
348
416
|
location={ location }
|
349
417
|
organization={ organization }
|
@@ -353,20 +421,48 @@ class ApplicationInstance extends React.Component {
|
|
353
421
|
}
|
354
422
|
<ForemanModal.Footer>
|
355
423
|
<div>
|
356
|
-
<Button bsStyle="primary" onClick={() => closeAnsibleParameterSelectionModal({ mode: 'save' })}>Save</Button>
|
357
|
-
<Button bsStyle="default" onClick={() => closeAnsibleParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
|
424
|
+
<Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'save' })}>{__("Save")}</Button>
|
425
|
+
<Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeAnsibleParameterSelectionModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
|
426
|
+
</div>
|
427
|
+
</ForemanModal.Footer>
|
428
|
+
</ForemanModal>
|
429
|
+
</div>
|
430
|
+
<div>
|
431
|
+
<ForemanModal
|
432
|
+
id="AppInstanceAddExistingHosts"
|
433
|
+
dialogClassName="add_existing_hosts_modal"
|
434
|
+
title={__("Add existing hosts to an Application Instance")}
|
435
|
+
>
|
436
|
+
<ForemanModal.Header closeButton={false}>
|
437
|
+
{__("Existing hosts selection")}
|
438
|
+
</ForemanModal.Header>
|
439
|
+
<ExistingHostSelection
|
440
|
+
location={ location }
|
441
|
+
organization={ organization }
|
442
|
+
services={ services }
|
443
|
+
allHosts={ this.props.hosts }
|
444
|
+
/>
|
445
|
+
<ForemanModal.Footer>
|
446
|
+
<div>
|
447
|
+
<Button bsStyle="primary" disabled={this.props.paramEditMode} onClick={() => closeAddExistingHostsModal({ mode: 'save' })}>{__("Save")}</Button>
|
448
|
+
<Button bsStyle="default" disabled={this.props.paramEditMode} onClick={() => closeAddExistingHostsModal({ mode: 'cancel' })}>{__("Cancel")}</Button>
|
358
449
|
</div>
|
359
450
|
</ForemanModal.Footer>
|
360
451
|
</ForemanModal>
|
361
452
|
</div>
|
453
|
+
{validateResult == false ? (
|
454
|
+
<div style={{ paddingTop: 25 }}>
|
455
|
+
<pre>{ validateMsg }</pre>
|
456
|
+
</div>
|
457
|
+
) : (<div></div>)}
|
362
458
|
<RailsData
|
363
|
-
key='
|
459
|
+
key='application_instance_hosts_data'
|
364
460
|
view='app_instance'
|
365
461
|
parameter='hosts'
|
366
462
|
value={JSON.stringify(this.props.hosts)}
|
367
463
|
/>
|
368
464
|
<RailsData
|
369
|
-
key='
|
465
|
+
key='application_instance_ansible_data'
|
370
466
|
view='app_instance'
|
371
467
|
parameter='ansible_vars_all'
|
372
468
|
value={JSON.stringify(this.props.ansibleVarsAll)}
|
@@ -377,6 +473,9 @@ class ApplicationInstance extends React.Component {
|
|
377
473
|
|
378
474
|
ApplicationInstance.defaultProps = {
|
379
475
|
error: {},
|
476
|
+
showAlertModal: false,
|
477
|
+
alertModalText: '',
|
478
|
+
alertModalTitle: '',
|
380
479
|
appDefinition: { "id": '', "name": '' },
|
381
480
|
editMode: false,
|
382
481
|
services: [],
|
@@ -385,16 +484,21 @@ ApplicationInstance.defaultProps = {
|
|
385
484
|
parametersData: {},
|
386
485
|
columns: [],
|
387
486
|
editParamsOfRowId: null,
|
487
|
+
paramEditMode: false,
|
388
488
|
}
|
389
489
|
|
390
490
|
ApplicationInstance.propTypes = {
|
391
491
|
initApplicationInstance: PropTypes.func,
|
492
|
+
showAlertModal: PropTypes.bool,
|
493
|
+
alertModalText: PropTypes.string,
|
494
|
+
alertModalTitle: PropTypes.string,
|
392
495
|
editMode: PropTypes.bool.isRequired,
|
393
496
|
services: PropTypes.array,
|
394
497
|
appDefinition: PropTypes.object,
|
395
498
|
columns: PropTypes.array,
|
396
499
|
hosts: PropTypes.array,
|
397
500
|
ansibleVarsAll: PropTypes.array,
|
501
|
+
closeAlertModal: PropTypes.func,
|
398
502
|
loadApplicationDefinition: PropTypes.func,
|
399
503
|
addApplicationInstanceHost: PropTypes.func,
|
400
504
|
deleteApplicationInstanceHost: PropTypes.func,
|
@@ -406,7 +510,11 @@ ApplicationInstance.propTypes = {
|
|
406
510
|
closeForemanParameterSelectionModal: PropTypes.func,
|
407
511
|
openAnsibleParameterSelectionModal: PropTypes.func,
|
408
512
|
closeAnsibleParameterSelectionModal: PropTypes.func,
|
513
|
+
openAddExistingHostsModal: PropTypes.func,
|
514
|
+
closeAddExistingHostsModal: PropTypes.func,
|
515
|
+
changeParameterSelectionMode: PropTypes.func,
|
409
516
|
parametersData: PropTypes.object,
|
517
|
+
paramEditMode: PropTypes.bool,
|
410
518
|
};
|
411
519
|
|
412
520
|
export default ApplicationInstance;
|
@@ -16,19 +16,24 @@ import {
|
|
16
16
|
|
17
17
|
import {
|
18
18
|
APPLICATION_INSTANCE_INIT,
|
19
|
+
APPLICATION_INSTANCE_CLOSE_ALERT_MODAL,
|
19
20
|
APPLICATION_INSTANCE_HOST_DELETE,
|
20
21
|
APPLICATION_INSTANCE_HOST_ADD,
|
21
22
|
APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
|
22
23
|
APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
23
24
|
APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
24
25
|
APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
26
|
+
APPLICATION_INSTANCE_HOST_EDIT_ERROR,
|
25
27
|
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
|
26
28
|
APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
|
27
29
|
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
|
28
30
|
APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
|
31
|
+
APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_OPEN,
|
32
|
+
APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_CLOSE,
|
29
33
|
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
|
30
34
|
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
|
31
35
|
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
|
36
|
+
APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE,
|
32
37
|
} from './ApplicationInstanceConstants';
|
33
38
|
|
34
39
|
export const initApplicationInstance = (
|
@@ -126,6 +131,11 @@ const errorHandler = (msg, err) => {
|
|
126
131
|
return { type: msg, payload: { error } };
|
127
132
|
};
|
128
133
|
|
134
|
+
export const closeAlertModal = () => ({
|
135
|
+
type: APPLICATION_INSTANCE_CLOSE_ALERT_MODAL,
|
136
|
+
payload: {}
|
137
|
+
});
|
138
|
+
|
129
139
|
export const loadApplicationDefinition = (
|
130
140
|
applicationDefinitionId,
|
131
141
|
additionalData,
|
@@ -166,12 +176,84 @@ export const activateEditApplicationInstanceHost = (additionalData) => ({
|
|
166
176
|
},
|
167
177
|
});
|
168
178
|
|
169
|
-
export const confirmEditApplicationInstanceHost = (
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
179
|
+
export const confirmEditApplicationInstanceHost = (
|
180
|
+
allData
|
181
|
+
) => async(dispatch) => {
|
182
|
+
|
183
|
+
// Host name can not be empty
|
184
|
+
|
185
|
+
if (allData.rowData.hostname == '') {
|
186
|
+
dispatch({
|
187
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_ERROR,
|
188
|
+
payload: __("Every host needs to have a valid name"),
|
189
|
+
});
|
190
|
+
return;
|
191
|
+
}
|
192
|
+
|
193
|
+
// Host name can only have specific characters
|
194
|
+
|
195
|
+
const hostname = allData.rowData.hostname.toLowerCase();
|
196
|
+
const hostnameRegex = /^[0-9a-z]([0-9a-z\-]{0,61}[0-9a-z])$/;
|
197
|
+
|
198
|
+
if (hostname.match(hostnameRegex) == undefined) {
|
199
|
+
dispatch({
|
200
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_ERROR,
|
201
|
+
payload: __("The hostname uses not allowed characters. See https://en.wikipedia.org/wiki/Hostname#Syntax for more details."),
|
202
|
+
});
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
|
206
|
+
// Service can not be empty
|
207
|
+
|
208
|
+
if (allData.rowData.service == '') {
|
209
|
+
dispatch({
|
210
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_ERROR,
|
211
|
+
payload: __("Every host needs to be assigned to a service."),
|
212
|
+
});
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
|
216
|
+
// Validation if host name is already used (only for new host entrys)
|
217
|
+
|
218
|
+
const url = '/acd/ui_acd_validate_hostname'
|
219
|
+
const validationData = {};
|
220
|
+
|
221
|
+
validationData['appDefId'] = allData.appDefinition.id;
|
222
|
+
validationData['serviceId'] = allData.rowData.service;
|
223
|
+
validationData['hostname'] = allData.rowData.hostname;
|
224
|
+
|
225
|
+
if (allData.rowData.newEntry === true) {
|
226
|
+
try {
|
227
|
+
const response = await api.get(url, {}, validationData);
|
228
|
+
|
229
|
+
if (response.data.result === true) {
|
230
|
+
dispatch({
|
231
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
232
|
+
payload: {
|
233
|
+
...allData,
|
234
|
+
}
|
235
|
+
});
|
236
|
+
} else {
|
237
|
+
dispatch({
|
238
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_ERROR,
|
239
|
+
payload: __('Hostname \''+ allData.rowData.hostname +'\' is already used. This check also includes hosts outside this application instance.'),
|
240
|
+
});
|
241
|
+
}
|
242
|
+
} catch (error) {
|
243
|
+
dispatch({
|
244
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_ERROR,
|
245
|
+
payload: __('Error during validation if hostname is already used.'),
|
246
|
+
});
|
247
|
+
}
|
248
|
+
} else {
|
249
|
+
dispatch({
|
250
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
251
|
+
payload: {
|
252
|
+
...allData,
|
253
|
+
}
|
254
|
+
});
|
255
|
+
}
|
256
|
+
};
|
175
257
|
|
176
258
|
export const cancelEditApplicationInstanceHost = (rowData) => ({
|
177
259
|
type: APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
@@ -237,3 +319,35 @@ export const closeAnsibleParameterSelectionModal = (additionalData) => dispatch
|
|
237
319
|
setModalClosed({ id: 'AppInstanceAnsibleParamSelection' })
|
238
320
|
);
|
239
321
|
}
|
322
|
+
|
323
|
+
export const openAddExistingHostsModal = (additionalData) => dispatch => {
|
324
|
+
dispatch({
|
325
|
+
type: APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_OPEN,
|
326
|
+
payload: {
|
327
|
+
...additionalData,
|
328
|
+
}
|
329
|
+
});
|
330
|
+
dispatch(
|
331
|
+
setModalOpen({ id: 'AppInstanceAddExistingHosts' })
|
332
|
+
);
|
333
|
+
}
|
334
|
+
|
335
|
+
export const closeAddExistingHostsModal = (additionalData) => dispatch => {
|
336
|
+
dispatch({
|
337
|
+
type: APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_CLOSE,
|
338
|
+
payload: {
|
339
|
+
...additionalData,
|
340
|
+
}
|
341
|
+
});
|
342
|
+
|
343
|
+
dispatch(
|
344
|
+
setModalClosed({ id: 'AppInstanceAddExistingHosts' })
|
345
|
+
);
|
346
|
+
}
|
347
|
+
|
348
|
+
export const changeParameterSelectionMode = (additionalData) => ({
|
349
|
+
type: APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE,
|
350
|
+
payload: {
|
351
|
+
...additionalData,
|
352
|
+
},
|
353
|
+
})
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export const APPLICATION_INSTANCE_INIT = 'APPLICATION_INSTANCE_INIT';
|
2
|
+
export const APPLICATION_INSTANCE_CLOSE_ALERT_MODAL = 'APPLICATION_INSTANCE_CLOSE_ALERT_MODAL';
|
2
3
|
export const APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST = 'APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST';
|
3
4
|
export const APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS = 'APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS';
|
4
5
|
export const APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE = 'APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE';
|
@@ -8,7 +9,11 @@ export const APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE = 'APPLICATION_INSTANCE_HOS
|
|
8
9
|
export const APPLICATION_INSTANCE_HOST_EDIT_CONFIRM = 'APPLICATION_INSTANCE_HOST_EDIT_CONFIRM';
|
9
10
|
export const APPLICATION_INSTANCE_HOST_EDIT_CHANGE = 'APPLICATION_INSTANCE_HOST_EDIT_CHANGE';
|
10
11
|
export const APPLICATION_INSTANCE_HOST_EDIT_CANCEL = 'APPLICATION_INSTANCE_HOST_EDIT_CANCEL';
|
12
|
+
export const APPLICATION_INSTANCE_HOST_EDIT_ERROR = 'APPLICATION_INSTANCE_HOST_EDIT_ERROR';
|
11
13
|
export const APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN';
|
12
14
|
export const APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE';
|
13
15
|
export const APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN';
|
14
16
|
export const APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE';
|
17
|
+
export const APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_OPEN = 'APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_OPEN';
|
18
|
+
export const APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_CLOSE = 'APPLICATION_INSTANCE_ADD_EXISTING_HOSTS_MODAL_CLOSE';
|
19
|
+
export const APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE = 'APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE';
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
function calculateServiceUsage(hostServiceId, services) {
|
3
|
+
const service = services.find(serv => serv['id'] == hostServiceId);
|
4
|
+
if ('currentCount' in service) {
|
5
|
+
service['currentCount'] += 1;
|
6
|
+
} else {
|
7
|
+
service['currentCount'] = 1;
|
8
|
+
}
|
9
|
+
|
10
|
+
return services;
|
11
|
+
}
|
12
|
+
|
13
|
+
export {
|
14
|
+
calculateServiceUsage,
|
15
|
+
};
|