foreman_acd 0.6.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +90 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +104 -7
- data/app/controllers/foreman_acd/app_instances_controller.rb +34 -32
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
- data/app/controllers/foreman_acd/remote_execution_controller.rb +37 -21
- data/app/controllers/ui_acd_controller.rb +42 -3
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +12 -7
- data/app/lib/actions/foreman_acd/run_configurator.rb +11 -7
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +41 -28
- data/app/models/foreman_acd/acd_provider.rb +7 -1
- data/app/models/foreman_acd/ansible_playbook.rb +2 -1
- data/app/models/foreman_acd/app_instance.rb +48 -3
- data/app/models/foreman_acd/foreman_host.rb +8 -0
- data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +59 -15
- data/app/services/foreman_acd/app_deployer.rb +27 -4
- data/app/services/foreman_acd/inventory_creator.rb +25 -1
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +41 -7
- data/app/views/foreman_acd/app_definitions/_form.html.erb +5 -1
- data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
- data/app/views/foreman_acd/app_definitions/index.html.erb +3 -6
- data/app/views/foreman_acd/app_instances/_form.html.erb +5 -1
- data/app/views/foreman_acd/app_instances/index.html.erb +18 -12
- data/app/views/foreman_acd/app_instances/report.html.erb +8 -3
- data/app/views/templates/job/run_acd_ansible_playbook.erb +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 +6 -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/75-job_templates.rb +1 -1
- data/lib/foreman_acd/engine.rb +26 -4
- data/lib/foreman_acd/plugin.rb +9 -18
- 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/package.json +8 -22
- data/test/controllers/ansible_playbooks_controller_test.rb +1 -1
- data/test/controllers/app_instances_controller_test.rb +8 -3
- data/test/controllers/ui_acd_controller_test.rb +25 -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 +35 -11
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +12 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +30 -9
- 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 +53 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +226 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +307 -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 +105 -31
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +118 -6
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +71 -30
- 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 +56 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +300 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +284 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
- 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 +81 -6
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +35 -1
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +3 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
- 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/__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 -1
- 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 +103 -1
- data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +46 -4
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +2 -0
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +5 -1
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +51 -29
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -0
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +124 -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 +12 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1589 -878
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +130 -79
- data/webpack/components/ParameterSelection/index.js +4 -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 +16 -2
- data/webpack/components/common/ExtTextInput.js +43 -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 +35 -1
- data/webpack/helper.test.js +56 -0
- data/webpack/index.js +7 -0
- data/webpack/js-yaml.js +3874 -0
- data/webpack/reducer.js +16 -1
- data/webpack/test_setup.js +0 -2
- metadata +136 -11
- 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
@@ -0,0 +1,90 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
|
3
|
+
import {
|
4
|
+
cloneDeep,
|
5
|
+
findIndex,
|
6
|
+
findLastIndex,
|
7
|
+
} from 'lodash';
|
8
|
+
|
9
|
+
import { shortHostname } from '../../helper';
|
10
|
+
import * as sort from 'sortabular';
|
11
|
+
|
12
|
+
import {
|
13
|
+
EXISTING_HOST_SELECTION_INIT,
|
14
|
+
EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
|
15
|
+
EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE,
|
16
|
+
EXISTING_HOST_SELECTION_SELECTION_CHANGED,
|
17
|
+
} from './ExistingHostSelectionConstants';
|
18
|
+
|
19
|
+
export const initialState = Immutable({
|
20
|
+
serviceId: undefined,
|
21
|
+
error: { errorMsg: '', status: '', statusText: '' },
|
22
|
+
});
|
23
|
+
|
24
|
+
const existingHostSelectionConf = (state = initialState, action) => {
|
25
|
+
const { payload } = action;
|
26
|
+
|
27
|
+
switch (action.type) {
|
28
|
+
case EXISTING_HOST_SELECTION_INIT: {
|
29
|
+
return state.merge(payload);
|
30
|
+
}
|
31
|
+
case EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS: {
|
32
|
+
let alreadyUsedHosts = [];
|
33
|
+
|
34
|
+
state.allHosts.forEach(host => {
|
35
|
+
if ((host.service == payload.serviceId) && (host.isExistingHost == true)) {
|
36
|
+
alreadyUsedHosts.push({
|
37
|
+
value: host.hostname,
|
38
|
+
label: host.hostname,
|
39
|
+
disabled: true,
|
40
|
+
tooltipText: __('Host already used for this application instance'),
|
41
|
+
});
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
let availableHosts = [];
|
46
|
+
let hostsInHostgroup = {};
|
47
|
+
payload.hosts.forEach(host => {
|
48
|
+
let shortName = shortHostname(host.name);
|
49
|
+
if (state.allHosts.find(h => h.hostname == shortName) == undefined) {
|
50
|
+
availableHosts.push({
|
51
|
+
value: shortName,
|
52
|
+
label: shortName,
|
53
|
+
});
|
54
|
+
}
|
55
|
+
hostsInHostgroup[shortName] = host;
|
56
|
+
});
|
57
|
+
|
58
|
+
return state.merge({
|
59
|
+
hostsInHostgroup: hostsInHostgroup,
|
60
|
+
availableHosts: availableHosts,
|
61
|
+
alreadyUsedHosts: alreadyUsedHosts,
|
62
|
+
serviceId: payload.serviceId,
|
63
|
+
});
|
64
|
+
}
|
65
|
+
case EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE: {
|
66
|
+
return state.merge({ error: payload.error });
|
67
|
+
}
|
68
|
+
case EXISTING_HOST_SELECTION_SELECTION_CHANGED: {
|
69
|
+
let selectedHosts = [];
|
70
|
+
|
71
|
+
payload.selection.forEach(selHost => {
|
72
|
+
let hostData = state.hostsInHostgroup[selHost.value];
|
73
|
+
selectedHosts.push({
|
74
|
+
fqdn: hostData.name,
|
75
|
+
hostname: shortHostname(hostData.name),
|
76
|
+
hostgroupId: hostData.hostgroup_id,
|
77
|
+
serviceId: state.serviceId,
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
return state.merge({
|
82
|
+
selectedHosts: selectedHosts,
|
83
|
+
});
|
84
|
+
}
|
85
|
+
default:
|
86
|
+
return state;
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
export default existingHostSelectionConf;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
const existingHostState = state => state.foremanAcd.existingHostSelectionConf;
|
2
|
+
|
3
|
+
export const selectServiceId = state => existingHostState(state).serviceId;
|
4
|
+
export const selectAllHosts = state => existingHostState(state).allHosts;
|
5
|
+
export const selectHostsInHostgroup = state => existingHostState(state).selectHostsInHostgroup;
|
6
|
+
export const selectAvailableHosts = state => existingHostState(state).availableHosts;
|
7
|
+
export const selectAlreadyUsedHosts = state => existingHostState(state).alreadyUsedHosts;
|
8
|
+
export const selectSelectedHosts = state => existingHostState(state).selectedHosts;
|
@@ -0,0 +1,191 @@
|
|
1
|
+
export const existingHostSelectionConfData_1 = {
|
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: [
|
75
|
+
'build'
|
76
|
+
],
|
77
|
+
provision_method: 'build',
|
78
|
+
certname: 'isaac-anselm.mylocal',
|
79
|
+
image_id: null,
|
80
|
+
image_name: null,
|
81
|
+
created_at: '2021-08-05 11:16:34 +0200',
|
82
|
+
updated_at: '2021-08-05 11:16:34 +0200',
|
83
|
+
last_compile: null,
|
84
|
+
global_status: 0,
|
85
|
+
global_status_label: 'Error',
|
86
|
+
uptime_seconds: null,
|
87
|
+
organization_id: 1,
|
88
|
+
organization_name: 'Default Organization',
|
89
|
+
location_id: 2,
|
90
|
+
location_name: 'Default Location',
|
91
|
+
puppet_status: 0,
|
92
|
+
model_name: null,
|
93
|
+
build_status: 2,
|
94
|
+
build_status_label: 'Token expired',
|
95
|
+
name: 'isaac-anselm.mylocal',
|
96
|
+
id: 3,
|
97
|
+
puppet_proxy_id: null,
|
98
|
+
puppet_proxy_name: null,
|
99
|
+
puppet_ca_proxy_id: null,
|
100
|
+
puppet_ca_proxy_name: null,
|
101
|
+
puppet_proxy: null,
|
102
|
+
puppet_ca_proxy: null,
|
103
|
+
hostgroup_name: 'base',
|
104
|
+
hostgroup_title: 'base'
|
105
|
+
},
|
106
|
+
'7': {
|
107
|
+
ip: null,
|
108
|
+
ip6: null,
|
109
|
+
environment_id: null,
|
110
|
+
environment_name: null,
|
111
|
+
last_report: null,
|
112
|
+
mac: '00:11:22:33:60:15',
|
113
|
+
realm_id: null,
|
114
|
+
realm_name: null,
|
115
|
+
sp_mac: null,
|
116
|
+
sp_ip: null,
|
117
|
+
sp_name: null,
|
118
|
+
domain_id: 1,
|
119
|
+
domain_name: 'mylocal',
|
120
|
+
architecture_id: 1,
|
121
|
+
architecture_name: 'x86_64',
|
122
|
+
operatingsystem_id: 1,
|
123
|
+
operatingsystem_name: 'centos 7',
|
124
|
+
subnet_id: 1,
|
125
|
+
subnet_name: 'mylocal',
|
126
|
+
subnet6_id: null,
|
127
|
+
subnet6_name: null,
|
128
|
+
sp_subnet_id: null,
|
129
|
+
ptable_id: 118,
|
130
|
+
ptable_name: 'Kickstart default',
|
131
|
+
medium_id: 1,
|
132
|
+
medium_name: 'CentOS 7 mirror',
|
133
|
+
pxe_loader: 'PXELinux BIOS',
|
134
|
+
build: true,
|
135
|
+
comment: null,
|
136
|
+
disk: null,
|
137
|
+
installed_at: null,
|
138
|
+
model_id: null,
|
139
|
+
hostgroup_id: 1,
|
140
|
+
owner_id: 4,
|
141
|
+
owner_name: 'Admin User',
|
142
|
+
owner_type: 'User',
|
143
|
+
enabled: true,
|
144
|
+
managed: true,
|
145
|
+
use_image: null,
|
146
|
+
image_file: '',
|
147
|
+
uuid: null,
|
148
|
+
compute_resource_id: null,
|
149
|
+
compute_resource_name: null,
|
150
|
+
compute_profile_id: null,
|
151
|
+
compute_profile_name: null,
|
152
|
+
capabilities: [
|
153
|
+
'build'
|
154
|
+
],
|
155
|
+
provision_method: 'build',
|
156
|
+
certname: 'lllllll.mylocal',
|
157
|
+
image_id: null,
|
158
|
+
image_name: null,
|
159
|
+
created_at: '2021-08-19 14:00:20 +0200',
|
160
|
+
updated_at: '2021-08-19 14:00:20 +0200',
|
161
|
+
last_compile: null,
|
162
|
+
global_status: 0,
|
163
|
+
global_status_label: 'Error',
|
164
|
+
uptime_seconds: null,
|
165
|
+
organization_id: 1,
|
166
|
+
organization_name: 'Default Organization',
|
167
|
+
location_id: 2,
|
168
|
+
location_name: 'Default Location',
|
169
|
+
puppet_status: 0,
|
170
|
+
model_name: null,
|
171
|
+
build_status: 2,
|
172
|
+
build_status_label: 'Token expired',
|
173
|
+
name: 'lllllll.mylocal',
|
174
|
+
id: 7,
|
175
|
+
puppet_proxy_id: null,
|
176
|
+
puppet_proxy_name: null,
|
177
|
+
puppet_ca_proxy_id: null,
|
178
|
+
puppet_ca_proxy_name: null,
|
179
|
+
puppet_proxy: null,
|
180
|
+
puppet_ca_proxy: null,
|
181
|
+
hostgroup_name: 'base',
|
182
|
+
hostgroup_title: 'base'
|
183
|
+
}
|
184
|
+
},
|
185
|
+
availableHosts: [
|
186
|
+
{
|
187
|
+
value: 'lllllll',
|
188
|
+
label: 'lllllll'
|
189
|
+
}
|
190
|
+
]
|
191
|
+
}
|
data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import {
|
3
|
+
cloneDeep,
|
4
|
+
findIndex,
|
5
|
+
findLastIndex,
|
6
|
+
} from 'lodash';
|
7
|
+
|
8
|
+
import {
|
9
|
+
existingHostSelectionConfData_1,
|
10
|
+
} from '../__fixtures__/existingHostSelectionConfData_1.fixtures';
|
11
|
+
|
12
|
+
export const successState = Immutable(existingHostSelectionConfData_1);
|
13
|
+
|
14
|
+
export const initExistingHostSelectionPayload = {
|
15
|
+
payload: {
|
16
|
+
serviceId: 2,
|
17
|
+
alreadyUsedHosts: [
|
18
|
+
{
|
19
|
+
value: 5,
|
20
|
+
label: 'isaac-anselm',
|
21
|
+
disabled: true,
|
22
|
+
tooltipText: 'Host already used for this application instance'
|
23
|
+
}
|
24
|
+
],
|
25
|
+
selectedHosts: [],
|
26
|
+
hostsInHostgroup: {},
|
27
|
+
}
|
28
|
+
};
|
29
|
+
|
30
|
+
export const existingHostSelectionSelectionChangedPayload = {
|
31
|
+
selection: [
|
32
|
+
{
|
33
|
+
label: 'isaar-anselm',
|
34
|
+
value: 3,
|
35
|
+
},
|
36
|
+
]
|
37
|
+
};
|
38
|
+
|
39
|
+
export const loadExistingHostSelectionSuccessPayload = {
|
40
|
+
hosts: [
|
41
|
+
{
|
42
|
+
ip: null,
|
43
|
+
ip6: '',
|
44
|
+
environment_id: null,
|
45
|
+
environment_name: null,
|
46
|
+
last_report: null,
|
47
|
+
mac: '00:11:22:33:44:a1',
|
48
|
+
realm_id: null,
|
49
|
+
realm_name: null,
|
50
|
+
sp_mac: null,
|
51
|
+
sp_ip: null,
|
52
|
+
sp_name: null,
|
53
|
+
domain_id: 1,
|
54
|
+
domain_name: 'mylocal',
|
55
|
+
architecture_id: 1,
|
56
|
+
architecture_name: 'x86_64',
|
57
|
+
operatingsystem_id: 1,
|
58
|
+
operatingsystem_name: 'centos 7',
|
59
|
+
subnet_id: 1,
|
60
|
+
subnet_name: 'mylocal',
|
61
|
+
subnet6_id: null,
|
62
|
+
subnet6_name: null,
|
63
|
+
sp_subnet_id: null,
|
64
|
+
ptable_id: 118,
|
65
|
+
ptable_name: 'Kickstart default',
|
66
|
+
medium_id: 1,
|
67
|
+
medium_name: 'CentOS 7 mirror',
|
68
|
+
pxe_loader: 'PXELinux BIOS',
|
69
|
+
build: true,
|
70
|
+
comment: '',
|
71
|
+
disk: '',
|
72
|
+
installed_at: null,
|
73
|
+
model_id: null,
|
74
|
+
hostgroup_id: 1,
|
75
|
+
owner_id: 4,
|
76
|
+
owner_name: 'Admin User',
|
77
|
+
owner_type: 'User',
|
78
|
+
enabled: true,
|
79
|
+
managed: true,
|
80
|
+
use_image: null,
|
81
|
+
image_file: '',
|
82
|
+
uuid: null,
|
83
|
+
compute_resource_id: null,
|
84
|
+
compute_resource_name: null,
|
85
|
+
compute_profile_id: null,
|
86
|
+
compute_profile_name: null,
|
87
|
+
capabilities: [
|
88
|
+
'build'
|
89
|
+
],
|
90
|
+
provision_method: 'build',
|
91
|
+
certname: 'isaac-anselm.mylocal',
|
92
|
+
image_id: null,
|
93
|
+
image_name: null,
|
94
|
+
created_at: '2021-08-05 11:16:34 +0200',
|
95
|
+
updated_at: '2021-08-05 11:16:34 +0200',
|
96
|
+
last_compile: null,
|
97
|
+
global_status: 0,
|
98
|
+
global_status_label: 'Error',
|
99
|
+
uptime_seconds: null,
|
100
|
+
organization_id: 1,
|
101
|
+
organization_name: 'Default Organization',
|
102
|
+
location_id: 2,
|
103
|
+
location_name: 'Default Location',
|
104
|
+
puppet_status: 0,
|
105
|
+
model_name: null,
|
106
|
+
build_status: 2,
|
107
|
+
build_status_label: 'Token expired',
|
108
|
+
name: 'isaac-anselm.mylocal',
|
109
|
+
id: 3,
|
110
|
+
puppet_proxy_id: null,
|
111
|
+
puppet_proxy_name: null,
|
112
|
+
puppet_ca_proxy_id: null,
|
113
|
+
puppet_ca_proxy_name: null,
|
114
|
+
puppet_proxy: null,
|
115
|
+
puppet_ca_proxy: null,
|
116
|
+
hostgroup_name: 'base',
|
117
|
+
hostgroup_title: 'base'
|
118
|
+
},
|
119
|
+
{
|
120
|
+
ip: null,
|
121
|
+
ip6: null,
|
122
|
+
environment_id: null,
|
123
|
+
environment_name: null,
|
124
|
+
last_report: null,
|
125
|
+
mac: '00:11:22:33:60:15',
|
126
|
+
realm_id: null,
|
127
|
+
realm_name: null,
|
128
|
+
sp_mac: null,
|
129
|
+
sp_ip: null,
|
130
|
+
sp_name: null,
|
131
|
+
domain_id: 1,
|
132
|
+
domain_name: 'mylocal',
|
133
|
+
architecture_id: 1,
|
134
|
+
architecture_name: 'x86_64',
|
135
|
+
operatingsystem_id: 1,
|
136
|
+
operatingsystem_name: 'centos 7',
|
137
|
+
subnet_id: 1,
|
138
|
+
subnet_name: 'mylocal',
|
139
|
+
subnet6_id: null,
|
140
|
+
subnet6_name: null,
|
141
|
+
sp_subnet_id: null,
|
142
|
+
ptable_id: 118,
|
143
|
+
ptable_name: 'Kickstart default',
|
144
|
+
medium_id: 1,
|
145
|
+
medium_name: 'CentOS 7 mirror',
|
146
|
+
pxe_loader: 'PXELinux BIOS',
|
147
|
+
build: true,
|
148
|
+
comment: null,
|
149
|
+
disk: null,
|
150
|
+
installed_at: null,
|
151
|
+
model_id: null,
|
152
|
+
hostgroup_id: 1,
|
153
|
+
owner_id: 4,
|
154
|
+
owner_name: 'Admin User',
|
155
|
+
owner_type: 'User',
|
156
|
+
enabled: true,
|
157
|
+
managed: true,
|
158
|
+
use_image: null,
|
159
|
+
image_file: '',
|
160
|
+
uuid: null,
|
161
|
+
compute_resource_id: null,
|
162
|
+
compute_resource_name: null,
|
163
|
+
compute_profile_id: null,
|
164
|
+
compute_profile_name: null,
|
165
|
+
capabilities: [
|
166
|
+
'build'
|
167
|
+
],
|
168
|
+
provision_method: 'build',
|
169
|
+
certname: 'lllllll.mylocal',
|
170
|
+
image_id: null,
|
171
|
+
image_name: null,
|
172
|
+
created_at: '2021-08-19 14:00:20 +0200',
|
173
|
+
updated_at: '2021-08-19 14:00:20 +0200',
|
174
|
+
last_compile: null,
|
175
|
+
global_status: 0,
|
176
|
+
global_status_label: 'Error',
|
177
|
+
uptime_seconds: null,
|
178
|
+
organization_id: 1,
|
179
|
+
organization_name: 'Default Organization',
|
180
|
+
location_id: 2,
|
181
|
+
location_name: 'Default Location',
|
182
|
+
puppet_status: 0,
|
183
|
+
model_name: null,
|
184
|
+
build_status: 2,
|
185
|
+
build_status_label: 'Token expired',
|
186
|
+
name: 'lllllll.mylocal',
|
187
|
+
id: 7,
|
188
|
+
puppet_proxy_id: null,
|
189
|
+
puppet_proxy_name: null,
|
190
|
+
puppet_ca_proxy_id: null,
|
191
|
+
puppet_ca_proxy_name: null,
|
192
|
+
puppet_proxy: null,
|
193
|
+
puppet_ca_proxy: null,
|
194
|
+
hostgroup_name: 'base',
|
195
|
+
hostgroup_title: 'base'
|
196
|
+
}
|
197
|
+
],
|
198
|
+
serviceId: 1
|
199
|
+
};
|
200
|
+
|
201
|
+
export const loadExistingHostSelectionFailurePayload = {
|
202
|
+
error: "Something really bad happend",
|
203
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import ExistingHostSelection from '../ExistingHostSelection';
|
4
|
+
|
5
|
+
const noop = () => {};
|
6
|
+
|
7
|
+
const fixtures = {
|
8
|
+
'should render existing host selection': {
|
9
|
+
location: "Default Location",
|
10
|
+
organization: "Default Organization",
|
11
|
+
services: [],
|
12
|
+
allHosts: [],
|
13
|
+
initExistingHostSelection: noop,
|
14
|
+
loadHostsOfHostgroup: noop,
|
15
|
+
},
|
16
|
+
};
|
17
|
+
|
18
|
+
describe('ExistingHostSelection', () =>
|
19
|
+
testComponentSnapshotsWithFixtures(ExistingHostSelection, fixtures));
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
import reducer, { initialState } from '../ExistingHostSelectionReducer';
|
3
|
+
|
4
|
+
import {
|
5
|
+
successState,
|
6
|
+
initExistingHostSelectionPayload,
|
7
|
+
existingHostSelectionSelectionChangedPayload,
|
8
|
+
loadExistingHostSelectionSuccessPayload,
|
9
|
+
loadExistingHostSelectionFailurePayload,
|
10
|
+
} from '../__fixtures__/existingHostSelectionReducer.fixtures';
|
11
|
+
|
12
|
+
import {
|
13
|
+
EXISTING_HOST_SELECTION_INIT,
|
14
|
+
EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
|
15
|
+
EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE,
|
16
|
+
EXISTING_HOST_SELECTION_SELECTION_CHANGED,
|
17
|
+
} from '../ExistingHostSelectionConstants';
|
18
|
+
|
19
|
+
const fixtures = {
|
20
|
+
'should return initial state': {
|
21
|
+
state: initialState,
|
22
|
+
action: {
|
23
|
+
type: undefined,
|
24
|
+
payload: {},
|
25
|
+
},
|
26
|
+
},
|
27
|
+
|
28
|
+
'should initialize component': {
|
29
|
+
state: initialState,
|
30
|
+
action: {
|
31
|
+
type: EXISTING_HOST_SELECTION_INIT,
|
32
|
+
payload: initExistingHostSelectionPayload,
|
33
|
+
},
|
34
|
+
},
|
35
|
+
'should handle changed existiong host selection': {
|
36
|
+
state: successState,
|
37
|
+
action: {
|
38
|
+
type: EXISTING_HOST_SELECTION_SELECTION_CHANGED,
|
39
|
+
payload: existingHostSelectionSelectionChangedPayload,
|
40
|
+
},
|
41
|
+
},
|
42
|
+
'should load host data be successful': {
|
43
|
+
state: successState,
|
44
|
+
action: {
|
45
|
+
type: EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
|
46
|
+
payload: loadExistingHostSelectionSuccessPayload,
|
47
|
+
},
|
48
|
+
},
|
49
|
+
'should load host data be erroneous': {
|
50
|
+
state: successState,
|
51
|
+
action: {
|
52
|
+
type: EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE,
|
53
|
+
payload: loadExistingHostSelectionFailurePayload,
|
54
|
+
},
|
55
|
+
},
|
56
|
+
};
|
57
|
+
|
58
|
+
describe('ExistingHostSelectionReducer', () =>
|
59
|
+
testReducerSnapshotWithFixtures(reducer, fixtures));
|
data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
|
2
|
+
|
3
|
+
import {
|
4
|
+
selectServiceId,
|
5
|
+
selectAvailableHosts,
|
6
|
+
selectAlreadyUsedHosts,
|
7
|
+
selectSelectedHosts,
|
8
|
+
selectHostsInHostgroup,
|
9
|
+
} from '../ExistingHostSelectionSelectors';
|
10
|
+
|
11
|
+
import {
|
12
|
+
existingHostSelectionConfData_1,
|
13
|
+
} from '../__fixtures__/existingHostSelectionConfData_1.fixtures';
|
14
|
+
|
15
|
+
const stateFactory = obj => ({
|
16
|
+
foremanAcd: {
|
17
|
+
existingHostSelectionConf: obj,
|
18
|
+
},
|
19
|
+
});
|
20
|
+
|
21
|
+
const fixtures = {
|
22
|
+
'should return serviceId from existingHostSelectionConfData_1 fixtures': () =>
|
23
|
+
selectServiceId(stateFactory(existingHostSelectionConfData_1)),
|
24
|
+
'should return availableHosts from existingHostSelectionConfData_1 fixtures': () =>
|
25
|
+
selectAvailableHosts(stateFactory(existingHostSelectionConfData_1)),
|
26
|
+
'should return alreadyUsedHosts from existingHostSelectionConfData_1 fixtures': () =>
|
27
|
+
selectAlreadyUsedHosts(stateFactory(existingHostSelectionConfData_1)),
|
28
|
+
'should return selectedHosts from existingHostSelectionConfData_1 fixtures': () =>
|
29
|
+
selectSelectedHosts(stateFactory(existingHostSelectionConfData_1)),
|
30
|
+
'should return hostsInHostgroup from existingHostSelectionConfData_1 fixtures': () =>
|
31
|
+
selectHostsInHostgroup(stateFactory(existingHostSelectionConfData_1)),
|
32
|
+
};
|
33
|
+
|
34
|
+
describe('ExistingHostSelectionSelectors', () =>
|
35
|
+
testSelectorsSnapshotWithFixtures(fixtures));
|
36
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ExistingHostSelection should render existing host selection 1`] = `
|
4
|
+
<div>
|
5
|
+
<div
|
6
|
+
className="row"
|
7
|
+
>
|
8
|
+
<ServiceSelector
|
9
|
+
additionalData={
|
10
|
+
Object {
|
11
|
+
"services": Array [],
|
12
|
+
"url": "/api/v2/hostgroups/__hostgroup_id__/hosts",
|
13
|
+
}
|
14
|
+
}
|
15
|
+
hidden={false}
|
16
|
+
label="Service"
|
17
|
+
onChange={[Function]}
|
18
|
+
options={Object {}}
|
19
|
+
selectValue="0"
|
20
|
+
/>
|
21
|
+
</div>
|
22
|
+
<div
|
23
|
+
className="row"
|
24
|
+
>
|
25
|
+
<label
|
26
|
+
className="col-md-2 control-label"
|
27
|
+
>
|
28
|
+
Hosts
|
29
|
+
</label>
|
30
|
+
<span>
|
31
|
+
Please select service first.
|
32
|
+
</span>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
`;
|