foreman_acd 0.2.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +107 -56
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +199 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +19 -10
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +111 -137
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  10. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  11. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/remote_execution_controller.rb +62 -0
  13. data/app/controllers/ui_acd_controller.rb +20 -3
  14. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
  15. data/app/lib/actions/foreman_acd/run_configurator.rb +44 -0
  16. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
  17. data/app/models/foreman_acd/acd_provider.rb +36 -0
  18. data/app/models/foreman_acd/ansible_playbook.rb +68 -0
  19. data/app/models/foreman_acd/app_definition.rb +25 -0
  20. data/app/models/foreman_acd/app_instance.rb +42 -0
  21. data/app/models/foreman_acd/foreman_host.rb +23 -0
  22. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  23. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  24. data/app/services/foreman_acd/app_configurator.rb +98 -0
  25. data/app/services/foreman_acd/app_deployer.rb +157 -0
  26. data/app/services/foreman_acd/inventory_creator.rb +68 -0
  27. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +64 -0
  28. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
  29. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  30. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
  32. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
  33. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
  35. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
  36. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
  38. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
  39. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
  40. data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -12
  41. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
  42. data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
  43. data/app/views/foreman_acd/app_instances/_form.html.erb +11 -9
  44. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  45. data/app/views/foreman_acd/app_instances/index.html.erb +89 -10
  46. data/app/views/foreman_acd/app_instances/report.html.erb +6 -3
  47. data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
  48. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  49. data/app/views/ui_acd/app.json.rabl +6 -2
  50. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  51. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  52. data/config/routes.rb +32 -2
  53. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  54. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  55. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
  56. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
  57. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  58. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  59. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  60. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  61. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  62. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  63. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  64. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  65. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  66. data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
  67. data/db/seeds.d/75-job_templates.rb +13 -0
  68. data/lib/foreman_acd.rb +12 -0
  69. data/lib/foreman_acd/engine.rb +43 -3
  70. data/lib/foreman_acd/plugin.rb +88 -22
  71. data/lib/foreman_acd/version.rb +1 -1
  72. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  73. data/locale/en/foreman_acd.edit.po +326 -0
  74. data/locale/en/foreman_acd.po +232 -2
  75. data/locale/en/foreman_acd.po.time_stamp +0 -0
  76. data/locale/foreman_acd.pot +343 -8
  77. data/package.json +9 -9
  78. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  79. data/test/controllers/app_instances_controller_test.rb +8 -3
  80. data/test/controllers/ui_acd_controller_test.rb +22 -6
  81. data/test/factories/foreman_acd_factories.rb +18 -4
  82. data/test/models/acd_provider_test.rb +37 -0
  83. data/test/models/ansible_playbook_test.rb +11 -0
  84. data/test/models/app_definition_test.rb +1 -1
  85. data/test/models/app_instance_test.rb +2 -0
  86. data/test/models/concerns/host_extensions_test.rb +26 -0
  87. data/test/models/foreman_host_test.rb +12 -0
  88. data/webpack/__mocks__/foremanReact/API.js +2 -0
  89. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  90. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  91. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  92. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  93. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  94. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  95. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  96. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +159 -29
  97. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +106 -14
  98. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +8 -2
  99. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  100. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +143 -21
  101. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
  102. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  103. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  104. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
  105. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  106. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
  107. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
  108. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  109. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
  110. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +50 -0
  111. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  112. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  113. data/webpack/components/ApplicationDefinition/index.js +6 -0
  114. data/webpack/components/ApplicationInstance/ApplicationInstance.js +151 -44
  115. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +47 -10
  116. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -2
  117. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -28
  118. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -1
  119. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  120. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
  121. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
  122. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
  123. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
  124. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
  125. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
  126. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
  127. data/webpack/components/ApplicationInstance/components/Service.js +1 -1
  128. data/webpack/components/ApplicationInstance/index.js +4 -0
  129. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
  130. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
  131. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
  132. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
  133. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
  134. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
  135. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  136. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  137. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  138. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  139. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  140. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
  141. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  142. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  143. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
  144. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  145. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  146. data/webpack/components/ApplicationInstanceReport/index.js +0 -2
  147. data/webpack/components/ParameterSelection/ParameterSelection.js +85 -50
  148. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +68 -62
  149. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +6 -3
  150. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
  151. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +47 -35
  152. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
  153. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
  154. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  155. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  156. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
  157. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  158. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
  159. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
  160. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
  161. data/webpack/components/ParameterSelection/index.js +4 -4
  162. data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
  163. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  164. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
  165. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
  166. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  167. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  168. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  169. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  170. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  171. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  172. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  173. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
  174. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  175. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  176. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  177. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
  178. data/webpack/components/SyncGitRepo/index.js +28 -0
  179. data/webpack/components/common/DeleteTableEntry.js +3 -3
  180. data/webpack/components/common/EditTableEntry.js +50 -0
  181. data/webpack/components/common/ExtTextInput.js +43 -0
  182. data/webpack/components/common/LockTableEntry.js +60 -0
  183. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  184. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  185. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
  186. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  187. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  188. data/webpack/helper.js +15 -1
  189. data/webpack/helper.test.js +37 -0
  190. data/webpack/index.js +2 -0
  191. data/webpack/reducer.js +18 -11
  192. metadata +184 -10
  193. data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
  194. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  195. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -8,5 +8,8 @@ export const APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE = 'APPLICATION_INSTANCE_HOS
