foreman_acd 0.7.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +17 -2
  4. data/app/controllers/foreman_acd/app_definitions_controller.rb +104 -7
  5. data/app/controllers/foreman_acd/app_instances_controller.rb +15 -30
  6. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  7. data/app/controllers/ui_acd_controller.rb +42 -3
  8. data/app/lib/actions/foreman_acd/run_configurator.rb +1 -0
  9. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +40 -27
  10. data/app/models/foreman_acd/app_instance.rb +47 -2
  11. data/app/models/foreman_acd/foreman_host.rb +8 -0
  12. data/app/services/foreman_acd/app_deployer.rb +19 -2
  13. data/app/services/foreman_acd/inventory_creator.rb +11 -1
  14. data/app/views/foreman_acd/app_definitions/_form.html.erb +4 -0
  15. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  16. data/app/views/foreman_acd/app_definitions/index.html.erb +3 -6
  17. data/app/views/foreman_acd/app_instances/_form.html.erb +4 -0
  18. data/app/views/foreman_acd/app_instances/index.html.erb +15 -11
  19. data/app/views/foreman_acd/app_instances/report.html.erb +7 -2
  20. data/app/views/ui_acd/host_report.json.rabl +4 -0
  21. data/app/views/ui_acd/report_data.json.rabl +10 -0
  22. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  23. data/config/routes.rb +3 -0
  24. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  25. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  26. data/lib/foreman_acd/plugin.rb +9 -9
  27. data/lib/foreman_acd/version.rb +1 -1
  28. data/lib/foreman_acd.rb +27 -9
  29. data/package.json +8 -25
  30. data/test/controllers/ui_acd_controller_test.rb +4 -1
  31. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  32. data/webpack/__snapshots__/helper.test.js.snap +1 -1
  33. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +34 -10
  34. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +12 -0
  35. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  36. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +30 -9
  37. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
  38. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +1 -0
  39. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +12 -0
  40. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +31 -5
  41. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +8 -0
  42. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +1 -1
  43. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +3 -3
  44. data/webpack/components/ApplicationDefinition/index.js +8 -0
  45. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  46. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  47. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  48. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  49. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  50. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  51. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  52. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  53. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  54. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  55. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  56. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  57. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  58. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  59. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  60. data/webpack/components/ApplicationInstance/ApplicationInstance.js +102 -26
  61. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +118 -6
  62. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -0
  63. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  64. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +71 -30
  65. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
  66. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +2 -0
  67. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +1 -0
  68. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +12 -0
  69. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +12 -0
  70. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +98 -7
  71. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +271 -0
  72. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +8 -0
  73. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  74. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  75. data/webpack/components/ApplicationInstance/helper.js +0 -0
  76. data/webpack/components/ApplicationInstance/index.js +8 -0
  77. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +81 -6
  78. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +35 -1
  79. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +3 -0
  80. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -0
  81. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  82. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +1 -124
  83. data/webpack/components/ApplicationInstanceReport/index.js +8 -1
  84. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  85. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  86. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  87. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  88. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  89. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  90. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  91. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  92. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  93. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  94. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  95. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  96. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  97. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  98. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  99. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  100. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  101. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  102. data/webpack/components/ExistingHostSelection/index.js +26 -0
  103. data/webpack/components/ParameterSelection/ParameterSelection.js +103 -1
  104. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  105. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +46 -4
  106. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +2 -0
  107. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +5 -1
  108. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +52 -11
  109. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -0
  110. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +8 -0
  111. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +2 -0
  112. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -0
  113. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +96 -0
  114. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +117 -17
  115. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +13 -0
  116. data/webpack/components/ParameterSelection/index.js +4 -1
  117. data/webpack/components/SyncGitRepo/SyncGitRepo.js +2 -10
  118. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +2 -3
  119. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +0 -1
  120. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +1 -0
  121. data/webpack/components/SyncGitRepo/components/FormTextInput.js +1 -1
  122. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +3 -2
  123. data/webpack/components/common/DeleteTableEntry.js +16 -2
  124. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +38 -0
  125. data/webpack/helper.js +21 -1
  126. data/webpack/helper.test.js +20 -1
  127. data/webpack/index.js +5 -0
  128. data/webpack/js-yaml.js +3874 -0
  129. data/webpack/reducer.js +13 -2
  130. data/webpack/test_setup.js +0 -2
  131. metadata +46 -2
