Scale out and CM update 79/47379/1
authorSonsino, Ofir (os0695) <os0695@intl.att.com>
Mon, 14 May 2018 10:30:27 +0000 (13:30 +0300)
committerSonsino, Ofir (os0695) <os0695@intl.att.com>
Mon, 14 May 2018 10:30:27 +0000 (13:30 +0300)
Change-Id: I313a82dfa92e49f868ea0d0b8a3ed1bffee423c9
Issue-ID: VID-188
Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
vid-app-common/src/main/webapp/app/vid/scripts/controller/change-management.controller.js
vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.css
vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
vid-app-common/src/main/webapp/app/vid/scripts/view-models/change-management.html

index f15c7e5..10ac231 100644 (file)
@@ -556,12 +556,12 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
         final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE + " request";
 
         Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg);
-        validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "existing-software-version", SOFTWARE_VERSION_PATTERN);
-        validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "new-software-version", SOFTWARE_VERSION_PATTERN);
+        validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "existing_software_version", SOFTWARE_VERSION_PATTERN);
+        validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "new_software_version", SOFTWARE_VERSION_PATTERN);
 
         //if "operations-timeout" is not integer, trying to read it as String that represent a number
         if (!(payload.get("operations-timeout") instanceof Integer)) {
-            validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "operations-timeout", NUMBER_PATTERN);
+            validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "operations_timeout", NUMBER_PATTERN);
         }
 
     }