8
8
  export const APPLICATION_INSTANCE_HOST_EDIT_CONFIRM = 'APPLICATION_INSTANCE_HOST_EDIT_CONFIRM';
9
9
  export const APPLICATION_INSTANCE_HOST_EDIT_CHANGE = 'APPLICATION_INSTANCE_HOST_EDIT_CHANGE';
10
10
  export const APPLICATION_INSTANCE_HOST_EDIT_CANCEL = 'APPLICATION_INSTANCE_HOST_EDIT_CANCEL';
11
- export const APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN';
12
- export const APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE';
11
+ export const APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN';
12
+ export const APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE';
13
+ export const APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN';
14
+ export const APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE';
15
+ export const APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE = 'APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE';
@@ -17,10 +17,18 @@ import {
17
17
  APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
18
18
  APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
19
19
  APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
20
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
21
- APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
20
+ APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
21
+ APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
22
+ APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
23
+ APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
24
+ APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE,
22
25
  } from './ApplicationInstanceConstants';
23
26
 
27
+ import {
28
+ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
29
+ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
30
+ } from '../ParameterSelection/ParameterSelectionConstants';
31
+
24
32
  export const initialState = Immutable({
25
33
  name: false,
26
34
  error: { errorMsg: '', status: '', statusText: '' },
@@ -40,6 +48,7 @@ const applicationInstanceConf = (state = initialState, action) => {
40
48
  return state.set('loading', true);
41
49
  }
42
50
  case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS: {
51
+ let newState = {};
43
52
  const services = JSON.parse(payload.app_definition.services);
44
53
 
45
54
  // initialize all services count with 0
@@ -56,11 +65,18 @@ const applicationInstanceConf = (state = initialState, action) => {
56
65
  });
57
66
  }
58
67
 
59
- return state.merge({
68
+ newState = {
60
69
  appDefinition: payload.app_definition,
61
70
  services: services,
62
71
  loading: false,
63
- });
72
+ };
73
+
74
+ // Initialize ansibleVarsAll if there is no data available in app instance
75
+ if (state.ansibleVarsAll.length <= 0) {
76
+ newState['ansibleVarsAll'] = JSON.parse(payload.app_definition.ansible_vars_all);
77
+ }
78
+
79
+ return state.merge(newState);
64
80
  }
