diff options
Diffstat (limited to 'vid-app-common/src/main/webapp')
5 files changed, 249 insertions, 58 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js index 4ac5f85ac..dbf6588ce 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js @@ -116,7 +116,8 @@ appDS2 CHANGE_MANAGEMENT_OPERATION_NO_SCHEDULER: "change-management/workflow/@vnfName", GET_WORKFLOW: "change-management/get_vnf_workflow_relation", GET_SO_WORKFLOWS: "workflows-management/workflows", - GET_SO_WORKFLOW_PARAMETER: "workflows-management/workflow-parameters/@workflowID", + GET_SO_WORKFLOW_PARAMETER: "workflows-management/remote-workflow-parameters/@workflowID", + GET_LOCAL_WORKFLOW_PARAMETER: "workflows-management/local-workflow-parameters/@workflowName", GET_MSO_WORKFLOWS: "change-management/mso", GET_SCHEDULER_CHANGE_MANAGEMENTS: "change-management/scheduler", CANCEL_SCHEDULE_REQUEST: "change-management/scheduler/schedules", diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js index e525f0f5c..8a7d59a62 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js @@ -28,8 +28,6 @@ var vm = this; vm.hasScheduler = !!VIDCONFIGURATION.SCHEDULER_PORTAL_URL; - vm.configUpdatePatternError = "Invalid file type. Please select a file with a CSV extension."; - vm.configUpdateContentError = "Invalid file structure."; vm.wizardStep = 1; vm.nextStep = function(){ @@ -202,7 +200,7 @@ }] }) .then(function (configUpdateResponse) { - vm.changeManagement.configUpdateFile = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload; + vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload; defer.resolve(true); }) .catch(function (error) { @@ -218,7 +216,6 @@ var result = {}; result.requestType = changeManagement.workflow; var workflowType = changeManagement.workflow; - var configurationParameters = changeManagement.configurationParameters; result.requestDetails = []; _.forEach(changeManagement.vnfNames, function (vnf) { @@ -246,51 +243,50 @@ } }else if(workflowType=="VNF In Place Software Update"){ var payloadObj = { - 'existing_software_version':changeManagement.existingSoftwareVersion, - 'new_software_version':changeManagement.newSoftwareVersion, - 'operations_timeout':changeManagement.operationTimeout + 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Existing software version').value, + 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'New software version').value, + 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Operations timeout').value }; requestParametersData = { payload: JSON.stringify(payloadObj) } }else if(workflowType=="VNF Config Update"){ requestParametersData = { - payload: changeManagement.configUpdateFile + payload: vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value } - }else if(workflowType=="VNF Scale Out"){ - if(!moduleToScale) return null; - - if(moduleToScale.userParams) { - requestParametersData = { - userParams: moduleToScale.userParams - //,usePreload: true - } - }else{ - requestParametersData = { - userParams: [] - //,usePreload: false - } - } - } + }else if(workflowType=="VNF Scale Out"){ + if(!moduleToScale) return null; + + if(moduleToScale.userParams) { + requestParametersData = { + userParams: moduleToScale.userParams + //,usePreload: true + } + }else{ + requestParametersData = { + userParams: [] + //,usePreload: false + } + } + } $log.info('SchedulerWidgetCtrl:extractChangeManagementCallbackDataStr info:: workflowType '+ workflowType); $log.info('SchedulerWidgetCtrl:extractChangeManagementCallbackDataStr info:: requestParametersData '+ requestParametersData); }else if(workflowType=="VNF In Place Software Update"){ var payloadObj = { - 'existing_software_version':changeManagement.existingSoftwareVersion, - 'new_software_version':changeManagement.newSoftwareVersion, - 'operations_timeout':changeManagement.operationTimeout + 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Existing software version').value, + 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'New software version').value, + 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Operations timeout').value }; requestParametersData = { payload: JSON.stringify(payloadObj) } }else if(workflowType=="VNF Config Update"){ requestParametersData = { - payload: changeManagement.configUpdateFile + payload: vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value } } - var data; if(workflowType=="VNF Scale Out") { data = { @@ -309,7 +305,7 @@ requestInfo: requestInfoData, relatedInstanceList: [], requestParameters:requestParametersData, - configurationParameters: JSON.parse(configurationParameters) + configurationParameters: JSON.parse(vm.getInternalWorkFlowParameter("VNF Scale Out", "STRING", "Configuration Parameters").value) }; requestInfoData.instanceName = vnf.name + "_" + (moduleToScale.currentCount + 1); }else{ @@ -641,6 +637,7 @@ // Should be corrected when VID-397 will be closed. At the moment there is a need // to merge local and remote workflows not to broke current functionality. return vm.loadLocalWorkFlows() + .then(vm.loadLocalWorkFlowsParameters) .then(vm.loadRemoteWorkFlows) .then(function () { vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name)); @@ -668,6 +665,28 @@ }); }; + vm.loadLocalWorkFlowsParameters = function () { + vm.localWorkflowsParameters = new Map(); + vm.localWorkflows.forEach(function(workflow) { + vm.loadLocalWorkFlowParameters(workflow); + }); + }; + + vm.loadLocalWorkFlowParameters = function (workflow) { + changeManagementService.getLocalWorkflowParameter(workflow) + .then(function (response) { + let fileParameters = response.data.parameterDefinitions.filter(item => item.type === 'FILE'); + let textParameters = response.data.parameterDefinitions.filter(item => item.type === 'STRING'); + let parameters = new Map(); + parameters.set('FILE', fileParameters); + parameters.set('STRING', textParameters); + vm.localWorkflowsParameters.set(workflow, parameters); + }) + .catch(function (error) { + $log.error(error); + }); + }; + vm.loadRemoteWorkFlowsParameters = function () { vm.remoteWorkflowsParameters = new Map(); vm.remoteWorkflows.forEach(function(workflow) { @@ -692,6 +711,19 @@ return []; }; + vm.getInternalWorkFlowParameters = function (workflow, type) { + if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).has(type)) { + return vm.localWorkflowsParameters.get(workflow).get(type) + } + return []; + }; + + vm.getInternalWorkFlowParameter = function (workflow, type, parameterName) { + if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).has(type)) { + return vm.localWorkflowsParameters.get(workflow).get(type).filter(parameter => parameter.name === parameterName)[0] + } + }; + //Must be $scope because we bind to the onchange of the html (cannot attached to vm variable). $scope.selectFileForVNFName = function (fileInput) { if (fileInput && fileInput.id) { diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js index c271b7505..5f3669152 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js @@ -80,11 +80,13 @@ describe('Testing workFlows from SO', () => { test('Verify load workflows will call load from SO and join workflow lists', () => { // given let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}}); let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]}); let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}}); $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; // when @@ -98,6 +100,7 @@ describe('Testing workFlows from SO', () => { test('Verify load workflows will call load workflows parameters from SO', () => { // given let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}}); let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]}); let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [ {"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"}, @@ -106,6 +109,7 @@ describe('Testing workFlows from SO', () => { $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; // when @@ -118,6 +122,56 @@ describe('Testing workFlows from SO', () => { }); }); + test('Verify load workflows will call load workflows parameters from local service', () => { + // given + let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ + "parameterDefinitions": [ + { + "id": 1, + "name": "Configuration Parameters", + "required": true, + "type": "STRING", + "pattern": ".*", + "msgOnPatternError": null, + "msgOnContentError": null, + "acceptableFileType": null + } + ], + }}); + let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); + let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); + + $controller.changeManagement.vnfNames = [{name: 'test1'}]; + $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; + $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; + $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; + // when + + let result = new Map(); + const scaleOutResult = new Map(); + scaleOutResult.set("FILE", []); + scaleOutResult.set("STRING", [ + { + "acceptableFileType": null, + "id": 1, + "msgOnContentError": null, + "msgOnPatternError": null, + "name": "Configuration Parameters", + "pattern": ".*", + "required": true, + "type": "STRING", + } + ]); + result.set("VNF Scale Out", scaleOutResult); + + return $controller.loadWorkFlows() + .then(() => { + expect($controller.localWorkflowsParameters).toEqual(result); + }); + }); + test('Verify broken SO workflows wont change content of local workflows', () => { // given let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); @@ -132,5 +186,114 @@ describe('Testing workFlows from SO', () => { expect($controller.workflows).toEqual(['workflow 0']); }); }); -}); + test('Verify get internal workflow parameters should return an empty list if not such workflow exist', () => { + // given + let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ + "parameterDefinitions": [ + { + "id": 1, + "name": "Configuration Parameters", + "required": true, + "type": "STRING", + "pattern": ".*", + "msgOnPatternError": null, + "msgOnContentError": null, + "acceptableFileType": null + } + ], + }}); + let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); + let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); + + $controller.changeManagement.vnfNames = [{name: 'test1'}]; + $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; + $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; + $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; + // when + return $controller.loadWorkFlows() + .then(() => { + let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("NON-EXISTENT WF", "STRING"); + expect(internalWorkFlowParameters).toEqual([]); + }); + }); + + test('Verify get internal workflow parameters should return an empty list if not such type exist', () => { + // given + let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ + "parameterDefinitions": [ + { + "id": 1, + "name": "Configuration Parameters", + "required": true, + "type": "STRING", + "pattern": ".*", + "msgOnPatternError": null, + "msgOnContentError": null, + "acceptableFileType": null + } + ], + }}); + let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); + let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); + + $controller.changeManagement.vnfNames = [{name: 'test1'}]; + $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; + $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; + $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; + // when + return $controller.loadWorkFlows() + .then(() => { + let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("VNF Scale Out", "FILE"); + expect(internalWorkFlowParameters).toEqual([]); + }); + }); + + test('Verify get internal workflow parameters should return a list if such workflow and type exist', () => { + // given + let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ + "parameterDefinitions": [ + { + "id": 1, + "name": "Configuration Parameters", + "required": true, + "type": "STRING", + "pattern": ".*", + "msgOnPatternError": null, + "msgOnContentError": null, + "acceptableFileType": null + } + ], + }}); + let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); + let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); + + $controller.changeManagement.vnfNames = [{name: 'test1'}]; + $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; + $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; + $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; + + let result = [{ + "acceptableFileType": null, + "id": 1, + "msgOnContentError": null, + "msgOnPatternError": null, + "name": "Configuration Parameters", + "pattern": ".*", + "required": true, + "type": "STRING", + }]; + // when + return $controller.loadWorkFlows() + .then(() => { + let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("VNF Scale Out", "STRING"); + expect(internalWorkFlowParameters).toEqual(result); + }); + }); +}); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html index 2cf879001..9fb978c42 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html @@ -78,38 +78,26 @@ <option value="" disabled>Select workflow</option> </select> </div> - <div class="form-group" ng-if="vm.isScaleOut()"> - <label class="control-label">Configuration Parameters</label> - <input type="text" name="configurationParameters" ng-model="vm.changeManagement.configurationParameters" id="configuration-parameters" required> - </div> - <div class="form-group" ng-if="vm.isConfigUpdate()"> - <label class="control-label">Attach configuration file</label> + + <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'FILE')"> + <label class="control-label">{{item.name}}</label> <div class="file-wrapper"> - <input id="config-update-input" class="file-input" type="file" ngf-select ng-model="vm.configUpdateFile" ngf-validate-async-fn="vm.uploadConfigFile($file)" name="configUpdateFile" - accept=".csv" ngf-pattern=".csv" required> </input> - <label id="config-update-label" class="file-input-label">{{vm.configUpdateFile&&vm.configUpdateFile.name||"Select File"}} </label> - <label for="config-update-input"><span class="icon-browse"></span></label> + <input id="internal-workflow-parameter-file-{{item.id}}" class="file-input" type="file" ngf-select ng-model="item.value" ngf-validate-async-fn="vm.uploadConfigFile($file)" name="configUpdateFile" accept="{{item.acceptableFileType}}" ngf-pattern="{{item.acceptableFileType}}" ng-required="{{item.required}}"/> + <label id="internal-workflow-parameter-file-{{item.id}}-label" class="file-input-label">{{item.value&&item.value.name||"Select File"}} </label> + <label for="internal-workflow-parameter-file-{{item.id}}"><span class="icon-browse"></span></label> </div> - <label id="errorLabel" class="icon-alert error" ng-if="newChangeManagement.configUpdateFile.$error.pattern">{{vm.configUpdatePatternError}}</label> - <label id="errorContentLabel" class="icon-alert error" ng-if="newChangeManagement.configUpdateFile.$error.validateAsyncFn">{{vm.configUpdateContentError}}</label> + <label id="errorLabel" class="icon-alert error" ng-if="item.value.$error.pattern">{{item.msgOnPatternError}}</label> + <label id="errorContentLabel" class="icon-alert error" ng-if="item.value.$error.validateAsyncFn">{{item.msgOnContentError}}</label> </div> - <div ng-if="vm.shouldShowVnfInPlaceFields()"> - <div class="form-group"> - <label class="control-label">Operations timeout</label> - <input class="form-control" ng-model="vm.changeManagement.operationTimeout" name="operationTimeout" type="text" id="operations-timeout" pattern="[0-9]+" required> - </div> - <div class="form-group"> - <label class="control-label">Existing software version</label> - <input class="form-control" ng-model="vm.changeManagement.existingSoftwareVersion" name="existingSoftwareVersion" type="text" id="existing-software-version" pattern="{{vm.softwareVersionRegex}}" required> - </div> - <div class="form-group"> - <label class="control-label">New software version</label> - <input class="form-control" ng-model="vm.changeManagement.newSoftwareVersion" name="newSoftwareVersion" type="text" id="new-software-version" pattern="{{vm.softwareVersionRegex}}" required> - </div> + + <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'STRING')"> + <label for="internal-workflow-parameter-text-{{item.id}}" class="control-label">{{item.name}}</label> + <input ng-model="item.value" type="text" id="internal-workflow-parameter-text-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}"> </div> + <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getRemoteWorkFlowParameters(vm.changeManagement.workflow)"> <label for="so-workflow-parameter-{{item.id}}" class="control-label">{{item.name}}</label> - <input class="form-control" ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}"> + <input ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}"> </div> </div> diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js index 5820ae212..45aedd1a1 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js @@ -36,7 +36,7 @@ .success(function (response) { return {data: response}; }) - .catch(function (err) { + .catch(function () { return {data: []}; }); }; @@ -57,6 +57,13 @@ }); }; + this.getLocalWorkflowParameter = function (workflowName){ + return $http.get(COMPONENT.GET_LOCAL_WORKFLOW_PARAMETER.replace('@workflowName', encodeURIComponent(workflowName))) + .success(function (response) { + return {data: response.parameterDefinitions} + }); + }; + this.getMSOChangeManagements = function() { var deferred = $q.defer(); |