@@ -469,6 +469,7 @@ Object {
469
469
  "foremanParameters": Array [],
470
470
  "hostname": "",
471
471
  "id": 5,
472
+ "isExistingHost": false,
472
473
  "newEntry": true,
473
474
  "service": "",
474
475
  },
@@ -476,6 +477,7 @@ Object {
476
477
  "foremanParameters": Array [],
477
478
  "hostname": "",
478
479
  "id": 5,
480
+ "isExistingHost": false,
479
481
  "newEntry": true,
480
482
  "service": "",
481
483
  },
@@ -1114,6 +1116,275 @@ Object {
1114
1116
  }
1115
1117
  `;
1116
1118
 
1119
+ exports[`ApplicationInstanceReducer should close alert modal 1`] = `
1120
+ Object {
1121
+ "alertModalText": "",
1122
+ "alertModalTitle": "",
1123
+ "ansibleVarsAll": Array [
1124
+ Object {
1125
+ "id": 0,
1126
+ "name": "repository",
1127
+ "value": "https://github.com/bennojoy/mywebapp.git",
1128
+ },
1129
+ ],
1130
+ "appDefinition": Object {
1131
+ "ansible_vars_all": "[{\\"id\\":0,\\"name\\":\\"repository\\",\\"value\\":\\"https://github.com/bennojoy/mywebapp.git\\"}]",
1132
+ "created_at": "2021-03-11 12:51:34 +0100",
1133
+ "description": "",
1134
+ "id": 1,
1135
+ "location_ids": Array [
1136
+ 2,
1137
+ ],
1138
+ "name": "LAMP",
1139
+ "organization_ids": Array [
1140
+ 1,
1141
+ ],
1142
+ "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\\"}]}]",
1143
+ "updated_at": "2021-03-13 00:06:12 +0100",
1144
+ },
1145
+ "columns": Array [
1146
+ Object {
1147
+ "cell": Object {
1148
+ "formatters": Array [
1149
+ null,
1150
+ ],
1151
+ },
1152
+ "header": Object {
1153
+ "formatters": Array [
1154
+ null,
1155
+ ],
1156
+ "label": "Hostname",
1157
+ "props": Object {
1158
+ "index": 0,
1159
+ "style": Object {
1160
+ "width": "30%",
1161
+ },
1162
+ },
1163
+ },
1164
+ "property": "hostname",
1165
+ },
1166
+ Object {
1167
+ "cell": Object {
1168
+ "formatters": Array [
1169
+ null,
1170
+ ],
1171
+ },
1172
+ "header": Object {
1173
+ "formatters": Array [
1174
+ null,
1175
+ ],
1176
+ "label": "Description",
1177
+ "props": Object {
1178
+ "index": 1,
1179
+ "style": Object {
1180
+ "width": "30%",
1181
+ },
1182
+ },
1183
+ },
1184
+ "property": "description",
1185
+ },
1186
+ Object {
1187
+ "cell": Object {
1188
+ "formatters": Array [
1189
+ null,
1190
+ ],
1191
+ },
1192
+ "header": Object {
1193
+ "formatters": Array [
1194
+ null,
1195
+ ],
1196
+ "label": "Service",
1197
+ "props": Object {
1198
+ "index": 2,
1199
+ "style": Object {
1200
+ "width": "20%",
1201
+ },
1202
+ },
1203
+ },
1204
+ "property": "service",
1205
+ },
1206
+ Object {
1207
+ "cell": Object {
1208
+ "formatters": Array [
1209
+ null,
1210
+ ],
1211
+ },
1212
+ "header": Object {
1213
+ "formatters": Array [
1214
+ null,
1215
+ ],
1216
+ "label": "Actions",
1217
+ "props": Object {
1218
+ "index": 4,
1219
+ "style": Object {
1220
+ "width": "20%",
1221
+ },
1222
+ },
1223
+ },
1224
+ "property": "actions",
1225
+ },
1226
+ ],
1227
+ "error": Object {
1228
+ "errorMsg": "",
1229
+ "status": "",
1230
+ "statusText": "",
1231
+ },
1232
+ "hosts": Array [
1233
+ Object {
1234
+ "ansibleParameters": Array [
1235
+ Object {
1236
+ "id": 0,
1237
+ "name": "mysqlservice",
1238
+ "value": "mysqld",
1239
+ },
1240
+ Object {
1241
+ "id": 1,
1242
+ "name": "mysql_port",
1243
+ "value": "3306",
1244
+ },
1245
+ Object {
1246
+ "id": 2,
1247
+ "name": "dbuser",
1248
+ "value": "webapp",
1249
+ },
1250
+ Object {
1251
+ "id": 3,
1252
+ "name": "dbname",
1253
+ "value": "ANSAP01",
1254
+ },
1255
+ Object {
1256
+ "id": 4,
1257
+ "name": "upassword",
1258
+ "value": "Bond@007",
1259
+ },
1260
+ Object {
1261
+ "id": 5,
1262
+ "name": "masterpassword",
1263
+ "value": "MySQL@007",
1264
+ },
1265
+ ],
1266
+ "description": "",
1267
+ "foremanParameters": Array [],
1268
+ "hostname": "great-web-app-db-1",
1269
+ "id": 4,
1270
+ "service": "2",
1271
+ },
1272
+ Object {
1273
+ "ansibleParameters": Array [
1274
+ Object {
1275
+ "id": 0,
1276
+ "name": "dummy_var",
1277
+ "value": "0",
1278
+ },
1279
+ ],
1280
+ "description": "",
1281
+ "foremanParameters": Array [],
1282
+ "hostname": "great-web-app-web-1",
1283
+ "id": 1,
1284
+ "service": "1",
1285
+ },
1286
+ Object {
1287
+ "ansibleParameters": Array [
1288
+ Object {
1289
+ "id": 0,
1290
+ "name": "dummy_var",
1291
+ "value": "0",
1292
+ },
1293
+ ],
1294
+ "description": "",
1295
+ "foremanParameters": Array [],
1296
+ "hostname": "great-web-app-web-2",
1297
+ "id": 2,
1298
+ "service": "1",
1299
+ },
1300
+ ],
1301
+ "loading": false,
1302
+ "name": false,
1303
+ "services": Array [
1304
+ Object {
1305
+ "ansibleGroup": "webservers",
1306
+ "ansibleParameters": Array [
1307
+ Object {
1308
+ "id": 0,
1309
+ "name": "dummy_var",
1310
+ "value": "0",
1311
+ },
1312
+ ],
1313
+ "currentCount": 2,
1314
+ "description": "",
1315
+ "foremanParameters": Array [
1316
+ Object {
1317
+ "description": "",
1318
+ "id": 1,
1319
+ "locked": false,
1320
+ "name": "CP",
1321
+ "type": "computeprofile",
1322
+ "value": "1",
1323
+ },
1324
+ Object {
1325
+ "description": "",
1326
+ "id": 2,
1327
+ "locked": true,
1328
+ "name": "LE",
1329
+ "type": "lifecycleenv",
1330
+ "value": "1",
1331
+ },
1332
+ ],
1333
+ "hostgroup": "1",
1334
+ "id": 1,
1335
+ "maxCount": "",
1336
+ "minCount": "2",
1337
+ "name": "web",
1338
+ },
1339
+ Object {
1340
+ "ansibleGroup": "dbservers",
1341
+ "ansibleParameters": Array [
1342
+ Object {
1343
+ "id": 0,
1344
+ "name": "mysqlservice",
1345
+ "value": "mysqld",
1346
+ },
1347
+ Object {
1348
+ "id": 1,
1349
+ "locked": true,
1350
+ "name": "mysql_port",
1351
+ "value": "3306",
1352
+ },
1353
+ Object {
1354
+ "id": 2,
1355
+ "name": "dbuser",
1356
+ "value": "webapp",
1357
+ },
1358
+ Object {
1359
+ "id": 3,
1360
+ "name": "dbname",
1361
+ "value": "ANSAP01",
1362
+ },
1363
+ Object {
1364
+ "id": 4,
1365
+ "name": "upassword",
1366
+ "value": "Bond@007",
1367
+ },
1368
+ Object {
1369
+ "id": 5,
1370
+ "name": "masterpassword",
1371
+ "value": "MySQL@007",
1372
+ },
1373
+ ],
1374
+ "currentCount": 1,
1375
+ "description": "",
1376
+ "foremanParameters": Array [],
1377
+ "hostgroup": "1",
1378
+ "id": 2,
1379
+ "maxCount": "",
1380
+ "minCount": "1",
1381
+ "name": "db",
1382
+ },
1383
+ ],
1384
+ "showAlertModal": false,
1385
+ }
1386
+ `;
1387
+
1117
1388
  exports[`ApplicationInstanceReducer should confirm edit host 1`] = `
