From 1ba64a4a45f26e8bdb58e866e540aa58f32e2e52 Mon Sep 17 00:00:00 2001 From: Ofir Sonsino Date: Wed, 20 Sep 2017 14:08:19 +0300 Subject: Change management and PNF support Issue-ID: VID-44, VID-48, VID-49, VID-50, VID-51, VID-52 Change-Id: I83e940aad2e4e294a0927b546c4c08ca8e539a65 Signed-off-by: Ofir Sonsino --- .../webapp/app/vid/scripts/services/aaiService.js | 296 ++++++++++------ .../scripts/services/change-management.service.js | 76 +++++ .../app/vid/scripts/services/creationService.js | 4 +- .../webapp/app/vid/scripts/services/msoService.js | 376 +++++++++++++-------- .../app/vid/scripts/services/schedulerService.js | 104 ++++++ 5 files changed, 609 insertions(+), 247 deletions(-) create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js create mode 100644 vid-app-common/src/main/webapp/app/vid/scripts/services/schedulerService.js (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/services') diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js index 09c70eb5..a10f602b 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js @@ -20,9 +20,9 @@ "use strict"; -var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD) { +var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD, $q) { return { - getSubscriberName: function (globalCustomerId, + getSubscriberName : function(globalCustomerId, successCallbackFunction) { $log .debug("AaiService:getSubscriberName: globalCustomerId: " @@ -31,9 +31,9 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE COMPONENT.AAI_SUB_DETAILS_PATH + globalCustomerId + COMPONENT.ASSIGN + Math.random(), { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { var subName = ""; if (response.data) { subName = response.data[FIELD.ID.SUBNAME]; @@ -44,7 +44,7 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }, - runNamedQuery: function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { + runNamedQuery : function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH + COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) + @@ -52,30 +52,54 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); $http.get(url, {}, { - timeout: PropertyService.getServerResponseTimeoutMsec() - }).then(function (response) { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { if (response.data != null) { successCallback(response); } else { errorCallback(response); } - }, function (response) { + }, function(response) { errorCallback(response); }); }, - getSubDetails: function (selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) { + getVNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) { + + var url = COMPONENT.AAI_GET_VNF_INFO + + COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) + + COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId); + $http.get(url, {}, { + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data != null) { + successCallback(response); + } else { + errorCallback(response); + } + }, function(response) { + errorCallback(response); + }); + }, + + + getSubDetails : function(selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) { var subscriber; var displayData; - $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, {}, { - timeout: PropertyService.getServerResponseTimeoutMsec() - }).then(function (response) { + $http.get( COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, {}, { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { displayData = []; subscriber = response.data; var subscriberName = subscriber[FIELD.ID.SUBNAME]; if (subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) { - angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function (serviceSubscription, key) { + angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) { var serviceInstanceId = []; var serviceType = ""; if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) { @@ -84,10 +108,9 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE serviceType = FIELD.PROMPT.NO_SERVICE_SUB; } if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) { - angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function (instValue, instKey) { + angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) { // put them together, i guess - var inst = { - "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], + var inst = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], "aaiModelInvariantId": instValue[FIELD.ID.MODEL_INVAR_ID], "aaiModelVersionId": instValue[FIELD.ID.MODEL_VERSION_ID], "serviceInstanceName": instValue[FIELD.ID.SERVICE_INSTANCE_NAME] @@ -102,111 +125,109 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }); } else { if (serviceInstanceId == []) { - serviceInstanceId = [FIELD.PROMPT.NO_SERVICE_INSTANCE]; + serviceInstanceId = [ FIELD.PROMPT.NO_SERVICE_INSTANCE ]; } } - angular.forEach(serviceInstanceId, function (subVal, subKey) { + angular.forEach(serviceInstanceId, function(subVal, subKey) { displayData.push({ - globalCustomerId: selectedSubscriber, - subscriberName: subscriberName, - serviceType: serviceType, - serviceInstanceId: subVal.serviceInstanceId, - aaiModelInvariantId: subVal.aaiModelInvariantId, - aaiModelVersionId: subVal.aaiModelVersionId, - serviceInstanceName: subVal.serviceInstanceName, + globalCustomerId : selectedSubscriber, + subscriberName : subscriberName, + serviceType : serviceType, + serviceInstanceId : subVal.serviceInstanceId, + aaiModelInvariantId : subVal.aaiModelInvariantId, + aaiModelVersionId + : subVal.aaiModelVersionId, + serviceInstanceName : subVal.serviceInstanceName, isPermitted: serviceSubscription[FIELD.ID.IS_PERMITTED] }); }); }); } else { displayData.push({ - globalCustomerId: selectedSubscriber, - subscriberName: selectedSubscriberName, - serviceType: FIELD.PROMPT.NO_SERVICE_SUB, - serviceInstanceId: FIELD.PROMPT.NO_SERVICE_INSTANCE + globalCustomerId : selectedSubscriber, + subscriberName : selectedSubscriberName, + serviceType : FIELD.PROMPT.NO_SERVICE_SUB, + serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE }); } successCallback(displayData, subscriberName); - }, function (response) { - errorCallback(response); - }); + }, function(response) { + errorCallback(response);}); }, - getSubList: function (successCallback, errorCallback) { - $http.get(FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, {}, { - timeout: PropertyService.getServerResponseTimeoutMsec() - }).then(function (response) { + getSubList : function(successCallback, errorCallback ) { + + $http.get( FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, {}, { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { var customerList = []; if (response.data.customer != null) { - angular.forEach(response.data.customer, function (subVal, subKey) { - var cust = { - "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], - "subscriberName": subVal[FIELD.ID.SUBNAME], - "isPermitted": subVal[FIELD.ID.IS_PERMITTED], - }; + angular.forEach(response.data.customer, function(subVal, subKey) { + var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME], + "isPermitted": subVal[FIELD.ID.IS_PERMITTED], }; customerList.push(cust); }); successCallback(customerList); } else { errorCallback(response); } - }, function (response) { + },function(response) { errorCallback(response); }); }, - getServices2: function (successCallback, errorCallback) { + getServices2 : function(successCallback, errorCallback ) { - $http.get(FIELD.ID.AAI_GET_SERVICES, {}, { - timeout: PropertyService.getServerResponseTimeoutMsec() - }).then(function (response) { + $http.get( FIELD.ID.AAI_GET_SERVICES, {}, { + + + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(function(response) { var customerList = []; if (response.data != null) { var serviceIdList = []; - angular.forEach(response.data, function (value, key) { - angular.forEach(value, function (subVal, key) { - var newVal = { - "id": subVal[FIELD.ID.SERVICE_ID], - "description": subVal[FIELD.ID.SERVICE_DESCRIPTION], + angular.forEach(response.data, function(value, key) { + angular.forEach(value, function(subVal, key) { + var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] , "isPermitted" : subVal[FIELD.ID.IS_PERMITTED] - }; - serviceIdList.push(newVal); + };serviceIdList.push(newVal); }); }); successCallback(serviceIdList); } else { errorCallback(response); } - }, function (response) { + },function(response) { errorCallback(response); }); }, - getSubscriptionServiceTypeList: function (globalCustomerId, + getSubscriptionServiceTypeList : function(globalCustomerId, successCallbackFunction) { $log .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: " + globalCustomerId); - if (UtilityService.hasContents(globalCustomerId)) { + if ( UtilityService.hasContents(globalCustomerId) ) { $http.get( COMPONENT.AAI_SUB_DETAILS_PATH + globalCustomerId + COMPONENT.ASSIGN + Math.random(), { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { if (response.data && response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]) { var serviceTypes = []; var serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]; for (var i = 0; i < serviceSubscriptions.length; i++) { serviceTypes.push({ - "name": serviceSubscriptions[i][FIELD.ID.SERVICETYPE], + "name":serviceSubscriptions[i][FIELD.ID.SERVICETYPE], "isPermitted": serviceSubscriptions[i][FIELD.ID.IS_PERMITTED], "id": i - }); - } + });} successCallbackFunction(serviceTypes); } else { successCallbackFunction([]); @@ -215,19 +236,19 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE (UtilityService.runHttpErrorHandler); } }, - getLcpCloudRegionTenantList: function (globalCustomerId, serviceType, + getLcpCloudRegionTenantList : function(globalCustomerId, serviceType, successCallbackFunction) { $log .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: " + globalCustomerId); - var url = COMPONENT.AAI_GET_TENANTS + var url = COMPONENT.AAI_GET_TENANTS + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); $http.get(url, { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { var lcpCloudRegionTenants = []; var aaiLcpCloudRegionTenants = response.data; @@ -242,24 +263,23 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID], "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME], "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID], - "isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED] - }); + "isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED]}); } successCallbackFunction(lcpCloudRegionTenants); })["catch"] (UtilityService.runHttpErrorHandler); }, - getSubscribers: function (successCallbackFunction) { + getSubscribers : function(successCallbackFunction) { $log .debug("AaiService:getSubscribers"); - var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random(); + var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random(); $http.get(url, { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { if (response.data) { successCallbackFunction(response.data.customer); } else { @@ -268,16 +288,16 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE })["catch"] (UtilityService.runHttpErrorHandler); }, - getProvOptionsFromSystemProp: function (successCallbackFunction) { + getProvOptionsFromSystemProp : function(successCallbackFunction) { $log .debug("AaiService:getProvOptionsFromSystemProp"); - var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH; + var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH; $http.get(url, { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { if (response.data) { successCallbackFunction(response); } else { @@ -286,28 +306,31 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE })["catch"] (UtilityService.runHttpErrorHandler); }, - getLoggedInUserID: function (successCallbackFunction) { + getLoggedInUserID : function(successCallbackFunction) { $log .debug("AaiService:getLoggedInUserID"); var url = COMPONENT.GET_USER_ID; $http.get(url, { - timeout: PropertyService + transformResponse: [function (data) { + return data; + }], + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { if (response.data) { successCallbackFunction(response); } else { successCallbackFunction([]); } - })["catch"] + },function(failure){console.log("failure")})["catch"] (UtilityService.runHttpErrorHandler); }, - getServices: function (successCallbackFunction) { + getServices : function(successCallbackFunction) { $log .debug("AaiService:getServices"); - var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random(); + var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random(); $http.get(url, { @@ -326,31 +349,46 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE getAicZones: function (successCallbackFunction) { $log .debug("getAicZones:getAicZones"); - var url = COMPONENT.AAI_GET_AIC_ZONES + COMPONENT.ASSIGN + Math.random(); + var url = COMPONENT.AAI_GET_AIC_ZONES +COMPONENT.ASSIGN + Math.random(); $http.get(url, { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { if (response.data) { successCallbackFunction(response); } else { successCallbackFunction([]); } })["catch"] - (UtilityService.runHttpErrorHandler); - }, - getServiceModels: function (globalCustomerId, serviceType, successCallbackFunction) { + (UtilityService.runHttpErrorHandler);}, + getAicZoneForPNF: function (globalCustomerId,serviceType,serviceInstanceId,successCallbackFunction) { + $log + .debug("getAicZones:getAicZones"); + var url = COMPONENT.AAI_GET_AIC_ZONE_FOR_PNF + .replace('@serviceInstanceId', serviceInstanceId) + .replace('@globalCustomerId', globalCustomerId) + .replace('@serviceType', serviceType); + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + successCallbackFunction(response.data); + })["catch"] + (UtilityService.runHttpErrorHandler);}, + + getServiceModels : function(globalCustomerId,serviceType,successCallbackFunction) { $log .debug("AaiService:getServices"); - var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); + var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH+globalCustomerId+ COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random(); $http.get(url, { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { if (response.data) { successCallbackFunction(response); } else { @@ -359,16 +397,16 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE })["catch"] (UtilityService.runHttpErrorHandler); }, - getServiceModelsByServiceType: function (namedQueryId, globalCustomerId, serviceType, successCallbackFunction) { + getServiceModelsByServiceType : function(namedQueryId,globalCustomerId,serviceType,successCallbackFunction) { $log .debug("AaiService:getServiceModelsByServiceType"); - var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE + COMPONENT.FORWARD_SLASH + namedQueryId + COMPONENT.FORWARD_SLASH + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random(); + var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE+COMPONENT.FORWARD_SLASH+namedQueryId+COMPONENT.FORWARD_SLASH+globalCustomerId+COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random(); $http.get(url, { - timeout: PropertyService + timeout : PropertyService .getServerResponseTimeoutMsec() - }).then(function (response) { + }).then(function(response) { if (response.data) { successCallbackFunction(response); } else { @@ -376,9 +414,71 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE } })["catch"] (UtilityService.runHttpErrorHandler); + }, + + getVnfsByCustomerIdAndServiceType: function(globalSubscriberId, serviceType){ + var deferred = $q.defer(); + + if (UtilityService.hasContents(globalSubscriberId) && + UtilityService.hasContents(serviceType) ) { + + $http.get(COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + globalSubscriberId + COMPONENT.FORWARD_SLASH + + serviceType ) + .success(function (response) { + if(response) { + deferred.resolve({data: response}); + } else { + deferred.resolve({data: []}); + } + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + } + + return deferred.promise; + }, + + getVnfVersionsByInvariantId: function(modelInvariantId){ + var deferred = $q.defer(); + + if (UtilityService.hasContents(modelInvariantId)) { + var body = {"versions" : modelInvariantId} + $http.post(( COMPONENT.AAI_GET_VERSION_BY_INVARIANT_ID),body) + + .success(function (response) { + if(response) { + deferred.resolve({data: response}); + } else { + deferred.resolve({data: []}); + } + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + } + + return deferred.promise; + }, + + getSubscriberServiceTypes: function(subscriberUuid) { + var deferred = $q.defer(); + $log.debug("AaiService:getSubscriberServiceTypes: subscriberUuid: " + subscriberUuid); + + if (UtilityService.hasContents(subscriberUuid)) { + $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + subscriberUuid + COMPONENT.ASSIGN + Math.random()) + .success(function (response) { + if(response && [FIELD.ID.SERVICE_SUBSCRIPTIONS]) { + deferred.resolve({data: response[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]}); + } else { + deferred.resolve({data: []}); + } + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + } + + return deferred.promise; } - } -} + }}; appDS2.factory("AaiService", ["$http", "$log", "PropertyService", - "UtilityService", "COMPONENT", "FIELD", AaiService]); + "UtilityService", "COMPONENT", "FIELD", "$q", AaiService]); 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 new file mode 100644 index 00000000..f2282d69 --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js @@ -0,0 +1,76 @@ +(function () { + 'use strict'; + + appDS2.service('changeManagementService', ['$http', '$q', 'COMPONENT', 'VIDCONFIGURATION', changeManagementService]); + + function changeManagementService($http, $q, COMPONENT, VIDCONFIGURATION) { + this.getWorkflows = function (vnfs) { + var deferred = $q.defer(); + + $http.get(COMPONENT.GET_WORKFLOW.replace("@vnfs", vnfs)) + .success(function (response) { + deferred.resolve({data: response}); + }).error(function (data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + }; + + this.getMSOChangeManagements = function() { + var deferred = $q.defer(); + + $http.get(COMPONENT.GET_MSO_WORKFLOWS) + .success(function (response) { + deferred.resolve({data: response}); + }) + .error(function(data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + }; + + this.getAllSDCServices = function () { + var deferred = $q.defer(); + + $http.get(COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS) + .success(function (response) { + deferred.resolve({data: response}); + }) + .error(function(data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + }; + + this.getSDCService = function(uuid) { + var deferred = $q.defer(); + + $http.get(COMPONENT.SERVICES_PATH + uuid) + .success(function (response) { + deferred.resolve({data: response}); + }) + .error(function(data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + }; + + this.getSchedulerChangeManagements = function(){ + var deferred = $q.defer(); + + $http.get(COMPONENT.GET_SCHEDULER_CHANGE_MANAGEMENTS) + .success(function (response) { + deferred.resolve({data: response}); + }) + .error(function(data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + + return deferred.promise; + }; + } +})(); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js index 9309ce6c..e171e285 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js @@ -274,7 +274,6 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON } parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK); if(_this.componentId === COMPONENT.VF_MODULE ){ - if(DataService.getSubscriberName() === FIELD.NAME.MOBILITY){ parameterList.push({name: FIELD.NAME.SDN_C_PRELOAD, id: FIELD.ID.SDN_C_PRELOAD, type: "checkbox", @@ -283,7 +282,6 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON hideFieldAndLabel: true } ); - } parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE, id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE, type: "checkbox", @@ -602,7 +600,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON requestDetails.requestParameters.usePreload = getValueFromList( FIELD.ID.SDN_C_PRELOAD, parameterList); if(_this.componentId == COMPONENT.VF_MODULE &&(requestDetails.requestParameters.usePreload== null || requestDetails.requestParameters.usePreload === '')){ - requestDetails.requestParameters.usePreload = true; + requestDetails.requestParameters.usePreload = false; } break; case COMPONENT.VOLUME_GROUP: diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/msoService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/msoService.js index 864abe67..68c8503d 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/msoService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/msoService.js @@ -20,156 +20,240 @@ "use strict"; -var MsoService = function($http, $log, PropertyService, UtilityService, COMPONENT, FIELD) { +var MsoService = function($http, $log, PropertyService, AaiService, UtilityService, COMPONENT, FIELD, $q) { - var _this = this; + var _this = this; /* * Common function to handle both create and delete instance requests */ - var requestInstanceUpdate = function(request, successCallbackFunction) { - $log.debug("MsoService:requestInstanceUpdate: request:"); - $log.debug(request); - $http.post( "mso/" + request.url, { - requestDetails : request.requestDetails - }, { - timeout : PropertyService.getServerResponseTimeoutMsec() - }).then(successCallbackFunction)["catch"] - (UtilityService.runHttpErrorHandler); - } - - var checkValidStatus = function(response) { - if (response.data.status < 200 || response.data.status > 202) { - throw { - type : FIELD.ID.MSO_FAILURE - } - } - } - - var addListEntry = function(name, value) { - var entry = '"' + name + '": '; - if (value === undefined) { - return entry + "undefined"; - } else { - return entry + '"' + value + '"'; - } - } - - return { - createInstance : requestInstanceUpdate, - deleteInstance : requestInstanceUpdate, - getOrchestrationRequest : function(requestId, successCallbackFunction) { - $log.debug("MsoService:getOrchestrationRequest: requestId: " - + requestId); - $http.get( - "mso/mso_get_orch_req/" - + requestId + "?r=" + Math.random(), - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(successCallbackFunction)["catch"] - (UtilityService.runHttpErrorHandler); - }, - getOrchestrationRequests : function(filterString, - successCallbackFunction) { - $log.debug("MsoService:getOrchestrationRequests: filterString: " - + filterString); - $http.get( - "mso/mso_get_orch_reqs/" - + encodeURIComponent(filterString) + "?r=" - + Math.random(), - { - timeout : PropertyService - .getServerResponseTimeoutMsec() - }).then(successCallbackFunction)["catch"] - (UtilityService.runHttpErrorHandler); - }, - getFormattedCommonResponse : function(response) { - return UtilityService.getCurrentTime() + " HTTP Status: " - + UtilityService.getHttpStatusText(response.data.status) - + "\n" + angular.toJson(response.data.entity, true) - - }, - checkValidStatus : checkValidStatus, - getFormattedGetOrchestrationRequestsResponse : function(response) { - UtilityService.checkUndefined(COMPONENT.ENTITY, response.data.entity); - UtilityService.checkUndefined(COMPONENT.STATUS, response.data.status); - checkValidStatus(response); - - var list = response.data.entity.requestList - UtilityService.checkUndefined(FIELD.ID.REQUEST_LIST, list); - - var message = ""; - - for (var i = 0; i < list.length; i++) { - var request = list[i].request; - message += addListEntry(FIELD.ID.REQUEST_ID, request.requestId) + ",\n"; - message += addListEntry(FIELD.ID.REQUEST_TYPE, request.requestType) - + ",\n"; - var status = request.requestStatus; - if (status === undefined) { - message += addListEntry(FIELD.ID.REQUEST_STATUS, undefined) + "\n"; - } else { - message += addListEntry(FIELD.ID.TIMESTAMP, status.timestamp) - + ",\n"; - message += addListEntry(FIELD.ID.REQUEST_STATE, status.requestState) - + ",\n"; - message += addListEntry(FIELD.ID.REQUEST_STATUS, - status.statusMessage) - + ",\n"; - message += addListEntry(FIELD.ID.PERCENT_PROGRESS, - status.percentProgress) - + "\n"; - } - if (i < (list.length - 1)) { - message += "\n"; - } - } - return message; - }, - getFormattedSingleGetOrchestrationRequestResponse : function (response) { - UtilityService.checkUndefined(COMPONENT.ENTITY, response.data.entity); - UtilityService.checkUndefined(COMPONENT.STATUS, response.data.status); - checkValidStatus(response); - - var message = ""; - if ( UtilityService.hasContents (response.data.entity.request) ) { - var request = response.data.entity.request; - message += addListEntry(FIELD.ID.REQUEST_ID, request.requestId) + ",\n"; - message += addListEntry(FIELD.ID.REQUEST_TYPE, request.requestType) - + ",\n"; - var status = request.requestStatus; - if (status === undefined) { - message += addListEntry(FIELD.ID.REQUEST_STATUS, undefined) + "\n"; - } else { - message += addListEntry(FIELD.ID.TIMESTAMP, status.timestamp) - + ",\n"; - message += addListEntry(FIELD.ID.REQUEST_STATE, status.requestState) - + ",\n"; - message += addListEntry(FIELD.ID.REQUEST_STATUS, - status.statusMessage) - + ",\n"; - message += addListEntry(FIELD.ID.PERCENT_PROGRESS, - status.percentProgress) - + "\n\n"; - } - } - return message; - }, - showResponseContentError : function(error, showFunction) { - switch (error.type) { - case "undefinedObject": - showFunction(FIELD.ERROR.SYSTEM_FAILURE, error.message); - break; - case "msoFailure": - showFunction(FIELD.ERROR.MSO, "") - break; - default: - showFunction(FIELD.ERROR.SYSTEM_FAILURE); - } - } - } -} + var requestInstanceUpdate = function(request, successCallbackFunction) { + $log.debug("MsoService:requestInstanceUpdate: request:"); + $log.debug(request); + $http.post( "mso/" + request.url, { + requestDetails : request.requestDetails + }, { + timeout : PropertyService.getServerResponseTimeoutMsec() + }).then(successCallbackFunction)["catch"] + (UtilityService.runHttpErrorHandler); + } + + var checkValidStatus = function(response) { + if (response.data.status < 200 || response.data.status > 202) { + throw { + type : FIELD.ID.MSO_FAILURE + } + } + }; + + var addListEntry = function(name, value) { + var entry = '"' + name + '": '; + if (value === undefined) { + return entry + "undefined"; + } else { + return entry + '"' + value + '"'; + } + }; + + var activateInstance = function(instance, model) { + var deferred = $q.defer(); + + AaiService.getLoggedInUserID(function (response) { + var userID = response.data; + + AaiService.getAicZoneForPNF(instance.globalCustomerId, model.service.serviceType, instance.serviceInstanceId, function (aicZone) { + + var requestDetails = { + "modelInstanceId": serviceInstanceId, + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": model.service.invariantUuid, + "modelVersionId": model.service.uuid, + "modelName": model.service.name, + "modelVersion": model.service.version + }, + "requestInfo": { + "source": "VID", + "requestorId": userID + }, + "requestParameters": { + "userParams": { + "name": "aic_zone", + "value": aicZone + } + } + } + }; + + console.log("requestDetails", requestDetails); + + $http.post(COMPONENT.MSO_ACTIVATE_INSTANCE.replace('@serviceInstanceId', requestDetails.modelInstanceId), + requestDetails.requestDetails) + .success(function (response) { + deferred.resolve({data: response}); + }) + .error(function(data, status, headers, config) { + deferred.reject({message: data, status: status}); + }); + }); + }); + + return deferred.promise; + }; + + return { + createInstance : requestInstanceUpdate, + deleteInstance : requestInstanceUpdate, + getOrchestrationRequest : function(requestId, successCallbackFunction) { + $log.debug("MsoService:getOrchestrationRequest: requestId: " + + requestId); + $http.get( + "mso/mso_get_orch_req/" + + requestId + "?r=" + Math.random(), + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(successCallbackFunction)["catch"] + (UtilityService.runHttpErrorHandler); + }, + getOrchestrationRequests : function(filterString, + successCallbackFunction) { + $log.debug("MsoService:getOrchestrationRequests: filterString: " + + filterString); + $http.get( + "mso/mso_get_orch_reqs/" + + encodeURIComponent(filterString) + "?r=" + + Math.random(), + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(successCallbackFunction)["catch"] + (UtilityService.runHttpErrorHandler); + }, + getFormattedCommonResponse : function(response) { + return UtilityService.getCurrentTime() + " HTTP Status: " + + UtilityService.getHttpStatusText(response.data.status) + + "\n" + angular.toJson(response.data.entity, true) + + }, + checkValidStatus : checkValidStatus, + getFormattedGetOrchestrationRequestsResponse : function(response) { + UtilityService.checkUndefined(COMPONENT.ENTITY, response.data.entity); + UtilityService.checkUndefined(COMPONENT.STATUS, response.data.status); + checkValidStatus(response); + + var list = response.data.entity.requestList + UtilityService.checkUndefined(FIELD.ID.REQUEST_LIST, list); + + var message = ""; + + for (var i = 0; i < list.length; i++) { + var request = list[i].request; + message += addListEntry(FIELD.ID.REQUEST_ID, request.requestId) + ",\n"; + message += addListEntry(FIELD.ID.REQUEST_TYPE, request.requestType) + + ",\n"; + var status = request.requestStatus; + if (status === undefined) { + message += addListEntry(FIELD.ID.REQUEST_STATUS, undefined) + "\n"; + } else { + message += addListEntry(FIELD.ID.TIMESTAMP, status.timestamp) + + ",\n"; + message += addListEntry(FIELD.ID.REQUEST_STATE, status.requestState) + + ",\n"; + message += addListEntry(FIELD.ID.REQUEST_STATUS, + status.statusMessage) + + ",\n"; + message += addListEntry(FIELD.ID.PERCENT_PROGRESS, + status.percentProgress) + + "\n"; + } + if (i < (list.length - 1)) { + message += "\n"; + } + } + return message; + }, + getFormattedSingleGetOrchestrationRequestResponse : function (response) { + UtilityService.checkUndefined(COMPONENT.ENTITY, response.data.entity); + UtilityService.checkUndefined(COMPONENT.STATUS, response.data.status); + checkValidStatus(response); + + var message = ""; + if ( UtilityService.hasContents (response.data.entity.request) ) { + var request = response.data.entity.request; + message += addListEntry(FIELD.ID.REQUEST_ID, request.requestId) + ",\n"; + message += addListEntry(FIELD.ID.REQUEST_TYPE, request.requestType) + + ",\n"; + var status = request.requestStatus; + if (status === undefined) { + message += addListEntry(FIELD.ID.REQUEST_STATUS, undefined) + "\n"; + } else { + message += addListEntry(FIELD.ID.TIMESTAMP, status.timestamp) + + ",\n"; + message += addListEntry(FIELD.ID.REQUEST_STATE, status.requestState) + + ",\n"; + message += addListEntry(FIELD.ID.REQUEST_STATUS, + status.statusMessage) + + ",\n"; + message += addListEntry(FIELD.ID.PERCENT_PROGRESS, + status.percentProgress) + + "\n\n"; + } + } + return message; + }, + getManualTasks : function(requestId) { + $log.debug("MsoService:getManualTasks: requestId: " + + requestId); + return $http.get( + "mso/mso_get_man_task/" + requestId, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }) + .catch(UtilityService.runHttpErrorHandler); + }, + completeTask: function(taskId, taskToComplete) { + $log.debug("MsoService:completeTask: taskId: " + + taskId); + AaiService.getLoggedInUserID(function (response) { + var attuid = response.data; + var source = "VID"; + var data = { + requestDetails: { + requestInfo: { + source: source, + responseValue: taskToComplete, + requestorId: attuid + } + } + }; + + return $http.post( + "mso/mso_post_man_task/" + taskId, data, + { + timeout: PropertyService + .getServerResponseTimeoutMsec() + }) + .catch(UtilityService.runHttpErrorHandler); + }); + }, + showResponseContentError : function(error, showFunction) { + switch (error.type) { + case "undefinedObject": + showFunction(FIELD.ERROR.SYSTEM_FAILURE, error.message); + break; + case "msoFailure": + showFunction(FIELD.ERROR.MSO, "") + break; + default: + showFunction(FIELD.ERROR.SYSTEM_FAILURE); + } + }, + activateInstance: activateInstance + } +}; appDS2.factory("MsoService", [ "$http", "$log", "PropertyService", - "UtilityService", "COMPONENT", "FIELD", MsoService ]); + "AaiService", "UtilityService", "COMPONENT", "FIELD", "$q", MsoService ]); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/schedulerService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/schedulerService.js new file mode 100644 index 00000000..83cc4dda --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/schedulerService.js @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +"use strict"; + +var SchedulerService = function($http, $log, PropertyService, UtilityService, COMPONENT, FIELD) { + return { + + getStatusSchedulerId : function(schedulerInfo,successCallbackFunction) { + $log + .debug("SchedulerService:getSchedulerStatusAndSchedulerId"); + var url = COMPONENT.POST_CREATE_NEW_VNF_CHANGE+COMPONENT.ASSIGN + Math.random(); + + $http.post(url, schedulerInfo, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + + getTimeSotsForSchedulerId:function(schedulerID,successCallbackFunction){ + $log + .debug("SchedulerService:getTimeSlotsForSchedulerID"); + var url = COMPONENT.GET_TIME_SLOTS+COMPONENT.FORWARD_SLASH +schedulerID+COMPONENT.ASSIGN; + + $http.get(url, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + + (UtilityService.runHttpErrorHandler); + }, + getSubmitForapprovedTimeslots: function(ApprovedTimeSlotsObj,successCallbackFunction) { + $log + .debug("SchedulerService:getSchedulerStatusAndSchedulerId"); + var url = COMPONENT.SUBMIT_VNF_CHANGE_TIMESLOTS+COMPONENT.ASSIGN + Math.random(); + + $http.post(url, ApprovedTimeSlotsObj, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + }, + getPolicyInfo:function(policyName,successCallbackFunction){ + $log + .debug("SchedulerService:getPolicyInfo"); + var url = COMPONENT.GET_POLICY +COMPONENT.ASSIGN + Math.random(); + + $http.post(url, policyName, + { + timeout : PropertyService + .getServerResponseTimeoutMsec() + }).then(function(response) { + if (response.data) { + successCallbackFunction(response); + } else { + successCallbackFunction([]); + } + })["catch"] + (UtilityService.runHttpErrorHandler); + } + } +} + +appDS2.factory("SchedulerService", ["$http", "$log", "PropertyService", + "UtilityService", "COMPONENT", "FIELD", SchedulerService]); -- cgit 1.2.3-korg