Skip to content

Commit

Permalink
[OGUI-1420] Reload configuration on global deployment (#2135)
Browse files Browse the repository at this point in the history
* adds a second reload of configuration if deployment is done via the Global Deployments page
  • Loading branch information
graduta authored Sep 29, 2023
1 parent c944dfe commit 906ca8c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions Control/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module.exports.setup = (http, ws) => {

const aliecsReqHandler = new AliecsRequestHandler(ctrlService);
aliecsReqHandler.setWs(ws);
aliecsReqHandler.workflowService = workflowService;

const envCache = new EnvCache(ctrlService);
envCache.setWs(ws);
Expand Down
39 changes: 38 additions & 1 deletion Control/lib/control-core/RequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class RequestHandler {
constructor(ctrlService) {
this.ctrlService = ctrlService;
this.requestList = {};

/**
* @type {WorkflowService}
*/
this._workflowService = undefined;
}

/**
Expand Down Expand Up @@ -57,12 +62,31 @@ class RequestHandler {
this.broadcast();
log.debug('Added request to cache, ID: ' + index);

const {selectedConfiguration} = req.body;
if (selectedConfiguration) {
// workaround for reloading configuration before deployment from global page
try {
const {variables} = await this._workflowService.retrieveWorkflowSavedConfiguration(selectedConfiguration);
variables.hosts = req.body.vars.hosts;

const {epn_enabled, odc_n_epns} = req.body.vars;
if (epn_enabled === 'true') {
variables.odc_n_epns = odc_n_epns;
}
req.body.vars = variables;
console.log('-------------------------');
console.log(req.body.vars);
} catch (error) {
console.error(error);
}
}

try {
const payload = CoreUtils.parseEnvironmentCreationPayload(req.body);
await this.ctrlService.executeCommandNoResponse('NewEnvironment', payload);
log.debug('Auto-removed request, ID: ' + index);
delete this.requestList[index];
} catch(error) {
} catch (error) {
errorLogger('Request failed, ID: ' + index);
errorLogger(error);
this.requestList[index].failed = true;
Expand Down Expand Up @@ -115,5 +139,18 @@ class RequestHandler {
getAll(req, res) {
return res.json(this._getAll());
}

/**
* Getters & Setters
*/

/**
* Setter for updating workflowService to use
* @param {WorkflowService} - service to be used for retrieving workflow configuration
* @return {void}
*/
set workflowService(service) {
this._workflowService = service;
}
}
module.exports = RequestHandler;
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class EnvironmentCreationModel extends Observable {

this._model.environment.newEnvironment({
workflowTemplate: path,
selectedConfiguration: this._selectedConfigurationLabel,
vars: this._creationModel.variables,
detectors: this._model.workflow.flpSelection.selectedDetectors
});
Expand Down

0 comments on commit 906ca8c

Please sign in to comment.