65
81
  case APPLICATION_INSTANCE_HOST_ADD: {
66
82
  let hosts = [];
@@ -71,7 +87,7 @@ const applicationInstanceConf = (state = initialState, action) => {
71
87
  index = Math.max(...hosts.map(e => e.id)) + 1;
72
88
  }
73
89
 
74
- const newRow = {id: index, hostname: "", description: '', service: '', parameters: [], newEntry: true };
90
+ const newRow = {id: index, hostname: "", description: '', service: '', foremanParameters: [], ansibleParameters: [], newEntry: true };
75
91
  newRow.backup = cloneDeep(newRow)
76
92
  hosts.push(newRow);
77
93
 
@@ -118,20 +134,31 @@ const applicationInstanceConf = (state = initialState, action) => {
118
134
  return state;
119
135
  }
120
136
 
137
+ // hostnames are lower case
138
+ thisHost.hostname = thisHost.hostname.toLowerCase();
139
+
140
+ const hostnameRegex = /^[0-9a-z]([0-9a-z\-]{0,61}[0-9a-z])$/;
141
+
142
+ if (thisHost.hostname.match(hostnameRegex) == undefined) {
143
+ window.alert("The hostname uses not allowed characters. See https://en.wikipedia.org/wiki/Hostname#Syntax for more details.")
144
+ return state;
145
+ }
146
+
121
147
  if (thisHost.service == '') {
122
- window.alert("Every host needs to be assigned to a service");
148
+ window.alert("Every host needs to be assigned to a service.");
123
149
  return state;
124
150
  }
125
151
 
126
152
  if (state.hosts.filter(v => v.hostname === thisHost.hostname && v.id != thisHost.id).length > 0) {
127
- window.alert("Host name already used for this Application Instance. Please make sure that every host name is unique");
153
+ window.alert("Host name already used in this Application Instance. Please make sure that every host name is unique.");
128
154
  return state;
129
155
  }
130
156
 
131
157
  // Initialize the new Instance with the parameters of the Application Definition.
132
158
  if (thisHost.newEntry === true) {
133
159
  const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
134
- hosts[index].parameters = selectedService.parameters;
160
+ hosts[index].foremanParameters = selectedService.foremanParameters;
161
+ hosts[index].ansibleParameters = selectedService.ansibleParameters;
135
162
 
136
163
  const hostServiceId = Number(thisHost.service);
137
164
  const service = services.find(serv => serv['id'] == hostServiceId);
@@ -175,35 +202,35 @@ const applicationInstanceConf = (state = initialState, action) => {
175
202
  hosts: hosts
176
203
  });
177
204
  }