index 273f130..488ada6 100644 (file)
@@ -1,12 +1,13 @@
 (function () {
     'use strict';
 
-    appDS2.controller("changeManagementController", ["$uibModal", "changeManagementService", "_", "$log",  "SchedulerService", "$filter", changeManagementController]);
+    appDS2.controller("changeManagementController", ["$uibModal", "changeManagementService", "_", "$log",  "SchedulerService", "$filter", "VIDCONFIGURATION", changeManagementController]);
 
-    function changeManagementController($uibModal, changeManagementService, _, $log, SchedulerService, $filter) {
+    function changeManagementController($uibModal, changeManagementService, _, $log, SchedulerService, $filter, VIDCONFIGURATION) {
         var vm = this;
 
         vm.lastTimeUpdated = "";
+        vm.hasScheduler = !!VIDCONFIGURATION.SCHEDULER_PORTAL_URL;
 
         vm.init = function() {
             vm.lastTimeUpdated = $filter('date')(new Date(), "MM/dd/yyyy | HH:mm:ss");
index e337a52..68f3b02 100644 (file)
@@ -7,6 +7,7 @@
     function newChangeManagementModalController($uibModalInstance, $uibModal,$q, AaiService, changeManagementService, Upload, $log, $scope, _, COMPONENT, VIDCONFIGURATION) {
 
         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.controllers = VIDCONFIGURATION.SCALE_OUT_CONTROLLERS;
                                         if (newVNFName["invariant-id"] === vnf.invariantUuid) {
                                             availableVersions.push(extractVNFModel(vnf, response.data.service, newVNFName));
                                             newVNFName.vfModules = vnf.vfModules;
+
+                                            //for scale out screen
+                                            newVNFName.category = response.data.service.category;
+                                            newVNFName.groupModules = _.groupBy(newVNFName.vfModules, "customizationUuid");
                                         }
                                     });
                                     var versions = _.uniqBy(availableVersions, 'modelInfo.modelVersion');
                                try{
                                var requestInfoData ={};
                                var requestParametersData ={};
+                var moduleToScale = _.find(vnf.vfModules, function(key, item){
+                    return !item.scale;
+                });
                                if (vnf.availableVersions && vnf.availableVersions.length!=0){
                                        
                                        requestInfoData ={
                                                        payload: changeManagement.configUpdateFile
                                                }
                     }else if(workflowType=="VNF Scale Out"){
-                        requestParametersData = {
-                            controllerType: changeManagement.controllerType
-                            //userParams: { ..json.. }
-                            //usePreload: false
+
+                        if(moduleToScale.userParams) {
+                            requestParametersData = {
+                                controllerType: changeManagement.controllerType,
+                                userParams: moduleToScale.userParams,
+                                usePreload: true
+                            }
+                        }else{
+                            requestParametersData = {
+                                controllerType: changeManagement.controllerType,
+                                userParams: [],
+                                usePreload: false
+                            }
                         }
                     }
                                        $log.info('SchedulerWidgetCtrl:extractChangeManagementCallbackDataStr info:: workflowType '+ workflowType);
                                        requestParametersData = {
                                                payload: changeManagement.configUpdateFile
                                        }
-                               }       
-                               
-                               var data = {
-                                       vnfName: vnf.name,
-                                       vnfInstanceId: vnf.id,
-                                       modelInfo: {
-                                               modelType: 'vnf',
-                                               modelInvariantId: vnf.properties['model-invariant-id'],
-                                               modelVersionId: vnf.modelVersionId,
-                                               modelName: vnf.properties['vnf-name'],
-                                               modelVersion: vnf.version,
-                                               modelCustomizationName: vnf.properties['model-customization-name'],
-                                               modelCustomizationId: vnf.properties['model-customization-id']
-                                       },
-                                       cloudConfiguration: vnf.cloudConfiguration,
-                                       requestInfo: requestInfoData,
-                                       relatedInstanceList: [],
-                                       requestParameters:requestParametersData
-                               };
+                               }
+
+
+                               var data;
+                               if(workflowType=="VNF Scale Out") {
+                                   var name = moduleToScale.modelCustomizationName.split('-')[0]; //example: vSAMP12..base..module-0
+                    name = name + "-" + vnf.groupModules[moduleToScale.customizationUuid].length;
+
+                    data = {
+                        modelInfo: {
+                            modelType: 'vfModule',
+                            modelInvariantId: moduleToScale.invariantUuid,
+                            modelName: name,
+                            modelVersion: moduleToScale.version,
+                            modelCustomizationId: moduleToScale.customizationUuid
+                        },
+                        cloudConfiguration: vnf.cloudConfiguration,
+                        requestInfo: requestInfoData,
+                        relatedInstanceList: [],
+                        requestParameters:requestParametersData
+                    }
+                }else{
+                    data = {
+                        vnfName: vnf.name,
+                        vnfInstanceId: vnf.id,
+                        modelInfo: {
+                            modelType: 'vnf',
+                            modelInvariantId: vnf.properties['model-invariant-id'],
+                            modelVersionId: vnf.modelVersionId,
+                            modelName: vnf.properties['vnf-name'],
+                            modelVersion: vnf.version,
+                            modelCustomizationName: vnf.properties['model-customization-name'],
+                            modelCustomizationId: vnf.properties['model-customization-id']
+                        },
+                        cloudConfiguration: vnf.cloudConfiguration,
+                        requestInfo: requestInfoData,
+                        relatedInstanceList: [],
+                        requestParameters:requestParametersData
+                    }
+                }
 
                                var serviceInstanceId = '';
                                _.forEach(vnf['service-instance-node'], function (instanceNode) {
                }
                
         vm.openModal = function () {
-            if(VIDCONFIGURATION.SCHEDULER_PORTAL_URL) { //scheduling supported
+            if(vm.hasScheduler) { //scheduling supported
                                $scope.widgetParameter = ""; // needed by the scheduler?
 
                                // properties needed by the scheduler so it knows whether to show
             return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfInPlace;
         };
 
+        vm.setPreload = function (fileEl) {
+            var files = fileEl.files;
+            var file = files[0];
+            var reader = new FileReader();
+
+            reader.onloadend = function(evt) {
+                if (evt.target.readyState === FileReader.DONE) {
+                    $scope.$apply(function () {
+                        $scope.moduleArr[0].userParams = JSON.parse(evt.target.result);
+                    });
+                }
+            };
+
+            reader.readAsText(file);
+        };
+
         init();
     }
 })();
\ No newline at end of file
index 4dc2d39..34a6af4 100644 (file)
 }
 .scale-out-modules .table-row > div:nth-child(1) {
     flex: 40px 0 0;
+    font-size: 22px;
 }
 .scale-out-modules .table-row > div:nth-child(2) {
-    flex: 363px 1 0;
+    flex: 220px 1 0;
 }
 .scale-out-modules .table-row > div:nth-child(3) {
-    flex: 90px 0 0;
+    flex: 200px 1 0;
 }
 .scale-out-modules .table-row > div:nth-child(4), .scale-out-modules .table-row > div:nth-child(5) {
     flex: 150px 0 0;
 .scale-out-modules .table-row > div:nth-child(6), .scale-out-modules .table-row > div:nth-child(7) {
     flex: 120px 0 0;
 }
+.scale-out-modules .table-row.open > div {
+    line-height: 29px;
+    border-top: 1px #009FDB solid;
+    border-bottom: 1px #009FDB solid;
+}
+.scale-out-modules .table-row.open > div:last-child {
+    box-shadow: 0px 0px 0px 0px red, 1px 0px 0px 0px #009FDB;
+}
+.scale-out-modules .table-row.open > div:nth-child(1) {
+    border-color: green;
+}
+.scale-out-modules .table-row.open > div:nth-child(2) {
+    color: #009FDB;
+}
 .scale-out-modules .table-header {
     border-bottom: none;
 }
 .scale-out-modules .table-header > div {
-    background-color: #F2F2F2;""
+    background-color: #F2F2F2;
     color: black;
     font-size: 12px;
 }
@@ -48,6 +63,7 @@
 }
 .scale-out-modules .modules-table .table-row  > div:nth-child(1) {
     flex: 539px 0 0;
+    font-size: 13px;
 }
 .scale-out-modules .modules-table .table-row  > div:nth-child(2) {
     flex: 90px 0 0;
@@ -69,6 +85,7 @@
 /*LESS*/
 /*
 
+
 .scale-out-modules{
 
        .table-row{
 
                        &:nth-child(1){
                                flex:40px 0 0;
+                               font-size:22px;
                        }
                        &:nth-child(2){
-                               flex:363px 1 0;
+                               flex:220px 1 0;
                        }
                        &:nth-child(3){
-                               flex:90px 0 0;
+                               flex:200px 1 0;
                        }
                        &:nth-child(4), &:nth-child(5){
                                flex:150px 0 0;
 
                                &:nth-child(1){
                                        flex:539px 0 0;
+                                       font-size:13px;
                                }
                                &:nth-child(2){
                                        flex:90px 0 0;
index e14af86..fa06258 100644 (file)
 
         <div class="table-header table-row">
             <div></div>
-            <div>VNF instance name</div>
+            <div>Service Instance Name</div>
+            <div>VNF Instance Name</div>
             <div>Model V</div>
             <div>Category</div>
-            <div>Sub Category</div>
             <div>UUID</div>
             <div>Invariant UUID</div>
         </div>
 
-        <div class="table-row" ng-repeat-start="vnf in vm.changeManagement.vnfNames" ng-if="vnf['prov-status'] === 'PROV'">
-            <div></div>
-            <div>{{vnf.name}} service instance name: {{vnf['service-instance-node'].properties['service-instance-name']}}</div>
-            <div>2</div>
-            <div>Category</div>
-            <div>Sub Category</div>
+        <div class="table-row" ng-repeat-start="vnf in vm.changeManagement.vnfNames" ng-if="vnf['prov-status'] === 'PROV'" ng-click="vnf.isOpen=!!!vnf.isOpen">
+            <div>+</div>
+            <div>{{vnf['service-instance-node'].properties['service-instance-name']}}</div>
+            <div>{{vnf.name}}</div>
+            <div>{{vnf['availableVersions'][0].modelInfo.modelVersion}}</div>
+            <div>{{vnf.category}}</div>
             <div>{{vnf.modelVersionId}}</div>
             <div>{{vnf['invariant-id']}}</div>
         </div>
-        <div class="modules-table open" ng-repeat-end="">
+        <div class="modules-table" ng-repeat-end="" ng-class="{'open' :vnf.isOpen}">
             <div class="table-header table-row">
                 <div>VF Module</div>
                 <div>In Service</div>
                 <div>File</div>
             </div>
 
-            <div class="table-row" ng-repeat="(key, module) in vnf.vfModules">
-                <div>{{module.modelCustomizationName}}</div>
-                <div>{{module.properties.minCountInstances}} - {{module.properties.maxCountInstances}}</div>
-                <div>Category</div>
-                <div>{{module.uuid}}</div>
+            <div class="table-row" ng-repeat="(custUUID, moduleArr) in vnf.groupModules">
+                <div>{{moduleArr[0].modelCustomizationName}}</div>
+                <div>{{moduleArr.length}}</div>
+                <div ng-if="moduleArr[0].properties.minCountInstances == moduleArr[0].properties.maxCountInstances">N/A</div>
+                <div ng-if="moduleArr[0].properties.minCountInstances != moduleArr[0].properties.maxCountInstances">
+                    <input type="number" ng-model="moduleArr[0].scale" step="1"
+                           ng-min="moduleArr[0].properties.minCountInstances" ng-max="moduleArr[0].properties.maxCountInstances - moduleArr.length" />
+                </div>
+                <div>{{moduleArr[0].uuid}}</div>
                 <div>
-                    <input type="file" ng-model="module.file" accept="application/json" />
+                    <input type="file" accept="application/json" onchange="angular.element(this).scope().setPreload(this)" />
                 </div>
             </div>
         </div>
 
     <div class="modal-footer">
         <div class="pull-right">
-            <button ng-if="!vm.isScaleOut() || (vm.isScaleOut() && vm.wizardStep === 2)" type="submit" id="submit" name="submit" class="btn btn-primary" data-ng-disabled="newChangeManagement.$invalid">Schedule</button>
+            <button ng-if="!vm.isScaleOut() || (vm.isScaleOut() && vm.wizardStep === 2)" type="submit" id="submit" name="submit" class="btn btn-primary" data-ng-disabled="newChangeManagement.$invalid">{{vm.hasScheduler ? "Schedule" : "Confirm"}}</button>
             <button ng-if="vm.isScaleOut() && vm.wizardStep === 1" ng-click="vm.nextStep();" type="button" id="next" name="next" class="btn btn-primary" data-ng-disabled="newChangeManagement.$invalid">Next</button>
             <button type="button" id="cancel" name="cancel" class="btn btn-white" ng-click="vm.close()">Cancel</button>
         </div>
index 94a1790..65c8ec7 100644 (file)
@@ -59,7 +59,7 @@
                         </table>
                         </div>
                         <div class="table-wrapper">
-                        <table class="table table-bordered"  data-tests-id="pending-table-cm" id="pending-table">
+                        <table ng-if="vm.hasScheduler" class="table table-bordered"  data-tests-id="pending-table-cm" id="pending-table">
                             <thead ng-click="collapsePending=!collapsePending">
                             <tr class="table-headline-row">
                                 <th class="col-md-6">