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.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +90 -0
  4. data/app/controllers/foreman_acd/app_definitions_controller.rb +104 -7
  5. data/app/controllers/foreman_acd/app_instances_controller.rb +34 -32
  6. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  7. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  8. data/app/controllers/foreman_acd/remote_execution_controller.rb +37 -21
  9. data/app/controllers/ui_acd_controller.rb +42 -3
  10. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +12 -7
  11. data/app/lib/actions/foreman_acd/run_configurator.rb +11 -7
  12. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +41 -28
  13. data/app/models/foreman_acd/acd_provider.rb +7 -1
  14. data/app/models/foreman_acd/ansible_playbook.rb +2 -1
  15. data/app/models/foreman_acd/app_instance.rb +48 -3
  16. data/app/models/foreman_acd/foreman_host.rb +8 -0
  17. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  18. data/app/services/foreman_acd/app_configurator.rb +59 -15
  19. data/app/services/foreman_acd/app_deployer.rb +27 -4
  20. data/app/services/foreman_acd/inventory_creator.rb +25 -1
  21. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +41 -7
  22. data/app/views/foreman_acd/app_definitions/_form.html.erb +5 -1
  23. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  24. data/app/views/foreman_acd/app_definitions/index.html.erb +3 -6
  25. data/app/views/foreman_acd/app_instances/_form.html.erb +5 -1
  26. data/app/views/foreman_acd/app_instances/index.html.erb +18 -12
  27. data/app/views/foreman_acd/app_instances/report.html.erb +8 -3
  28. data/app/views/templates/job/run_acd_ansible_playbook.erb +1 -1
  29. data/app/views/ui_acd/host_report.json.rabl +4 -0
  30. data/app/views/ui_acd/report_data.json.rabl +10 -0
  31. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  32. data/config/routes.rb +6 -0
  33. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  34. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  35. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  36. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  37. data/db/seeds.d/75-job_templates.rb +1 -1
  38. data/lib/foreman_acd/engine.rb +26 -4
  39. data/lib/foreman_acd/plugin.rb +9 -18
  40. data/lib/foreman_acd/version.rb +1 -1
  41. data/lib/foreman_acd.rb +30 -0
  42. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  43. data/package.json +8 -22
  44. data/test/controllers/ansible_playbooks_controller_test.rb +1 -1
  45. data/test/controllers/app_instances_controller_test.rb +8 -3
  46. data/test/controllers/ui_acd_controller_test.rb +25 -6
  47. data/test/factories/foreman_acd_factories.rb +18 -4
  48. data/test/models/acd_provider_test.rb +37 -0
  49. data/test/models/ansible_playbook_test.rb +11 -0
  50. data/test/models/app_definition_test.rb +1 -1
  51. data/test/models/app_instance_test.rb +2 -0
  52. data/test/models/concerns/host_extensions_test.rb +26 -0
  53. data/test/models/foreman_host_test.rb +12 -0
  54. data/webpack/__mocks__/foremanReact/API.js +2 -0
  55. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  56. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  57. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  58. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  59. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  60. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  61. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  62. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  63. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +35 -11
  64. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +12 -0
  65. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  66. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +30 -9
  67. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
  68. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  69. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  70. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +26 -0
  71. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  72. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +53 -0
  73. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +226 -0
  74. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  75. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +307 -0
  76. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +2 -1
  77. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  78. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  79. data/webpack/components/ApplicationDefinition/index.js +8 -0
  80. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  81. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  82. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  83. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  84. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  85. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  86. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  87. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  88. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  89. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  90. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  91. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  92. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  93. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  94. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  95. data/webpack/components/ApplicationInstance/ApplicationInstance.js +105 -31
  96. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +118 -6
  97. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -0
  98. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  99. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +71 -30
  100. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
  101. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  102. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
  103. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
  104. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
  105. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +56 -0
  106. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +300 -0
  107. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
  108. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +284 -0
  109. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  110. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  111. data/webpack/components/ApplicationInstance/helper.js +0 -0
  112. data/webpack/components/ApplicationInstance/index.js +8 -0
  113. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +81 -6
  114. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +35 -1
  115. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +3 -0
  116. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -0
  117. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  118. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  119. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  120. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  121. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  122. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  123. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +7 -0
  124. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  125. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  126. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  127. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  128. data/webpack/components/ApplicationInstanceReport/index.js +8 -1
  129. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  130. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  131. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  132. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  133. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  134. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  135. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  136. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  137. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  138. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  139. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  140. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  141. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  142. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  143. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  144. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  145. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  146. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  147. data/webpack/components/ExistingHostSelection/index.js +26 -0
  148. data/webpack/components/ParameterSelection/ParameterSelection.js +103 -1
  149. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  150. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +46 -4
  151. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +2 -0
  152. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +5 -1
  153. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +51 -29
  154. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -0
  155. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +124 -84
  156. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  157. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  158. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +33 -25
  159. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +12 -6
  160. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
  161. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1589 -878
  162. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +130 -79
  163. data/webpack/components/ParameterSelection/index.js +4 -1
  164. data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
  165. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  166. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
  167. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -0
  168. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  169. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  170. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  171. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  172. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  173. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  174. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  175. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +31 -0
  176. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  177. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  178. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  179. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +47 -0
  180. data/webpack/components/SyncGitRepo/index.js +28 -0
  181. data/webpack/components/common/DeleteTableEntry.js +16 -2
  182. data/webpack/components/common/ExtTextInput.js +43 -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 +40 -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 +35 -1
  189. data/webpack/helper.test.js +56 -0
  190. data/webpack/index.js +7 -0
  191. data/webpack/js-yaml.js +3874 -0
  192. data/webpack/reducer.js +16 -1
  193. data/webpack/test_setup.js +0 -2
  194. metadata +136 -11
  195. data/webpack/components/common/EasyHeaderFormatter.js +0 -18
  196. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  197. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -0,0 +1,284 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ApplicationInstanceSelectors should return ParamEditMode from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
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
+
9
+ exports[`ApplicationInstanceSelectors should return ansibleVarsAll from applicationInstanceConfData_1 fixtures 1`] = `
10
+ Array [
11
+ Object {
12
+ "id": 0,
13
+ "name": "repository",
14
+ "value": "https://github.com/bennojoy/mywebapp.git",
15
+ },
16
+ ]
17
+ `;
18
+
19
+ exports[`ApplicationInstanceSelectors should return appDefinition from applicationInstanceConfData_1 fixtures 1`] = `
20
+ Object {
21
+ "ansible_vars_all": "[{\\"id\\":0,\\"name\\":\\"repository\\",\\"value\\":\\"https://github.com/bennojoy/mywebapp.git\\"}]",
22
+ "created_at": "2021-03-11 12:51:34 +0100",
23
+ "description": "",
24
+ "id": 1,
25
+ "location_ids": Array [
26
+ 2,
27
+ ],
28
+ "name": "LAMP",
29
+ "organization_ids": Array [
30
+ 1,
31
+ ],
32
+ "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\\"}]}]",
33
+ "updated_at": "2021-03-13 00:06:12 +0100",
34
+ }
35
+ `;
36
+
37
+ exports[`ApplicationInstanceSelectors should return columns from applicationInstanceConfData_1 fixtures 1`] = `
38
+ Array [
39
+ Object {
40
+ "cell": Object {
41
+ "formatters": Array [
42
+ null,
43
+ ],
44
+ },
45
+ "header": Object {
46
+ "formatters": Array [
47
+ null,
48
+ ],
49
+ "label": "Hostname",
50
+ "props": Object {
51
+ "index": 0,
52
+ "style": Object {
53
+ "width": "30%",
54
+ },
55
+ },
56
+ },
57
+ "property": "hostname",
58
+ },
59
+ Object {
60
+ "cell": Object {
61
+ "formatters": Array [
62
+ null,
63
+ ],
64
+ },
65
+ "header": Object {
66
+ "formatters": Array [
67
+ null,
68
+ ],
69
+ "label": "Description",
70
+ "props": Object {
71
+ "index": 1,
72
+ "style": Object {
73
+ "width": "30%",
74
+ },
75
+ },
76
+ },
77
+ "property": "description",
78
+ },
79
+ Object {
80
+ "cell": Object {
81
+ "formatters": Array [
82
+ null,
83
+ ],
84
+ },
85
+ "header": Object {
86
+ "formatters": Array [
87
+ null,
88
+ ],
89
+ "label": "Service",
90
+ "props": Object {
91
+ "index": 2,
92
+ "style": Object {
93
+ "width": "20%",
94
+ },
95
+ },
96
+ },
97
+ "property": "service",
98
+ },
99
+ Object {
100
+ "cell": Object {
101
+ "formatters": Array [
102
+ null,
103
+ ],
104
+ },
105
+ "header": Object {
106
+ "formatters": Array [
107
+ null,
108
+ ],
109
+ "label": "Actions",
110
+ "props": Object {
111
+ "index": 4,
112
+ "style": Object {
113
+ "width": "20%",
114
+ },
115
+ },
116
+ },
117
+ "property": "actions",
118
+ },
119
+ ]
120
+ `;
121
+
122
+ exports[`ApplicationInstanceSelectors should return editMode from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
123
+
124
+ exports[`ApplicationInstanceSelectors should return hiddenForemanParameterTypes from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
125
+
126
+ exports[`ApplicationInstanceSelectors should return hosts from applicationInstanceConfData_1 fixtures 1`] = `
127
+ Array [
128
+ Object {
129
+ "ansibleParameters": Array [
130
+ Object {
131
+ "id": 0,
132
+ "name": "mysqlservice",
133
+ "value": "mysqld",
134
+ },
135
+ Object {
136
+ "id": 1,
137
+ "name": "mysql_port",
138
+ "value": "3306",
139
+ },
140
+ Object {
141
+ "id": 2,
142
+ "name": "dbuser",
143
+ "value": "webapp",
144
+ },
145
+ Object {
146
+ "id": 3,
147
+ "name": "dbname",
148
+ "value": "ANSAP01",
149
+ },
150
+ Object {
151
+ "id": 4,
152
+ "name": "upassword",
153
+ "value": "Bond@007",
154
+ },
155
+ Object {
156
+ "id": 5,
157
+ "name": "masterpassword",
158
+ "value": "MySQL@007",
159
+ },
160
+ ],
161
+ "description": "",
162
+ "foremanParameters": Array [],
163
+ "hostname": "great-web-app-db-1",
164
+ "id": 4,
165
+ "service": "2",
166
+ },
167
+ Object {
168
+ "ansibleParameters": Array [
169
+ Object {
170
+ "id": 0,
171
+ "name": "dummy_var",
172
+ "value": "0",
173
+ },
174
+ ],
175
+ "description": "",
176
+ "foremanParameters": Array [],
177
+ "hostname": "great-web-app-web-1",
178
+ "id": 1,
179
+ "service": "1",
180
+ },
181
+ Object {
182
+ "ansibleParameters": Array [
183
+ Object {
184
+ "id": 0,
185
+ "name": "dummy_var",
186
+ "value": "0",
187
+ },
188
+ ],
189
+ "description": "",
190
+ "foremanParameters": Array [],
191
+ "hostname": "great-web-app-web-2",
192
+ "id": 2,
193
+ "service": "1",
194
+ },
195
+ ]
196
+ `;
197
+
198
+ exports[`ApplicationInstanceSelectors should return parametersData from applicationInstanceConfData_1 fixtures 1`] = `undefined`;
199
+
200
+ exports[`ApplicationInstanceSelectors should return services from applicationInstanceConfData_1 fixtures 1`] = `
201
+ Array [
202
+ Object {
203
+ "ansibleGroup": "webservers",
204
+ "ansibleParameters": Array [
205
+ Object {
206
+ "id": 0,
207
+ "name": "dummy_var",
208
+ "value": "0",
209
+ },
210
+ ],
211
+ "currentCount": 2,
212
+ "description": "",
213
+ "foremanParameters": Array [
214
+ Object {
215
+ "description": "",
216
+ "id": 1,
217
+ "locked": false,
218
+ "name": "CP",
219
+ "type": "computeprofile",
220
+ "value": "1",
221
+ },
222
+ Object {
223
+ "description": "",
224
+ "id": 2,
225
+ "locked": true,
226
+ "name": "LE",
227
+ "type": "lifecycleenv",
228
+ "value": "1",
229
+ },
230
+ ],
231
+ "hostgroup": "1",
232
+ "id": 1,
233
+ "maxCount": "",
234
+ "minCount": "2",
235
+ "name": "web",
236
+ },
237
+ Object {
238
+ "ansibleGroup": "dbservers",
239
+ "ansibleParameters": Array [
240
+ Object {
241
+ "id": 0,
242
+ "name": "mysqlservice",
243
+ "value": "mysqld",
244
+ },
245
+ Object {
246
+ "id": 1,
247
+ "locked": true,
248
+ "name": "mysql_port",
249
+ "value": "3306",
250
+ },
251
+ Object {
252
+ "id": 2,
253
+ "name": "dbuser",
254
+ "value": "webapp",
255
+ },
256
+ Object {
257
+ "id": 3,
258
+ "name": "dbname",
259
+ "value": "ANSAP01",
260
+ },
261
+ Object {
262
+ "id": 4,
263
+ "name": "upassword",
264
+ "value": "Bond@007",
265
+ },
266
+ Object {
267
+ "id": 5,
268
+ "name": "masterpassword",
269
+ "value": "MySQL@007",
270
+ },
271
+ ],
272
+ "currentCount": 1,
273
+ "description": "",
274
+ "foremanParameters": Array [],
275
+ "hostgroup": "1",
276
+ "id": 2,
277
+ "maxCount": "",
278
+ "minCount": "1",
279
+ "name": "db",
280
+ },
281
+ ]
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;