178
- case APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN: {
205
+ case APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN: {
179
206
  let parametersData = {};
180
207
 
181
- if (payload && payload.rowData) {
182
- const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
183
-
184
- parametersData.serviceDefinition = {
185
- id: selectedService.id,
186
- name: selectedService.name,
187
- hostgroup_id: selectedService.hostgroup,
188
- hostId: payload.rowData.id,
189
- };
190
- parametersData.parameters = payload.rowData.parameters;
208
+ const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
209
+
210
+ parametersData.paramDefinition = {
211
+ id: selectedService.id,
212
+ name: selectedService.name,
213
+ dataId: selectedService.hostgroup,
214
+ hostId: payload.rowData.id,
215
+ // TODO: is this really correct? Guess it shoud be dataId and we should get rid of them
216
+ //hostgroup_id: selectedService.hostgroup,
217
+ };
218
+ parametersData.type = PARAMETER_SELECTION_PARAM_TYPE_FOREMAN;
219
+ parametersData.parameters = payload.rowData.foremanParameters;
220
+ parametersData.useDefaultValue = false;
221
+ parametersData.allowRowAdjustment = false;
222
+ parametersData.allowNameAdjustment = false;
223
+ parametersData.allowDescriptionAdjustment = false;
191
224
 
192
- if (parametersData.parameters.length > 0) {
193
- parametersData.mode = 'editInstance';
194
- } else {
195
- parametersData.mode = 'newInstance';
196
- }
197
- }
198
225
  return state.merge({
199
226
  parametersData: parametersData,
200
227
  });
201
228
  }
202
- case APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE: {
229
+ case APPLICATION_INSTANCE_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE: {
203
230
  if (payload.mode == 'save') {
204
231
  const hosts = cloneDeep(state.hosts);
205
- const index = findIndex(hosts, { id: state.parametersData.serviceDefinition.hostId });
206
- hosts[index].parameters = cloneDeep(payload.hostParameterSelection);
232
+ const index = findIndex(hosts, { id: state.parametersData.paramDefinition.hostId });
233
+ hosts[index].foremanParameters = cloneDeep(payload.parameterSelection);
207
234
 
208
235
  return state.merge({
209
236
  parametersData: null,
@@ -215,6 +242,65 @@ const applicationInstanceConf = (state = initialState, action) => {
215
242
  });
216
243
  }
217
244
  }
245
+ case APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN: {
246
+ let parametersData = {};
247
+
248
+ if ((payload.hasOwnProperty('isAllGroup')) && (payload.isAllGroup == true)) {
249
+ parametersData.parameters = state.ansibleVarsAll;
250
+ parametersData.paramDefinition = {
251
+ isAllGroup: true,
252
+ }
253
+ } else {
254
+ const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
255
+
256
+ parametersData.paramDefinition = {
257
+ id: selectedService.id,
258
+ name: selectedService.name,
259
+ hostId: payload.rowData.id,
260
+ // TODO: is this really correct? Guess it shoud be dataId and we should get rid of them
261
+ //hostgroup_id: selectedService.hostgroup,
262
+ };
263
+ parametersData.parameters = payload.rowData.ansibleParameters;
264
+ }
265
+
266
+ parametersData.type = PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE;
267
+ parametersData.useDefaultValue = false;
268
+ parametersData.allowRowAdjustment = false;
269
+ parametersData.allowNameAdjustment = false;
270
+ parametersData.allowDescriptionAdjustment = false;
271
+
272
+ return state.merge({
273
+ parametersData: parametersData,
274
+ });
275
+ }
276
+ case APPLICATION_INSTANCE_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE: {
277
+ let newState = {};
278
+ if (payload.mode == 'save') {
279
+ if ((state.parametersData.paramDefinition.hasOwnProperty('isAllGroup')) && (state.parametersData.paramDefinition.isAllGroup == true)) {
280
+ newState = {
281
+ parametersData: null,
282
+ ansibleVarsAll: cloneDeep(payload.parameterSelection),
283
+ };
284
+ } else {
285
+ const hosts = cloneDeep(state.hosts);
286
+ const index = findIndex(hosts, { id: state.parametersData.paramDefinition.hostId });
287
+ hosts[index].ansibleParameters = cloneDeep(payload.parameterSelection);
288
+
289
+ newState = {
290
+ parametersData: null,
291
+ hosts: hosts
292
+ };
293
+ }
294
+ } else {
295
+ newState = {
296
+ parametersData: null,
297
+ };
298
+ }
299
+ return state.merge(newState);
300
+ }
301
+ case APPLICATION_INSTANCE_CHANGE_PARAMETER_SELECTION_MODE: {
302
+ return state.merge({ paramEditMode: payload.mode });
303
+ }
218
304
  default:
219
305
  return state;
220
306
  }
@@ -4,5 +4,7 @@ export const selectEditMode = state => applicationInstanceConf(state).editMode;
4
4
  export const selectAppDefinition = state => applicationInstanceConf(state).appDefinition;
5
5
  export const selectHosts = state => applicationInstanceConf(state).hosts;
6
6
  export const selectColumns = state => applicationInstanceConf(state).columns;
7
- export const selectParametersData = state => applicationInstanceConf(state).parametersData;
8
7
  export const selectServices = state => applicationInstanceConf(state).services;
8
+ export const selectParametersData = state => applicationInstanceConf(state).parametersData;
9
+ export const selectAnsibleVarsAll = state => applicationInstanceConf(state).ansibleVarsAll;
10
+ export const selectParamEditMode = state => applicationInstanceConf(state).paramEditMode;
@@ -0,0 +1,263 @@
1
+ export const applicationInstanceConfData_1 = {
2
+ name: false,
3
+ error: {
4
+ errorMsg: '',
5
+ status: '',
6
+ statusText: ''
7
+ },
8
+ loading: false,
9
+ columns: [
10
+ {
11
+ property: 'hostname',
12
+ header: {
13
+ label: 'Hostname',
14
+ formatters: [
15
+ null
16
+ ],
17
+ props: {
18
+ index: 0,
19
+ style: {
20
+ width: '30%'
21
+ }
22
+ }
23
+ },
24
+ cell: {
25
+ formatters: [
26
+ null
27
+ ]
28
+ }
29
+ },
30
+ {
31
+ property: 'description',
32
+ header: {
33
+ label: 'Description',
34
+ formatters: [
35
+ null
36
+ ],
37
+ props: {
38
+ index: 1,
39
+ style: {
40
+ width: '30%'
41
+ }
42
+ }
43
+ },
44
+ cell: {
45
+ formatters: [
46
+ null
47
+ ]
48
+ }
49
+ },
50
+ {
51
+ property: 'service',
52
+ header: {
53
+ label: 'Service',
54
+ formatters: [
55
+ null
56
+ ],
57
+ props: {
58
+ index: 2,
59
+ style: {
60
+ width: '20%'
61
+ }
62
+ }
63
+ },
64
+ cell: {
65
+ formatters: [
66
+ null
67
+ ]
68
+ }
69
+ },
70
+ {
71
+ property: 'actions',
72
+ header: {
73
+ label: 'Actions',
74
+ formatters: [
75
+ null
76
+ ],
77
+ props: {
78
+ index: 4,
79
+ style: {
80
+ width: '20%'
81
+ }
82
+ }
83
+ },
84
+ cell: {
85
+ formatters: [
86
+ null
87
+ ]
88
+ }
89
+ }
90
+ ],
91
+ appDefinition: {
92
+ id: 1,
93
+ name: 'LAMP',
94
+ description: '',
95
+ services: '[{"id":1,"name":"web","description":"","hostgroup":"1","ansibleGroup":"webservers","minCount":"2","maxCount":"","foremanParameters":[{"id":1,"locked":false,"name":"CP","description":"","type":"computeprofile","value":"1"},{"id":2,"locked":true,"name":"LE","description":"","type":"lifecycleenv","value":"1"}],"ansibleParameters":[{"id":0,"name":"dummy_var","value":"0"}]},{"id":2,"name":"db","description":"","hostgroup":"1","ansibleGroup":"dbservers","minCount":"1","maxCount":"","foremanParameters":[],"ansibleParameters":[{"id":0,"name":"mysqlservice","value":"mysqld"},{"id":1,"name":"mysql_port","value":"3306","locked":true},{"id":2,"name":"dbuser","value":"webapp"},{"id":3,"name":"dbname","value":"ANSAP01"},{"id":4,"name":"upassword","value":"Bond@007"},{"id":5,"name":"masterpassword","value":"MySQL@007"}]}]',
96
+ ansible_vars_all: '[{"id":0,"name":"repository","value":"https://github.com/bennojoy/mywebapp.git"}]',
97
+ location_ids: [
98
+ 2
99
+ ],
100
+ organization_ids: [
101
+ 1
102
+ ],
103
+ created_at: '2021-03-11 12:51:34 +0100',
104
+ updated_at: '2021-03-13 00:06:12 +0100'
105
+ },
106
+ hosts: [
107
+ {
108
+ id: 4,
109
+ hostname: 'great-web-app-db-1',
110
+ service: '2',
111
+ description: '',
112
+ foremanParameters: [],
113
+ ansibleParameters: [
114
+ {
115
+ id: 0,
116
+ name: 'mysqlservice',
117
+ value: 'mysqld'
118
+ },
119
+ {
120
+ id: 1,
121
+ name: 'mysql_port',
122
+ value: '3306'
123
+ },
124
+ {
125
+ id: 2,
126
+ name: 'dbuser',
127
+ value: 'webapp'
128
+ },
129
+ {
130
+ id: 3,
131
+ name: 'dbname',
132
+ value: 'ANSAP01'
133
+ },
134
+ {
135
+ id: 4,
136
+ name: 'upassword',
137
+ value: 'Bond@007'
138
+ },
139
+ {
140
+ id: 5,
141
+ name: 'masterpassword',
142
+ value: 'MySQL@007'
143
+ }
144
+ ]
145
+ },
146
+ {
147
+ id: 1,
148
+ hostname: 'great-web-app-web-1',
149
+ service: '1',
150
+ description: '',
151
+ foremanParameters: [],
152
+ ansibleParameters: [
153
+ {
154
+ id: 0,
155
+ name: 'dummy_var',
156
+ value: '0'
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ id: 2,
162
+ hostname: 'great-web-app-web-2',
163
+ service: '1',
164
+ description: '',
165
+ foremanParameters: [],
166
+ ansibleParameters: [
167
+ {
168
+ id: 0,
169
+ name: 'dummy_var',
170
+ value: '0'
171
+ }
172
+ ]
173
+ }
174
+ ],
175
+ ansibleVarsAll: [
176
+ {
177
+ id: 0,
178
+ name: 'repository',
179
+ value: 'https://github.com/bennojoy/mywebapp.git'
180
+ }
181
+ ],
182
+ services: [
183
+ {
184
+ id: 1,
185
+ name: 'web',
186
+ description: '',
187
+ hostgroup: '1',
188
+ ansibleGroup: 'webservers',
189
+ minCount: '2',
190
+ maxCount: '',
191
+ foremanParameters: [
192
+ {
193
+ id: 1,
194
+ locked: false,
195
+ name: 'CP',
196
+ description: '',
197
+ type: 'computeprofile',
198
+ value: '1'
199
+ },
200
+ {
201
+ id: 2,
202
+ locked: true,
203
+ name: 'LE',
204
+ description: '',
205
+ type: 'lifecycleenv',
206
+ value: '1'
207
+ }
208
+ ],
209
+ ansibleParameters: [
210
+ {
211
+ id: 0,
212
+ name: 'dummy_var',
213
+ value: '0'
214
+ }
215
+ ],
216
+ currentCount: 2
217
+ },
218
+ {
219
+ id: 2,
220
+ name: 'db',
221
+ description: '',
222
+ hostgroup: '1',
223
+ ansibleGroup: 'dbservers',
224
+ minCount: '1',
225
+ maxCount: '',
226
+ foremanParameters: [],
227
+ ansibleParameters: [
228
+ {
229
+ id: 0,
230
+ name: 'mysqlservice',
231
+ value: 'mysqld'
232
+ },
233
+ {
234
+ id: 1,
235
+ name: 'mysql_port',
236
+ value: '3306',
237
+ locked: true
238
+ },
239
+ {
240
+ id: 2,
241
+ name: 'dbuser',
242
+ value: 'webapp'
243
+ },
244
+ {
245
+ id: 3,
246
+ name: 'dbname',
247
+ value: 'ANSAP01'
248
+ },
249
+ {
250
+ id: 4,
251
+ name: 'upassword',
252
+ value: 'Bond@007'
253
+ },
254
+ {
255
+ id: 5,
256
+ name: 'masterpassword',
257
+ value: 'MySQL@007'
258
+ }
259
+ ],
260
+ currentCount: 1
261
+ }
262
+ ]
263
+ }