1118
1389
  Object {
1119
1390
  "ansibleVarsAll": Array [
@@ -2,6 +2,10 @@
2
2
 
3
3
  exports[`ApplicationInstanceSelectors should return ParamEditMode from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
4
4
 
5
+ exports[`ApplicationInstanceSelectors should return alertModalText from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
6
+
7
+ exports[`ApplicationInstanceSelectors should return alertModalTitle from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
8
+
5
9
  exports[`ApplicationInstanceSelectors should return ansibleVarsAll from applicationInstanceConfData_1 fixtures 1`] = `
6
10
  Array [
7
11
  Object {
@@ -117,6 +121,8 @@ Array [
117
121
 
118
122
  exports[`ApplicationInstanceSelectors should return editMode from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
119
123
 
124
+ exports[`ApplicationInstanceSelectors should return hiddenForemanParameterTypes from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
125
+
120
126
  exports[`ApplicationInstanceSelectors should return hosts from applicationInstanceConfData_1 fixtures 1`] = `
121
127
  Array [
122
128
  Object {
@@ -274,3 +280,5 @@ Array [
274
280
  },
275
281
  ]
276
282
  `;
283
+
284
+ exports[`ApplicationInstanceSelectors should return showAlertModal from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
@@ -18,6 +18,7 @@ const AppDefinitionSelector= ({
18
18
  <label className="col-md-2 control-label">{label}</label>
19
19
  <div className="col-md-4">
20
20
  <ExtSelect
21
+ hidden={hidden}
21
22
  editable={editable}
22
23
  viewText={viewText}
23
24
  selectValue={selectValue}
@@ -15,7 +15,7 @@ const ServiceCounter= ({
15
15
 
16
16
  return (
17
17
  <div>
18
- <label class="service-counter-title">{title}</label>
18
+ <label className="service-counter-title">{title}</label>
19
19
  {Object.keys(services).map(key => (
20
20
  <Service
21
21
  key={services[key].id}
File without changes
@@ -6,22 +6,30 @@ import ApplicationInstance from './ApplicationInstance';
6
6
  import * as ApplicationInstanceActions from './ApplicationInstanceActions';
7
7
 
8
8
  import {
9
+ selectShowAlertModal,
10
+ selectAlertModalText,
11
+ selectAlertModalTitle,
9
12
  selectEditMode,
10
13
  selectAppDefinition,
11
14
  selectHosts,
12
15
  selectServices,
13
16
  selectColumns,
17
+ selectHiddenForemanParameterTypes,
14
18
  selectParametersData,
15
19
  selectAnsibleVarsAll,
16
20
  selectParamEditMode,
17
21
  } from './ApplicationInstanceSelectors';
18
22
 
19
23
  const mapStateToProps = state => ({
24
+ showAlertModal: selectShowAlertModal(state),
25
+ alertModalText: selectAlertModalText(state),
26
+ alertModalTitle: selectAlertModalTitle(state),
20
27
  editMode: selectEditMode(state),
21
28
  appDefinition: selectAppDefinition(state),
22
29
  hosts: selectHosts(state),
23
30
  services: selectServices(state),
24
31
  columns: selectColumns(state),
32
+ hiddenForemanParameterTypes: selectHiddenForemanParameterTypes(state),
25
33
  parametersData: selectParametersData(state),
26
34
  ansibleVarsAll: selectAnsibleVarsAll(state),
27
35
  paramEditMode: selectParamEditMode(state),
@@ -1,6 +1,11 @@
1
1
  import React, { useState } from 'react'
2
2
  import PropTypes from 'prop-types';
3
3
 
4
+ import {
5
+ Icon,
6
+ Spinner,
7
+ } from 'patternfly-react';
8
+
4
9
  import {
5
10
  VerticalTabs,
6
11
  } from 'patternfly-react-extensions';
@@ -20,14 +25,42 @@ class ApplicationInstanceReport extends React.Component {
20
25
 
21
26
  componentDidMount() {
22
27
  const {
23
- data: { hosts, mode },
28
+ data: { hosts, deploymentState, initialConfigureState, initialConfigureJobUrl },
24
29
  initApplicationInstanceReport,
25
30
  setActiveHost,
26
31
  } = this.props;
27
32
 
28
- initApplicationInstanceReport(hosts);
33
+ initApplicationInstanceReport(hosts, deploymentState, initialConfigureState, initialConfigureJobUrl);
34
+ this.reloadReportData();
29
35
  };
30
36
 
37
+ reloadReportData() {
38
+ const {
39
+ data: { appInstanceId, reportDataUrl },
40
+ deploymentState, initialConfigureState,
41
+ loadReportData,
42
+ } = this.props;
43
+
44
+ // if both states are unknown, it means, that the component was just loaded. try again after a short timeout.
45
+ if (deploymentState == 'unknown' && initialConfigureState == 'unknown') {
46
+ setTimeout(() => {
47
+ this.reloadReportData();
48
+ }, 1000);
49
+
50
+ return;
51
+ }
52
+
53
+ if ((deploymentState != 'new' && deploymentState != 'finished' && deploymentState != 'failed') ||
54
+ (initialConfigureState == 'unconfigured' || initialConfigureState == 'scheduled' || initialConfigureState == 'pending')) {
55
+
56
+ loadReportData(reportDataUrl, appInstanceId);
57
+
58
+ setTimeout(() => {
59
+ this.reloadReportData();
60
+ }, 5000);
61
+ }
62
+ }
63
+
31
64
  isActive(id) {
32
65
  return (this.props.activeHostId === id);
33
66
  }
@@ -66,13 +99,20 @@ class ApplicationInstanceReport extends React.Component {
66
99
  </div>
67
100
  )
68
101
  } else {
102
+ const already_deployed_msg = __("Already existing host which was added to the application instance");
69
103
  return (
70
104
  <div>
71
105
  <span>Host: <a href={ host['hostUrl'] }>{ host['name'] }</a></span>
72
106
  <span>&nbsp;|&nbsp;</span>
73
107
  <span>State: { host['build'] == true ? "in Build" : "Deployed" }</span>
74
108
  <span>&nbsp;|&nbsp;</span>
75
- <span>Power Status: <PowerStatus key={ "power_status_"+ host['id'] } data={{ id: host['id'], url: host['powerStatusUrl'] }} /></span>
109
+ <span>Power Status: <PowerStatus key={ "power_status_"+ host['id'] } id={ host['id'] } url={ host['powerStatusUrl'] } data={{ id: host['id'], url: host['powerStatusUrl'] }} /></span>
110
+ {host['isExistingHost'] ? (
111
+ <span>
112
+ &nbsp;|&nbsp; Existing host &nbsp;
113
+ <Icon style={{marginRight: 8, marginLeft: 2}} type="pf" name="info" title={already_deployed_msg} />
114
+ </span>
115
+ ) : (<span></span>)}
76
116
  </div>
77
117
  )
78
118
  }
@@ -80,14 +120,22 @@ class ApplicationInstanceReport extends React.Component {
80
120
 
81
121
  render() {
82
122
  const {
83
- data: { hosts, mode, appInstanceName, deployTaskUrl, configureJobUrl },
84
- activeHostId,
123
+ data: { appInstanceId, appInstanceName, deployTaskUrl, configureJobUrl, reportDataUrl },
124
+ activeHostId, hosts,
125
+ deploymentState,
126
+ initialConfigureState, initialConfigureJobUrl, showInitialConfigureJob,
127
+ loadReportData,
85
128
  } = this.props;
86
129
 
87
130
  let tabs = [];
88
131
  let reportStatus = undefined;
89
132
  let report = undefined;
90
133
 
134
+ // This handles the first call to render() in which the state hosts is always empty
135
+ if (hosts.length == 0) {
136
+ return (<span>No host</span>);
137
+ }
138
+
91
139
  tabs = this.collectLastReportData(hosts);
92
140
  reportStatus = this.lastReportStatus(hosts[activeHostId]);
93
141
 
@@ -98,14 +146,32 @@ class ApplicationInstanceReport extends React.Component {
98
146
  return (
99
147
  <span>
100
148
  <div className="deploy_status">
149
+ <div>
150
+ <div className="deploy_status_head">Host deployment state</div>
151
+ <div className="deploy_status_content">
152
+ { (deploymentState != 'new' && deploymentState != 'finished' && deploymentState != 'failed') ? (<span><Spinner loading size='sm' /> &nbsp;</span>) : (<span></span>) }
153
+ { deploymentState }
154
+ </div>
155
+ </div>
101
156
  <div>
102
157
  <div className="deploy_status_head">Deployment task</div>
103
158
  <div className="deploy_status_content"><a href={ deployTaskUrl } >Last deployment task</a></div>
104
159
  </div>
160
+ { (showInitialConfigureJob == true) ? (
161
+ <div>
162
+ <div className="deploy_status_head">Configuration job</div>
163
+ <div className="deploy_status_content">
164
+ { (initialConfigureState == 'scheduled' || initialConfigureState == 'pending') ? (<span><Spinner loading size='sm' /> &nbsp;</span>) : (<span></span>) }
165
+ { (initialConfigureState != 'unconfigured' && initialConfigureState != 'scheduled') ? (<a href={ initialConfigureJobUrl }>Configuration job</a>) : (<span></span>) }
166
+ { (initialConfigureState != 'unconfigured') ? (<span>&nbsp; State: { initialConfigureState }</span>) : (<span></span>) }
167
+ </div>
168
+ </div>
169
+ ) : (
105
170
  <div>
106
171
  <div className="deploy_status_head">Configuration job</div>
107
172
  <div className="deploy_status_content"><a href={ configureJobUrl }>Configuration jobs</a></div>
108
173
  </div>
174
+ ) }
109
175
  </div>
110
176
  <div className="deploy_report_hosts">
111
177
  Hosts
@@ -131,6 +197,10 @@ ApplicationInstanceReport.defaultProps = {
131
197
  hosts: [],
132
198
  report: [],
133
199
  activeHostId: 0,
200
+ deploymentState: 'unknown',
201
+ initialConfigureState: 'unknown',
202
+ initialConfigureJobUrl: '',
203
+ showInitialConfigureJob: false,
134
204
  }
135
205
 
136
206
  ApplicationInstanceReport.propTypes = {
@@ -138,11 +208,16 @@ ApplicationInstanceReport.propTypes = {
138
208
  appInstanceName: PropTypes.string,
139
209
  deployTaskUrl: PropTypes.string,
140
210
  configureJobUrl: PropTypes.string,
211
+ deploymentState: PropTypes.string,
212
+ initialConfigureState: PropTypes.string,
213
+ initialConfigureJobUrl: PropTypes.string,
214
+ showInitialConfigureJob: PropTypes.bool,
141
215
  hosts: PropTypes.array,
216
+ deploymentState: PropTypes.string,
142
217
  report: PropTypes.array,
143
218
  setActiveHost: PropTypes.func,
219
+ loadReportData: PropTypes.func,
144
220
  activeHostId: PropTypes.number,
145
-
146
221
  };
147
222
 
148
223
  export default ApplicationInstanceReport;
@@ -13,14 +13,28 @@ import {
13
13
  import {
14
14
  APPLICATION_INSTANCE_REPORT_INIT,
15
15
  APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST,
16
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST,
17
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS,
18
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE,
16
19
  } from './ApplicationInstanceReportConstants';
17
20
 
18
21
  export const initApplicationInstanceReport = (
19
- hosts,
22
+ hosts, deploymentState, initialConfigureState, initialConfigureJobUrl,
20
23
  ) => dispatch => {
21
24
  const initialState = {};
22
25
 
23
26
  initialState.hosts = hosts;
27
+ initialState.deploymentState = deploymentState;
28
+ initialState.initialConfigureState = initialConfigureState;
29
+ initialState.initialConfigureJobUrl = initialConfigureJobUrl;
30
+
31
+ // Decide if it should show only the initial Configure job state + URL or
32
+ // the URL to all configuration jobs
33
+ if (initialConfigureState == 'unconfigured') {
34
+ initialState.showInitialConfigureJob = true;
35
+ } else {
36
+ initialState.showInitialConfigureJob = false;
37
+ }
24
38
 
25
39
  dispatch({
26
40
  type: APPLICATION_INSTANCE_REPORT_INIT,
@@ -28,6 +42,26 @@ export const initApplicationInstanceReport = (
28
42
  });
29
43
  };
30
44
 
45
+ export const loadReportData = (
46
+ reportDataUrl,
47
+ appInstanceId,
48
+ ) => dispatch => {
49
+ dispatch({ type: APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST });
50
+
51
+ const baseUrl = reportDataUrl;
52
+ const realUrl = baseUrl.replace("__id__", appInstanceId);
53
+
54
+ return api
55
+ .get(realUrl, {}, {})
56
+ .then(({ data }) =>
57
+ dispatch({
58
+ type: APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS,
59
+ payload: { ...data }
60
+ })
61
+ )
62
+ .catch(error => dispatch(errorHandler(APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE, error)));
63
+ };
64
+
31
65
  const errorHandler = (msg, err) => {
32
66
  const error = {
33
67
  errorMsg: 'Failed to fetch data from server.',
@@ -1,2 +1,5 @@
1
1
  export const APPLICATION_INSTANCE_REPORT_INIT = 'APPLICATION_INSTANCE_REPORT_INIT';
2
2
  export const APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST = 'APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST';
3
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST = 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST';
4
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS = 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS';
5
+ export const APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE = 'APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE';
@@ -9,6 +9,9 @@ import {
9
9
  import {
10
10
  APPLICATION_INSTANCE_REPORT_INIT,
11
11
  APPLICATION_INSTANCE_REPORT_SET_ACTIVE_HOST,
12
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST,
13
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS,
14
+ APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE,
12
15
  } from './ApplicationInstanceReportConstants';
13
16
 
14
17
  export const initialState = Immutable({
@@ -29,6 +32,22 @@ const applicationInstanceReport = (state = initialState, action) => {
29
32
  activeHostId: payload.activeHostId,
30
33
  })
31
34
  }
35
+ case APPLICATION_INSTANCE_REPORT_LOAD_REPORT_REQUEST: {
36
+ // Nothing to do
37
+ return state;
38
+ }
39
+ case APPLICATION_INSTANCE_REPORT_LOAD_REPORT_SUCCESS: {
40
+ return state.merge({
41
+ deploymentState: payload.deploymentState,
42
+ initialConfigureState: payload.initialConfigureState,
43
+ initialConfigureJobUrl: payload.initialConfigureJobUrl,
44
+ hosts: payload.hosts,
45
+ });
46
+ }
47
+ case APPLICATION_INSTANCE_REPORT_LOAD_REPORT_FAILURE: {
48
+ console.log("Error while loading report data: "+ payload.error);
49
+ return state.merge({ error: payload.error});
50
+ }
32
51
  default: {
33
52
  return state;
34
53
  }
@@ -2,3 +2,7 @@ const applicationInstanceReport = state => state.foremanAcd.applicationInstanceR
2
2
 
3
3
  export const selectHosts = state => applicationInstanceReport(state).hosts;
4
4
  export const selectActiveHostId = state => applicationInstanceReport(state).activeHostId;
5
+ export const selectDeploymentState = state => applicationInstanceReport(state).deploymentState;
6
+ export const selectInitialConfigureState = state => applicationInstanceReport(state).initialConfigureState;
7
+ export const selectInitialConfigureJobUrl = state => applicationInstanceReport(state).initialConfigureJobUrl;
8
+ export const selectShowInitialConfigureJob = state => applicationInstanceReport(state).showInitialConfigureJob;