aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/webapp/app/vid/scripts/services
diff options
context:
space:
mode:
authorjimmydot <jf2512@att.com>2017-05-07 14:58:24 -0400
committerjimmydot <jf2512@att.com>2017-05-07 14:58:24 -0400
commit3982f4f67314ec37fd9b22ae54049958af777c1b (patch)
tree72111b7c13ee7529cce1ea4c8d83c89fdd164450 /vid-app-common/src/main/webapp/app/vid/scripts/services
parent00e0d25933699f9e39c3f0b86c983165a1e3e330 (diff)
[VID-6] Initial rebase push
Change-Id: I9077be9663754d9b22f77c6a7b3109b361b39346 Signed-off-by: jimmydot <jf2512@att.com>
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/services')
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js339
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js40
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js178
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js924
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js243
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js502
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/detailsService.js98
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/msoService.js175
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/propertyService.js89
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/statusService.js185
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/utilityService.js640
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js82
12 files changed, 3495 insertions, 0 deletions
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
new file mode 100755
index 000000000..8132e3a33
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
@@ -0,0 +1,339 @@
+/*-
+ * ============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 AaiService = function($http, $log, PropertyService, UtilityService, COMPONENT, FIELD) {
+ return {
+ getSubscriberName : function(globalCustomerId,
+ successCallbackFunction) {
+ $log
+ .debug("AaiService:getSubscriberName: globalCustomerId: "
+ + globalCustomerId);
+ $http.get(
+ COMPONENT.AAI_SUB_DETAILS_PATH
+ + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ var subName = "";
+ if (response.data) {
+ subName = response.data[FIELD.ID.SUBNAME];
+ }
+ successCallbackFunction(subName);
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+
+
+ runNamedQuery : function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
+
+ var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) +
+ 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) {
+ 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) {
+ var serviceInstanceId = [];
+ var serviceType = "";
+ if (serviceSubscription[FIELD.ID.SERVICE_TYPE] != null) {
+ serviceType = serviceSubscription[FIELD.ID.SERVICE_TYPE];
+ } else {
+ 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) {
+ // put them together, i guess
+ 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]
+ };
+ if (selectedServiceInstance != null) {
+ if ((instValue[FIELD.ID.SERVICE_INSTANCE_ID] == selectedServiceInstance ) || (instValue[FIELD.ID.SERVICE_INSTANCE_NAME] == selectedServiceInstance)) {
+ serviceInstanceId.push(inst);
+ }
+ } else {
+ serviceInstanceId.push(inst);
+ }
+ });
+ } else {
+ if (serviceInstanceId == []) {
+ serviceInstanceId = [ FIELD.PROMPT.NO_SERVICE_INSTANCE ];
+ }
+ }
+ 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
+ });
+ });
+ });
+ } else {
+ displayData.push({
+ globalCustomerId : selectedSubscriber,
+ subscriberName : selectedSubscriberName,
+ serviceType : FIELD.PROMPT.NO_SERVICE_SUB,
+ serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE
+ });
+ }
+ successCallback(displayData, subscriberName);
+ }, function(response) {
+ errorCallback(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] };
+ customerList.push(cust);
+ });
+ successCallback(customerList);
+ } else {
+ errorCallback(response);
+ }
+ },function(response) {
+ errorCallback(response);
+ });
+ },
+
+ getServices2 : function(successCallback, errorCallback ) {
+
+ $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] };
+ serviceIdList.push(newVal);
+ });
+ });
+ successCallback(serviceIdList);
+ } else {
+ errorCallback(response);
+ }
+ },function(response) {
+ errorCallback(response);
+ });
+ },
+
+ getSubscriptionServiceTypeList : function(globalCustomerId,
+ successCallbackFunction) {
+ $log
+ .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: "
+ + globalCustomerId);
+ if ( UtilityService.hasContents(globalCustomerId) ) {
+ $http.get(
+ COMPONENT.AAI_SUB_DETAILS_PATH
+ + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).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(serviceSubscriptions[i][FIELD.ID.SERVICE_TYPE]);
+ }
+ successCallbackFunction(serviceTypes);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ }
+ },
+ getLcpCloudRegionTenantList : function(globalCustomerId, serviceType,
+ successCallbackFunction) {
+ $log
+ .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: "
+ + globalCustomerId);
+ var url = COMPONENT.AAI_GET_TENANTS
+ + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ var lcpCloudRegionTenants = [];
+ var aaiLcpCloudRegionTenants = response.data;
+
+ lcpCloudRegionTenants.push({
+ "cloudRegionId": "",
+ "tenantName": FIELD.PROMPT.REGION,
+ "tenantId": ""
+ });
+
+ for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) {
+ lcpCloudRegionTenants.push({
+ "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID],
+ "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME],
+ "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID]
+ });
+ }
+
+ successCallbackFunction(lcpCloudRegionTenants);
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+ getSubscribers : function(successCallbackFunction) {
+ $log
+ .debug("AaiService:getSubscribers");
+ var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response.data.customer);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+ getProvOptionsFromSystemProp : function(successCallbackFunction) {
+ $log
+ .debug("AaiService:getProvOptionsFromSystemProp");
+ var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH;
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+ getLoggedInUserID : function(successCallbackFunction) {
+ $log
+ .debug("AaiService:getLoggedInUserID");
+ var url = COMPONENT.GET_USER_ID;
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+ getServices : function(successCallbackFunction) {
+ $log
+ .debug("AaiService:getServices");
+ var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["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();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+}
+ }
+}
+
+appDS2.factory("AaiService", [ "$http", "$log", "PropertyService",
+ "UtilityService", "COMPONENT", "FIELD", AaiService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js
new file mode 100755
index 000000000..68fdce44f
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js
@@ -0,0 +1,40 @@
+/*-
+ * ============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 AsdcService = function($http, $log, PropertyService, UtilityService) {
+ return {
+ getModel : function(modelId, successCallbackFunction) {
+ $log.debug("AsdcService:getModel: modelId: " + modelId);
+ $http.get(
+ "asdc/getModel/" + modelId
+ + "?r=" + Math.random(),
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(successCallbackFunction)["catch"]
+ (UtilityService.runHttpErrorHandler);
+ }
+ }
+}
+
+appDS2.factory("AsdcService", [ "$http", "$log", "PropertyService",
+ "UtilityService", AsdcService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js
new file mode 100755
index 000000000..391c6ba13
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/componentService.js
@@ -0,0 +1,178 @@
+/*-
+ * ============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 ComponentService = function($log, COMPONENT, UtilityService) {
+
+ var _this = this;
+
+ var componentList = [ {
+ id : COMPONENT.NETWORK,
+ displayName : "Network"
+ }, {
+ id : COMPONENT.SERVICE,
+ displayName : "Service Instance"
+ }, {
+ id : COMPONENT.VNF,
+ displayName : "Virtual Network Function"
+ }, {
+ id : COMPONENT.VF_MODULE,
+ displayName : "VF Module"
+ }, {
+ id : COMPONENT.VOLUME_GROUP,
+ displayName : "Volume Group"
+ } ];
+
+ var getInventoryInfo = function(suffix, inventoryItem) {
+ var pattern = new RegExp(suffix + "-");
+ for ( var key in inventoryItem) {
+ if (pattern.exec(key)) {
+ return inventoryItem[key];
+ }
+ }
+ };
+
+ /*
+ * Converts 'id' to a user friendly version.
+ *
+ * The algorithm used is:
+ *
+ * 1) If "id" found in COMPONENT.FULL_NAME_MAP, return the name found in the
+ * map.
+ *
+ * 2) Otherwise, if camel case, add "-" between camel case words.
+ *
+ * 3) Split id into multiple "partial names" assuming "-" is the delimiter.
+ *
+ * 4) Map any partial names found in COMPONENT.PARTIAL_NAME_MAP to the name
+ * found in the map.
+ *
+ * 5) Use partial names whenever not found in map.
+ *
+ * 5) Return name by combining all partial names with " " delimiter.
+ */
+ var getDisplayName = function(id) {
+ var tmp = COMPONENT.FULL_NAME_MAP[id.toLowerCase()];
+ if (UtilityService.hasContents(tmp)) {
+ return tmp;
+ }
+ /*
+ * Add "-" if camel case found.
+ */
+ var id = id.replace(/([a-z](?=[A-Z]))/g, '$1-');
+ var name = "";
+ var arg = id.split("-");
+ for (var i = 0; i < arg.length; i++) {
+ if (i > 0) {
+ name += " ";
+ }
+ var tmp = COMPONENT.PARTIAL_NAME_MAP[arg[i].toLowerCase()];
+ if (UtilityService.hasContents(tmp)) {
+ name += tmp;
+ } else {
+ name += arg[i].slice(0, 1).toUpperCase() + arg[i].slice(1);
+ }
+ }
+ return name;
+ };
+
+ return {
+ initialize : function(componentId) {
+ for (var i = 0; i < componentList.length; i++) {
+ if (componentList[i].id === componentId) {
+ _this.componentId = componentList[i].id;
+ return componentId;
+ }
+ }
+ throw "ComponentService:initializeComponent: componentId not found: "
+ + componentId;
+ },
+ getComponentDisplayName : function() {
+ for (var i = 0; i < componentList.length; i++) {
+ if (componentList[i].id === _this.componentId) {
+ return componentList[i].displayName;
+ }
+ }
+ },
+ getInventoryInfo : getInventoryInfo,
+ getInventoryParameterList : function(suffix, inventoryItem, isPartial) {
+ console.log ("getInventoryParameterList" ); console.log ( JSON.stringify ( inventoryItem, null, 4));
+ var parameterList = new Array();
+ var pattern = new RegExp("network-id|network-name");
+ var pattern1 = new RegExp("neutron");
+
+ if ( (suffix === COMPONENT.NETWORK) && (isPartial) ) {
+ for ( var id in inventoryItem.object) {
+ if (pattern.exec(id) && (!(pattern1.exec(id))) ) {
+ parameterList.push({
+ id : id,
+ value : inventoryItem.object[id]
+ });
+ }
+ }
+ }
+ else if (suffix === COMPONENT.NETWORK) {
+ for ( var id in inventoryItem.object) {
+ parameterList.push({
+ id : id,
+ value : inventoryItem.object[id]
+ });
+ }
+ for ( var index in inventoryItem.subnets) {
+ for (var fieldId in inventoryItem.subnets[index]) {
+ parameterList.push({
+ id : fieldId,
+ value : inventoryItem.subnets[index][fieldId]
+ });
+ }
+ }
+ }
+ else {
+ for ( var id in inventoryItem) {
+ //if (pattern.exec(id)) {
+ parameterList.push({
+ id : id,
+ value : inventoryItem[id]
+ });
+ //}
+ }
+ }
+ return parameterList;
+ },
+ getDisplayNames : function(inputList) {
+ var outputList = new Array();
+ for (var i = 0; i < inputList.length; i++) {
+ var entry = angular.copy(inputList[i]);
+ if (!UtilityService.hasContents(entry.name)) {
+ entry.name = getDisplayName(entry.id);
+ }
+ outputList.push(entry);
+ }
+ return outputList;
+ },
+ getFieldDisplayName : function(name) {
+ return getDisplayName(name);
+ }
+ }
+}
+
+appDS2.factory("ComponentService", [ "$log", "COMPONENT", "UtilityService",
+ ComponentService ]);
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
new file mode 100755
index 000000000..f6838af09
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js
@@ -0,0 +1,924 @@
+/*-
+ * ============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";
+
+/*
+ * "CreationService" isolates the "component-specific" logic required by the
+ * "CreationDialog" controller.
+ *
+ * "Components" are defined as the 5 element types managed by the dialogs: A)
+ * Service B) VNF C) VF Module D) Volume Group and E) Network.
+ *
+ */
+
+var CreationService = function($log, AaiService, AsdcService, DataService,
+ ComponentService, COMPONENT, FIELD, PARAMETER, UtilityService) {
+
+ var _this = this;
+
+ var getAsyncOperationList = function() {
+ if (DataService.getLoggedInUserId() == null)
+ getLoggedInUserID();
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ return [ getSubscribers, getServices ];
+ case COMPONENT.NETWORK:
+ return [ getLcpCloudRegionTenantList ];
+ case COMPONENT.VNF:
+ return [ getLcpCloudRegionTenantList ];
+ case COMPONENT.VF_MODULE:
+ return [ getLcpCloudRegionTenantList ];
+ case COMPONENT.VOLUME_GROUP:
+ return [ getLcpCloudRegionTenantList ];
+ }
+ };
+
+ /*
+ * "getSummaryList" and "getUserProvidedList" return parameters that should
+ * be displayed in the summary and user provided sections, respectively. The
+ * functions are expected to return lists that are in the format needed by
+ * the parameter-block directive.
+ */
+
+ var getSummaryList = function() {
+
+ /*
+ * These placeholders should be removed and their usage in
+ * "getSummaryList" should be replaced by appropriate code as the
+ * requirements and interfaces firm up.
+ */
+
+ var PLACEHOLDER_RESOURCE_DESCRIPTION = "Resource Description (PLACEHOLDER)";
+ var PLACEHOLDER_SERVICE_CATEGORY = "Service Category (PLACEHOLDER)";
+ var PLACEHOLDER_VF_MODULE_DESCRIPTION = "VF Module Description (PLACEHOLDER)";
+ var PLACEHOLDER_VF_MODULE_LABEL = "VF Module Label (PLACEHOLDER)";
+ var PLACEHOLDER_VF_MODULE_TYPE = "VF Module Type (PLACEHOLDER)";
+
+ _this.parameterList = new Array();
+
+ /*
+ * Common fields displayed at the top of all create instance screens.
+ */
+ addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
+
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ if ( !DataService.getALaCarte() ) {
+ // for macro instantiation need to add the resource names under the node template list
+ // this field is called modelCustomizationName in the asdc client code
+ var p;
+ var rlist = DataService.getResources();
+ var res;
+ if ( rlist != null ) {
+ for (var i = 0; i < rlist.length; i++) {
+ res = rlist[i];
+
+ p = FIELD.NAME.RESOURCE_NAME.concat(" " + (i+1));
+ addToList(p, res.name );
+ p = FIELD.NAME.RESOURCE_DESCRIPTION.concat(" " + (i+1));
+ addToList(p, res.description );
+ }
+ }
+ }
+ addToList(FIELD.NAME.SERVICE_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.SERVICE_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.SERVICE_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.SERVICE_DESCRIPTION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.DESCRIPTION]);
+ addToList(FIELD.NAME.SERVICE_CATEGORY, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CATEGORY]);
+ break;
+ case COMPONENT.VF_MODULE:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
+ break;
+ case COMPONENT.VNF:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_CUSTOMIZATION_NAME]);
+ addToList(FIELD.NAME.MODEL_VNF_TYPE, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_TYPE]);
+ addToList(FIELD.NAME.MODEL_VNF_ROLE, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_ROLE]);
+ addToList(FIELD.NAME.MODEL_VNF_FUNCTION, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_FUNCTION]);
+ addToList(FIELD.NAME.MODEL_VNF_CODE, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_CODE]);
+ break;
+ case COMPONENT.NETWORK:
+ case COMPONENT.VOLUME_GROUP:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
+ break;
+ }
+
+ return _this.parameterList;
+ };
+
+ var getUserProvidedList = function() {
+ parameterList = [];
+ var isUserProvidedNaming = false;
+ if ( (DataService.getModelInfo(_this.componentId).serviceEcompNaming != null)
+ && (DataService.getModelInfo(_this.componentId).serviceEcompNaming === "false") ) {
+ isUserProvidedNaming = true;
+ }
+ var parameterList;
+ if (_this.componentId === COMPONENT.SERVICE) {
+ if ( DataService.getALaCarte() ) {
+ parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
+ parameterList = parameterList.concat([ getSubscribersParameter(),
+ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
+ }
+ else {
+ // macro
+ if (isUserProvidedNaming) {
+ parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
+
+ }
+ parameterList = parameterList.concat([ getSubscribersParameter(),
+ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
+ parameterList = parameterList.concat([ getServiceId(),
+ FIELD.PARAMETER.SERVICE_TYPE,
+ FIELD.PARAMETER.LCP_REGION,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ }
+ else {
+ parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ case COMPONENT.VNF:
+ parameterList = parameterList.concat([ getServiceId(),
+ getLcpRegion(), FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ break;
+ case COMPONENT.VF_MODULE:
+ parameterList = parameterList.concat([
+ getLcpRegion(),
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED
+ ]);
+
+ var availableVolumeGroupList = DataService.getAvailableVolumeGroupList();
+
+ if (availableVolumeGroupList && availableVolumeGroupList.length > 0) {
+ var availableVolumeGroupNames = [FIELD.STATUS.NONE];
+
+ for (var i = 0; i < availableVolumeGroupList.length; i++) {
+ availableVolumeGroupNames.push(availableVolumeGroupList[i].instance.name);
+ }
+
+ parameterList.push(addOptionList(
+ FIELD.PARAMETER.AVAILABLE_VOLUME_GROUP,
+ availableVolumeGroupNames));
+ }
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ parameterList = parameterList.concat([ getLcpRegion(),
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ }
+
+ parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK);
+
+ addArbitraryParameters(parameterList);
+
+ return parameterList;
+ };
+
+ var addArbitraryParameters = function(parameterList) {
+ if ( DataService.getModelInfo(_this.componentId).displayInputs != null ) {
+ var inputs = DataService.getModelInfo(_this.componentId).displayInputs;
+ for ( var key in inputs) {
+ var parameter = {
+ id : key,
+ type : PARAMETER.STRING,
+ name : ComponentService.getFieldDisplayName(key),
+ value : inputs[key][PARAMETER.DEFAULT],
+ isRequired : inputs[key][PARAMETER.REQUIRED],
+ description : inputs[key][PARAMETER.DESCRIPTION]
+ };
+ switch (inputs[key][PARAMETER.TYPE]) {
+ case PARAMETER.INTEGER:
+ parameter.type = PARAMETER.NUMBER;
+ break;
+ case PARAMETER.BOOLEAN:
+ parameter.type = PARAMETER.BOOLEAN;
+ break;
+ case PARAMETER.RANGE:
+ break;
+ case PARAMETER.LIST:
+ break;
+ case PARAMETER.MAP:
+ parameter.type = PARAMETER.MAP;
+ break;
+ }
+
+ if ( UtilityService.hasContents(inputs[key][PARAMETER.CONSTRAINTS])
+ && ( inputs[key][PARAMETER.CONSTRAINTS].length > 0 ) ) {
+ var constraintsArray = inputs[key][PARAMETER.CONSTRAINTS];
+ //console.log ("Calling addConstraintParameters for input name=" + key);
+ addConstraintParameters (parameterList, constraintsArray, key, inputs, parameter);
+ }
+ else {
+
+ parameterList.push(parameter);
+ }
+ }
+ }
+ };
+
+ var addConstraintParameters = function(parameterList, constraintsArray, key, inputs, parameter) {
+ // If there are constraints and the operator is "valid_values",
+ // use a select parameter type.
+ var i = constraintsArray.length;
+ var parameterPushed = false;
+ if ( i > 0 ) {
+ while ( (i--) && (!parameterPushed) ) {
+ var keys = Object.keys(constraintsArray[i]);
+ //var keys_len = keys.length;
+ for ( var operator in keys ) {
+ //console.log ("keys[operator]=" + keys[operator]);
+ switch (keys[operator]) {
+ case PARAMETER.VALID_VALUES:
+ var j = constraintsArray[i][PARAMETER.VALID_VALUES].length;
+ if ( j > 0 ) {
+ var oList = [];
+ var option;
+ while (j--) {
+ option = {
+ name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
+ isDefault: false
+ }
+ if ( ( UtilityService.hasContents (inputs[key][PARAMETER.DEFAULT]) )
+ && (inputs[key][PARAMETER.DEFAULT] === constraintsArray[i][PARAMETER.VALID_VALUES][j] ) ) {
+ option = {
+ name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
+ isDefault: true
+ }
+ }
+ oList.push(option);
+ }
+ parameter.type = PARAMETER.SELECT;
+ parameter.optionList = oList;
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for valid values");
+ }
+ break;
+
+ case PARAMETER.EQUAL:
+ if ( constraintsArray[i][PARAMETER.EQUAL] != null ) {
+ //override parameter type
+ parameter.type = PARAMETER.STRING;
+ parameter.isReadOnly = true;
+ parameter.value = constraintsArray[i][PARAMETER.EQUAL];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for equal");
+ }
+ break;
+
+ case PARAMETER.LENGTH:
+ if ( constraintsArray[i][PARAMETER.LENGTH] != null ) {
+ parameter.minLength = constraintsArray[i][PARAMETER.LENGTH];
+ parameter.maxLength = constraintsArray[i][PARAMETER.LENGTH];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for length: ");
+ //console.log (JSON.stringify (parameter, null, 4));
+ }
+ break;
+ case PARAMETER.MAX_LENGTH:
+ if ( constraintsArray[i][PARAMETER.MAX_LENGTH] != null ) {
+ parameter.maxLength = constraintsArray[i][PARAMETER.MAX_LENGTH];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for max length: ");
+ //console.log (JSON.stringify (parameter, null, 4));
+ }
+ break;
+ case PARAMETER.MIN_LENGTH:
+ if ( constraintsArray[i][PARAMETER.MIN_LENGTH] != null ) {
+ parameter.minLength = constraintsArray[i][PARAMETER.MIN_LENGTH];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for min length: ");
+ //console.log (JSON.stringify (parameter, null, 4));
+ }
+ break;
+ case PARAMETER.IN_RANGE:
+ if ( constraintsArray[i][PARAMETER.IN_RANGE] != null ) {
+ if (constraintsArray[i][PARAMETER.IN_RANGE].length > 1 ) {
+ parameter.min = constraintsArray[i][PARAMETER.IN_RANGE][0];
+ parameter.max = constraintsArray[i][PARAMETER.IN_RANGE][1];
+ parameter.type = PARAMETER.NUMBER;
+ parameter.value = inputs[key][PARAMETER.DEFAULT]
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for in_range");
+ }
+ }
+ break;
+ case PARAMETER.GREATER_THAN:
+ if ( constraintsArray[i][PARAMETER.GREATER_THAN] != null ) {
+ parameter.type = PARAMETER.NUMBER;
+ parameter.min = constraintsArray[i][PARAMETER.GREATER_THAN];
+ parameter.value = inputs[key][PARAMETER.DEFAULT]
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for greater_than");
+
+ }
+ break;
+ }//switch
+ }//for
+
+ }//while
+ }//if
+ };
+ var addToList = function(name, value) {
+ _this.parameterList.push({
+ name : name,
+ value : value
+ });
+ };
+
+ /*
+ * The "*Mso*" functions return URL and request details that can be passed
+ * to the MSO controller. The request details defines the info passed as
+ * part of the POST body.
+ */
+
+ var getMsoUrl = function() {
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ return "mso_create_nw_instance/"
+ + DataService.getServiceInstanceId();
+ case COMPONENT.SERVICE:
+ return "mso_create_svc_instance";
+ case COMPONENT.VNF:
+ return "mso_create_vnf_instance/"
+ + DataService.getServiceInstanceId();
+ case COMPONENT.VF_MODULE:
+ return "mso_create_vfmodule_instance/"
+ + DataService.getServiceInstanceId() + "/vnfs/"
+ + DataService.getVnfInstanceId();
+ case COMPONENT.VOLUME_GROUP:
+ return "mso_create_volumegroup_instance/"
+ + DataService.getServiceInstanceId() + "/vnfs/"
+ + DataService.getVnfInstanceId();
+ }
+ };
+
+ var getMsoRequestDetails = function(parameterList) {
+ console.log("getMsoRequestDetails invoked, parameterList="); console.log(JSON.stringify(parameterList,null,4));
+ var modelInfo = DataService.getModelInfo(_this.componentId);
+ var requestorloggedInId = DataService.getLoggedInUserId();
+ if (requestorloggedInId == null)
+ requestorloggedInId = "";
+ var isSupRollback = false;
+ if (getValueFromList(FIELD.ID.SUPPRESS_ROLLBACK,parameterList) === "true") {
+ isSupRollback = true;
+ }
+ var requestDetails = {
+ requestInfo : {
+ instanceName : getValueFromList(FIELD.ID.INSTANCE_NAME,
+ parameterList),
+ source : FIELD.ID.VID,
+ suppressRollback : isSupRollback,
+ requestorId: requestorloggedInId
+ },
+ modelInfo : {
+ modelType : _this.componentId,
+ modelInvariantId : modelInfo.modelInvariantId,
+ modelVersionId : modelInfo.modelNameVersionId,
+ modelName : modelInfo.modelName,
+ modelVersion : modelInfo.modelVersion,
+ modelCustomizationId: modelInfo.customizationUuid,
+ modelCustomizationName : modelInfo.modelCustomizationName
+ },
+ requestParameters : {
+ userParams : getArbitraryParameters(parameterList)
+ }
+ };
+ if ( (_this.componentId != COMPONENT.SERVICE) || ( !DataService.getALaCarte() ) ) {
+ // include cloud region for everything but service create alacarte
+ var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+ if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ }
+ requestDetails.cloudConfiguration = {
+ lcpCloudRegionId : lcpRegion,
+ tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+ }
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ requestDetails.subscriberInfo = {
+ globalSubscriberId : DataService.getGlobalCustomerId(),
+ subscriberName : DataService.getSubscriberName()
+ };
+ requestDetails.requestParameters.subscriptionServiceType = getValueFromList(
+ FIELD.ID.SERVICE_TYPE, parameterList);
+ requestDetails.requestParameters.aLaCarte = DataService.getALaCarte();
+ if ( !DataService.getALaCarte() ) {
+ requestDetails.requestInfo.productFamilyId = getValueFromList(
+ FIELD.ID.PRODUCT_FAMILY, parameterList);
+ }
+ var svcModelInfo = {
+ modelType : _this.componentId,
+ modelInvariantId : modelInfo.modelInvariantId,
+ modelVersionId : modelInfo.modelNameVersionId,
+ modelName : modelInfo.modelName,
+ modelVersion : modelInfo.modelVersion
+ };
+ requestDetails.modelInfo = svcModelInfo;
+ break;
+ case COMPONENT.VNF:
+
+ requestDetails.requestInfo.productFamilyId = getValueFromList(
+ FIELD.ID.PRODUCT_FAMILY, parameterList);
+ break;
+ case COMPONENT.NETWORK:
+ requestDetails.requestInfo.productFamilyId = getValueFromList(
+ FIELD.ID.PRODUCT_FAMILY, parameterList);
+
+ break;
+ case COMPONENT.VF_MODULE:
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ break;
+ }
+
+ var relatedInstanceList = getRelatedInstanceList(parameterList);
+
+ if (relatedInstanceList !== undefined) {
+ requestDetails.relatedInstanceList = relatedInstanceList;
+ }
+
+ return requestDetails;
+ };
+
+ var getRelatedInstanceList = function(parameterList) {
+ var relatedInstanceList = new Array();
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ return undefined;
+ case COMPONENT.NETWORK:
+ case COMPONENT.VNF:
+ addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
+ DataService.getServiceInstanceId());
+ break;
+ case COMPONENT.VF_MODULE:
+ addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
+ DataService.getServiceInstanceId());
+ addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
+ .getVnfInstanceId());
+
+ var availableVolumeGroup = getValueFromList(
+ FIELD.ID.AVAILABLE_VOLUME_GROUP, parameterList);
+
+ if (UtilityService.hasContents(availableVolumeGroup) && availableVolumeGroup !== "None") {
+ var availableVolumeGroups = DataService.getAvailableVolumeGroupList();
+
+ for (var i = 0; i < availableVolumeGroups.length; i++) {
+ if (availableVolumeGroups[i].instance.name == availableVolumeGroup) {
+ DataService.setModelInfo(COMPONENT.VOLUME_GROUP, DataService.getModelInfo(COMPONENT.VF_MODULE));
+ DataService.setVolumeGroupInstanceId(availableVolumeGroups[i].instance.object["volume-group-id"]);
+ break;
+ }
+ }
+
+ addRelatedInstance(relatedInstanceList, COMPONENT.VOLUME_GROUP,
+ DataService.getVolumeGroupInstanceId());
+ }
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
+ DataService.getServiceInstanceId());
+ addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
+ .getVnfInstanceId());
+ break;
+ }
+
+ return relatedInstanceList;
+ };
+
+ var addRelatedInstance = function(relatedInstanceList, componentId,
+ instanceId) {
+ var modelInfo = DataService.getModelInfo(componentId);
+ var relatedInstance;
+ if (modelInfo !== undefined) {
+ if (componentId === COMPONENT.SERVICE) {
+ relatedInstance = {
+ "instanceId" : instanceId,
+ "modelInfo" : {
+ "modelType" : componentId,
+ "modelName" : modelInfo.modelName,
+ "modelInvariantId" : modelInfo.modelInvariantId,
+ "modelVersion" : modelInfo.modelVersion,
+ "modelVersionId" : modelInfo.modelNameVersionId,
+
+ }
+ };
+ }
+ else {
+ relatedInstance = {
+ "instanceId" : instanceId,
+ "modelInfo" : {
+ "modelType" : componentId,
+ "modelName" : modelInfo.modelName,
+ "modelInvariantId" : modelInfo.modelInvariantId,
+ "modelVersion" : modelInfo.modelVersion,
+ "modelVersionId" : modelInfo.modelNameVersionId,
+ "modelCustomizationId": modelInfo.customizationUuid,
+ "modelCustomizationName": modelInfo.modelCustomizationName
+ }
+ }
+ }
+ relatedInstanceList.push({
+ relatedInstance : relatedInstance
+ });
+ }
+ };
+
+ /*
+ * var getArbitraryParameters = function(parameterList) { var
+ * arbitraryParameters = new Object(); for (var i = 0; i <
+ * parameterList.length; i++) { var parameter = parameterList[i]; switch
+ * (parameter.id) { case FIELD.ID.INSTANCE_NAME: case
+ * FIELD.ID.PRODUCT_FAMILY: case FIELD.ID.LCP_REGION: case
+ * FIELD.ID.LCP_REGION_TEXT: case FIELD.ID.SERVICE_TYPE: case
+ * FIELD.ID.TENANT: case FIELD.ID.SUPPRESS_ROLLBACK: break; default:
+ * arbitraryParameters[parameter.id] = parameter.value; } } return
+ * arbitraryParameters; }
+ */
+ var getArbitraryParameters = function(parameterList) {
+ var arbitraryParameters = new Object();
+ var arbitraryArray = new Array();
+ for (var i = 0; i < parameterList.length; i++) {
+ var parameter = parameterList[i];
+ switch (parameter.id) {
+ case FIELD.ID.AVAILABLE_VOLUME_GROUP:
+ break;
+ case FIELD.ID.INSTANCE_NAME:
+ break;
+ case FIELD.ID.PRODUCT_FAMILY:
+ break;
+ case FIELD.ID.LCP_REGION:
+ break;
+ case FIELD.ID.LCP_REGION_TEXT:
+ break;
+ case FIELD.ID.SERVICE_TYPE:
+ break;
+ case FIELD.ID.TENANT:
+ break;
+ case FIELD.ID.SUPPRESS_ROLLBACK:
+ break;
+ case FIELD.ID.SUBSCRIBER_NAME:
+ break;
+ default:
+ arbitraryParameters = {
+ name : parameter.id,
+ value : parameter.value
+ }
+ arbitraryArray.push(arbitraryParameters);
+ }
+ }
+ return (arbitraryArray);
+ }
+
+ var getModel = function() {
+ AsdcService.getModel(DataService.getModelId(), function(response) {
+ DataService.setModelInfo(_this.componentId, {
+ modelInvariantId : response.data.invariantUUID,
+ modelNameVersionId : response.data.uuid,
+ modelName : response.data.name,
+ modelVersion : response.data.version,
+ inputs : response.data.inputs
+ });
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getSubscriptionServiceTypeList = function() {
+ AaiService.getSubscriptionServiceTypeList(DataService
+ .getGlobalCustomerId(), function(response) {
+ DataService.setSubscriptionServiceTypeList(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getLoggedInUserID = function() {
+ AaiService.getLoggedInUserID(function(response) {
+ DataService.setLoggedInUserId(response.data);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getSubscribers = function() {
+ AaiService.getSubscribers(function(response) {
+ DataService.setSubscribers(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+ var getServices = function() {
+ AaiService.getServices(function(response) {
+ 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] };
+ serviceIdList.push(newVal);
+ DataService.setServiceIdList(serviceIdList);
+ });
+ });
+
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+ var getLcpCloudRegionTenantList = function() {
+ AaiService.getLcpCloudRegionTenantList(DataService
+ .getGlobalCustomerId(), DataService.getServiceType(), function(
+ response) {
+ DataService.setCloudRegionTenantList(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var internalGetParametersHandler = function() {
+ if (angular.isFunction(_this.getParametersHandler)) {
+ _this.getParametersHandler({
+ summaryList : getSummaryList(),
+ userProvidedList : getUserProvidedList()
+ });
+ }
+ };
+
+ var getSubscribersParameter = function() {
+ var subscribers = DataService.getSubscribers();
+ var parameter = FIELD.PARAMETER.SUBSCRIBER_NAME;
+ if ( UtilityService.hasContents(subscribers)) {
+ parameter.optionList = [];
+
+ for (var i = 0; i < subscribers.length; i++) {
+ parameter.optionList.push({
+ id : subscribers[i][FIELD.ID.GLOBAL_CUSTOMER_ID],
+ name : subscribers[i][FIELD.ID.SUBNAME]
+ })
+ }
+ }
+ return parameter;
+ };
+
+ var getServiceId = function() {
+ var serviceIdList = DataService.getServiceIdList();
+ var serviceTypeList = DataService.getSubscriptionServiceTypeList();
+ var parameter = FIELD.PARAMETER.PRODUCT_FAMILY;
+ parameter.optionList = new Array();
+
+ if (serviceTypeList == null) {
+ getSubscriptionServiceTypeList();
+ serviceTypeList = DataService.getSubscriptionServiceTypeList();
+ }
+ var went = 0;
+ if ( UtilityService.hasContents (serviceIdList) ) {
+ for (var i = 0; i < serviceIdList.length; i++) {
+ var go = 0;
+ var name = serviceIdList[i].id;
+
+ if (UtilityService.hasContents(serviceTypeList) ) {
+ console.log("STL: " + serviceTypeList);
+ for (var k = 0; k < serviceTypeList.length; k++) {
+ if (angular.equals(name,serviceTypeList[k])) {
+ go = 1;
+ went = 1;
+ }
+ }
+ } else {
+ go = 1;
+ went = 1;
+ }
+ if (go == 1) {
+ parameter.optionList.push({
+ id : serviceIdList[i].id,
+ name : serviceIdList[i].description
+ });
+ }
+ } // load them all, ours wasn't in the list
+ if (went == 0) {
+ for (var i = 0; i < serviceIdList.length; i++) {
+ parameter.optionList.push({
+ id : serviceIdList[i].id,
+ name : serviceIdList[i].description
+ });
+ }
+ }
+ }
+ return parameter;
+ };
+
+ var getLcpRegion = function() {
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ var parameter = FIELD.PARAMETER.LCP_REGION;
+ if ( UtilityService.hasContents (cloudRegionTenantList) ) {
+ parameter.optionList = new Array();
+ for (var i = 0; i < cloudRegionTenantList.length; i++) {
+ for (var j = 0; j < parameter.optionList.length; j++) {
+ if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) {
+ break;
+ }
+ }
+ if (j < parameter.optionList.length) {
+ continue;
+ }
+ parameter.optionList.push({
+ id : cloudRegionTenantList[i].cloudRegionId
+ });
+ }
+ }
+ return parameter;
+ };
+
+ var getTenantList = function(cloudRegionId) {
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ var parameter = "";
+ if ( UtilityService.hasContents (cloudRegionTenantList) ) {
+ parameter = FIELD.PARAMETER.TENANT_ENABLED;
+ parameter.optionList = new Array();
+ for (var i = 0; i < cloudRegionTenantList.length; i++) {
+ if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) {
+ parameter.optionList.push({
+ id : cloudRegionTenantList[i].tenantId,
+ name : cloudRegionTenantList[i].tenantName
+ });
+ }
+ }
+ }
+ return parameter;
+
+ };
+
+ var addOptionList = function(parameter, optionSimpleArray) {
+ var optionList = new Array();
+ if (!angular.isArray(optionSimpleArray)) {
+ return optionList;
+ }
+ for (var i = 0; i < optionSimpleArray.length; i++) {
+ optionList.push({
+ name : optionSimpleArray[i]
+ });
+ }
+ parameter.optionList = optionList;
+ return parameter;
+ };
+
+ var getValueFromList = function(id, parameterList) {
+ for (var i = 0; i < parameterList.length; i++) {
+ if (parameterList[i].id === id) {
+ return parameterList[i].value;
+ }
+ }
+ };
+ var updateUserParameterList = function(updatedId, parameterListControl) {
+ console.log ("updateUserParameterList() updatedId=" + updatedId);
+ if (updatedId === FIELD.ID.LCP_REGION) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+ parameterListControl
+ .updateList([ getTenantList(list[0].value) ]);
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ if (list[0].value === FIELD.KEY.LCP_REGION_TEXT) {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_VISIBLE ]);
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN ]);
+ }
+ } else if (updatedId === FIELD.ID.SUBSCRIBER_NAME) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+ DataService.setGlobalCustomerId(list[0].value);
+
+ AaiService.getSubscriptionServiceTypeList(DataService
+ .getGlobalCustomerId(), function(response) {
+ DataService.setSubscriptionServiceTypeList(response);
+ var serviceTypeParameters = FIELD.PARAMETER.SERVICE_TYPE;
+ serviceTypeParameters.optionList = [];
+
+ for (var i = 0; i < response.length; i++) {
+ serviceTypeParameters.optionList.push({
+ "id" : response[i],
+ "name" : response[i]
+ });
+ }
+ console.log ( "updateUserParameterList: service type parameters " );
+ console.log ( JSON.stringify (serviceTypeParameters, null, 4));
+ parameterListControl.updateList([ serviceTypeParameters ]);
+ });
+
+ }
+ } else if ( updatedId === FIELD.ID.SERVICE_TYPE ) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+
+ DataService.setServiceType(list[0].value);
+ var cloudRegionTenantList = new Array();
+ AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) {
+ DataService.setCloudRegionTenantList(cloudRegionTenantList);
+ parameterListControl.updateList([ getLcpRegion() ]);
+ });
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
+ }
+ }
+
+ };
+
+ return {
+ initializeComponent : function(componentId) {
+ _this.componentId = ComponentService.initialize(componentId);
+ },
+ setHttpErrorHandler : function(httpErrorHandler) {
+ _this.httpErrorHandler = httpErrorHandler;
+ },
+ getComponentDisplayName : ComponentService.getComponentDisplayName,
+ getParameters : function(getParametersHandler) {
+ _this.getParametersHandler = getParametersHandler;
+ UtilityService.setHttpErrorHandler(_this.httpErrorHandler);
+ UtilityService.startAsyncOperations(getAsyncOperationList(),
+ internalGetParametersHandler);
+ },
+ updateUserParameterList : updateUserParameterList,
+ getMsoRequestDetails : getMsoRequestDetails,
+ getMsoUrl : getMsoUrl
+ }
+}
+
+appDS2.factory("CreationService", [ "$log", "AaiService", "AsdcService",
+ "DataService", "ComponentService", "COMPONENT", "FIELD", "PARAMETER",
+ "UtilityService", CreationService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js
new file mode 100755
index 000000000..7d913fafb
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js
@@ -0,0 +1,243 @@
+/*-
+ * ============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 DataService = function($log, DataService) {
+
+ var _this = this;
+
+ return {
+ getAvailableVolumeGroupList : function() {
+ return _this.availableVolumeGroupList;
+ },
+ setAvailableVolumeGroupList : function(availableVolumeGroupList) {
+ _this.availableVolumeGroupList = availableVolumeGroupList;
+ },
+ getCloudRegionTenantList : function() {
+ return _this.cloudRegionTenantList;
+ },
+ setCloudRegionTenantList : function(cloudRegionTenantList) {
+ _this.cloudRegionTenantList = cloudRegionTenantList;
+ },
+ getGlobalCustomerId : function() {
+ return _this.globalCustomerId;
+ },
+ setGlobalCustomerId : function(globalCustomerId) {
+ _this.globalCustomerId = globalCustomerId;
+ },
+ getCustomizationUuid : function() {
+ return _this.customizationUUID;
+ },
+ setCustomizationUuid : function(customizationUUID) {
+ _this.customizationUUID = customizationUUID;
+ },
+ getResCustomizationUuid : function() {
+ return _this.rescustomizationUUID;
+ },
+ setResCustomizationUuid : function(rescustomizationUUID) {
+ _this.rescustomizationUUID = rescustomizationUUID;
+ },
+ getInventoryItem : function() {
+ return _this.inventoryItem;
+ },
+ setInventoryItem : function(inventoryItem) {
+ _this.inventoryItem = inventoryItem;
+ },
+ getModelId : function() {
+ return _this.modelId;
+ },
+ setModelId : function(modelId) {
+ _this.modelId = modelId;
+ },
+ getModelInstanceName : function() {
+ return _this.modelInstanceName;
+ },
+ setModelInstanceName : function(modelInstanceName) {
+ _this.modelInstanceName = modelInstanceName;
+ },
+ getModelInfo : function(componentId) {
+ return _this.modelInfo[componentId];
+ },
+ setModelInfo : function(componentId, modelInfo) {
+ if (_this.modelInfo === undefined) {
+ _this.modelInfo = new Object;
+ }
+ _this.modelInfo[componentId] = modelInfo;
+ },
+ getNetworkInstanceId : function() {
+ return _this.networkInstanceId;
+ },
+ setNetworkInstanceId : function(networkInstanceId) {
+ _this.networkInstanceId = networkInstanceId;
+ },
+ getServiceIdList : function() {
+ return _this.serviceIdList;
+ },
+ setServiceIdList : function(serviceIdList) {
+ _this.serviceIdList = serviceIdList;
+ },
+ getServiceInstanceId : function() {
+ return _this.serviceInstanceId;
+ },
+ setServiceInstanceId : function(serviceInstanceId) {
+ _this.serviceInstanceId = serviceInstanceId;
+ },
+ getServiceInstanceName : function() {
+ return _this.serviceInstanceName;
+ },
+ setServiceInstanceName : function(serviceInstanceName) {
+ _this.serviceInstanceName = serviceInstanceName;
+ },
+ getServiceName : function() {
+ return _this.serviceName;
+ },
+ setServiceName : function(serviceName) {
+ _this.serviceName = serviceName;
+ },
+ getServiceType : function() {
+ return _this.serviceType;
+ },
+ setServiceType : function(serviceType) {
+ _this.serviceType = serviceType;
+ },
+ getServiceUuid : function() {
+ return _this.serviceUuid;
+ },
+ setServiceUuid : function(serviceUuid) {
+ _this.serviceUuid = serviceUuid;
+ },
+ getSubscriberId : function() {
+ return _this.subscriberId;
+ },
+ setSubscriberId : function(subscriberId) {
+ _this.subscriberId = subscriberId;
+ },
+ getLoggedInUserId : function() {
+ return _this.loggedInUserId;
+ },
+ setLoggedInUserId : function(loggedInUserId) {
+ _this.loggedInUserId = loggedInUserId;
+ },
+ getSubscriberName : function() {
+ return _this.subscriberName;
+ },
+ setSubscriberName : function(subscriberName) {
+ _this.subscriberName = subscriberName;
+ },
+ getSubscribers : function() {
+ return _this.subscribers;
+ },
+ setSubscribers : function(subscribers) {
+ _this.subscribers = subscribers;
+ },
+ getSubscriptionServiceTypeList : function() {
+ return _this.subscriptionServiceTypeList;
+ },
+ setSubscriptionServiceTypeList : function(subscriptionServiceTypeList) {
+ _this.subscriptionServiceTypeList = subscriptionServiceTypeList;
+ },
+ getUserParams : function() {
+ return _this.userParams;
+ },
+ setUserParams : function(userParams) {
+ _this.userParams = userParams;
+ },
+ getUserServiceInstanceName : function() {
+ return _this.userServiceInstanceName;
+ },
+ setUserServiceInstanceName : function(userServiceInstanceName) {
+ _this.userServiceInstanceName = userServiceInstanceName;
+ },
+ getVfModuleInstanceId : function() {
+ return _this.vfModuleInstanceId;
+ },
+ setVfModuleInstanceId : function(vfModuleInstanceId) {
+ _this.vfModuleInstanceId = vfModuleInstanceId;
+ },
+ getVnfInstanceId : function() {
+ return _this.vnfInstanceId;
+ },
+ setVnfInstanceId : function(vnfInstanceId) {
+ _this.vnfInstanceId = vnfInstanceId;
+ },
+ getVolumeGroupInstanceId : function() {
+ return _this.volumeGroupInstanceId;
+ },
+ setVolumeGroupInstanceId : function(volumeGroupInstanceId) {
+ _this.volumeGroupInstanceId = volumeGroupInstanceId;
+ },
+ getLcpRegion : function() {
+ return _this.lcpRegion;
+ },
+ setLcpRegion : function(lcpRegion) {
+ _this.lcpRegion = lcpRegion;
+ },
+ getTenant : function() {
+ return _this.tenant;
+ },
+ setTenant : function(tenant) {
+ _this.tenant = tenant;
+ },
+ getTreeHandle : function() {
+ return _this.treeHandle;
+ },
+ setTreeHandle : function(treeHandle) {
+ _this.treeHandle = treeHandle;
+ },
+ setServiceInstanceToCustomer : function(serviceInstanceToCustomer) {
+ _this.serviceInstanceToCustomer = [];
+ _this.serviceInstanceToCustomer = serviceInstanceToCustomer;
+ },
+ getServiceInstanceToCustomer : function() {
+ return _this.serviceInstanceToCustomer;
+ },
+ setALaCarte : function(aval) {
+ _this.aLaCarte = aval;
+ },
+ getALaCarte : function() {
+ // if not set return true
+ if (_this.aLaCarte === undefined) {
+ return true;
+ }
+ return _this.aLaCarte;
+ },
+ getResources : function() {
+ return _this.resources;
+ },
+ setResources : function(r) {
+ _this.resources = r;
+ },
+ getSystemPropProvStatus : function() {
+ return _this.syspropProvStatusList;
+ },
+ setSystemPropProvStatus : function(r) {
+ _this.syspropProvStatusList = r;
+ },
+ getUpdatedVNFProvStatus : function() {
+ return _this.updatedvnfProvStatus;
+ },
+ setUpdatedVNFProvStatus : function(r) {
+ _this.updatedvnfProvStatus = r;
+ }
+ }
+}
+
+appDS2.factory("DataService", [ "$log", DataService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js
new file mode 100755
index 000000000..62c2b19cb
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/deletionService.js
@@ -0,0 +1,502 @@
+/*-
+ * ============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 DeletionService = function($log, AaiService, AsdcService, DataService,
+ ComponentService, COMPONENT, FIELD, UtilityService) {
+
+ var _this = this;
+
+ var getAsyncOperationList = function() {
+ if (DataService.getLoggedInUserId() == null)
+ getLoggedInUserID();
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ return [ getSubscribers, getLcpCloudRegionTenantList ];
+ case COMPONENT.NETWORK:
+ return [ getLcpCloudRegionTenantList ];
+ case COMPONENT.VNF:
+ return [ getLcpCloudRegionTenantList ];
+ case COMPONENT.VF_MODULE:
+ return [ getLcpCloudRegionTenantList ];
+ case COMPONENT.VOLUME_GROUP:
+ return [ getLcpCloudRegionTenantList ];
+ }
+ };
+
+ var getLcpCloudRegionTenantList = function() {
+ //console.log ( "global customer id: " );
+ //console.log ( JSON.stringify (DataService.getGlobalCustomerId()) );
+
+ //console.log ( "service type: " );
+ //console.log ( JSON.stringify (DataService.getServiceType()) );
+
+ AaiService.getLcpCloudRegionTenantList(DataService
+ .getGlobalCustomerId(), DataService.getServiceType(), function(
+ response) {
+ DataService.setCloudRegionTenantList(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getLoggedInUserID = function() {
+ AaiService.getLoggedInUserID(function(response) {
+ DataService.setLoggedInUserId(response.data);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getSubscribers = function() {
+ AaiService.getSubscribers(function(response) {
+ DataService.setSubscribers(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var internalGetParametersHandler = function() {
+ if (angular.isFunction(_this.getParametersHandler)) {
+ if (_this.componentId == COMPONENT.SERVICE) {
+ if ( DataService.getALaCarte() ) {
+ _this.getParametersHandler({
+ summaryList : getSummaryList(),
+ userProvidedList : getUserProvidedList()
+ }, true);
+ }
+ else {
+ _this.getParametersHandler({
+ summaryList : getSummaryList(),
+ userProvidedList : getUserProvidedList()
+ }, false);
+ }
+ }
+ else {
+ _this.getParametersHandler({
+ summaryList : getSummaryList(),
+ userProvidedList : getUserProvidedList()
+ }, false);
+ }
+ }
+ };
+
+ var getSubscribersParameter = function() {
+ var subscribers = DataService.getSubscribers();
+ var parameter = FIELD.PARAMETER.SUBSCRIBER_NAME;
+ parameter.optionList = [];
+
+ for (var i = 0; i < subscribers.length; i++) {
+ parameter.optionList.push({
+ id : subscribers[i][FIELD.ID.GLOBAL_CUSTOMER_ID],
+ name : subscribers[i][FIELD.ID.SUBNAME]
+ })
+ }
+ return parameter;
+ };
+
+ var getServiceId = function() {
+ var serviceIdList = DataService.getServiceIdList();
+ var parameter = FIELD.PARAMETER.PRODUCT_FAMILY;
+ parameter.optionList = new Array();
+ for (var i = 0; i < serviceIdList.length; i++) {
+ parameter.optionList.push({
+ id : serviceIdList[i].id,
+ name : serviceIdList[i].description
+ });
+ }
+ return parameter;
+ };
+
+ var getUserProvidedList = function() {
+
+ //var parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
+
+ var parameterList = [];
+
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ if ( DataService.getALaCarte() ) {
+ parameterList = [];
+ }
+ else {
+ parameterList = parameterList.concat ([getLcpRegion(),
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ break;
+ case COMPONENT.NETWORK:
+ case COMPONENT.VNF:
+ parameterList = parameterList.concat([ //getServiceId(),
+ getLcpRegion(), FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ break;
+ case COMPONENT.VF_MODULE:
+ parameterList = parameterList.concat([
+ getLcpRegion(),
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED
+ ]);
+
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ parameterList = parameterList.concat([ getLcpRegion(),
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+
+ //parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK);
+
+ //addArbitraryParameters(parameterList);
+
+ return parameterList;
+ };
+ var getSummaryList = function() {
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ case COMPONENT.SERVICE:
+ case COMPONENT.VNF:
+ case COMPONENT.VF_MODULE:
+ case COMPONENT.VOLUME_GROUP:
+ var summaryList = [ {
+ name : FIELD.NAME.SUBSCRIBER_NAME,
+ value : DataService.getSubscriberName()
+ }, {
+ name : FIELD.NAME.CUSTOMER_ID,
+ value : DataService.getGlobalCustomerId()
+ }, {
+ name : FIELD.NAME.SERVICE_UUID,
+ value : DataService.getServiceUuid()
+ }, {
+ name : FIELD.NAME.SERVICE_NAME,
+ value : DataService.getServiceName()
+ /* }, {
+ name : FIELD.NAME.USER_SERVICE_INSTANCE_NAME,
+ value : DataService.getUserServiceInstanceName()*/
+ } ];
+
+ _this.parameterList = new Array();
+
+ addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
+
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ addToList(FIELD.NAME.SERVICE_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.SERVICE_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.SERVICE_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.SERVICE_DESCRIPTION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.DESCRIPTION]);
+ addToList(FIELD.NAME.SERVICE_CATEGORY, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CATEGORY]);
+ break;
+ case COMPONENT.VF_MODULE:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ break;
+ case COMPONENT.NETWORK:
+ case COMPONENT.VNF:
+ case COMPONENT.VOLUME_GROUP:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ break;
+ }
+
+ /*var additionalList = ComponentService.getInventoryParameterList(
+ _this.componentId, DataService.getInventoryItem());*/
+ var additionalList = ComponentService.getDisplayNames(ComponentService
+ .getInventoryParameterList(_this.componentId, DataService
+ .getInventoryItem(), true ));
+
+ return summaryList.concat(ComponentService
+ .getDisplayNames(additionalList));
+ }
+ };
+
+ var getMsoUrl = function() {
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ return "mso_delete_nw_instance/"
+ + DataService.getServiceInstanceId() + "/networks/"
+ + DataService.getNetworkInstanceId();
+ case COMPONENT.SERVICE:
+ return "mso_delete_svc_instance/"
+ + DataService.getServiceInstanceId();
+ case COMPONENT.VNF:
+ return "mso_delete_vnf_instance/"
+ + DataService.getServiceInstanceId() + "/vnfs/"
+ + DataService.getVnfInstanceId();
+ case COMPONENT.VF_MODULE:
+ return "mso_delete_vfmodule_instance/"
+ + DataService.getServiceInstanceId() + "/vnfs/"
+ + DataService.getVnfInstanceId() + "/vfModules/"
+ + DataService.getVfModuleInstanceId();
+ case COMPONENT.VOLUME_GROUP:
+ return "mso_delete_volumegroup_instance/"
+ + DataService.getServiceInstanceId() + "/vnfs/"
+ + DataService.getVnfInstanceId() + "/volumeGroups/"
+ + DataService.getVolumeGroupInstanceId();
+ }
+ }
+
+ var addToList = function(name, value) {
+ _this.parameterList.push({
+ name : name,
+ value : value
+ });
+ };
+
+ var getMsoRequestDetails = function(parameterList) {
+ console.log("getMsoRequestDetails invoked");
+ var inventoryInfo = ComponentService.getInventoryInfo(
+ _this.componentId, DataService.getInventoryItem());
+ var modelInfo = DataService.getModelInfo(_this.componentId);
+ var requestorloggedInId = DataService.getLoggedInUserId();
+ if (requestorloggedInId == null)
+ requestorloggedInId = "";
+ var requestDetails = {
+ modelInfo : {
+ modelType : _this.componentId,
+ modelInvariantId : modelInfo.modelInvariantId,
+ modelVersionId : modelInfo.modelNameVersionId,
+ modelName : modelInfo.modelName,
+ modelCustomizationName : modelInfo.modelCustomizationName,
+ modelCustomizationId : modelInfo.customizationUuid,
+ modelVersion : modelInfo.modelVersion
+ },
+ requestInfo : {
+ source : FIELD.ID.VID,
+ requestorId: requestorloggedInId
+ }
+ };
+
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ requestDetails.requestParameters = {
+ aLaCarte : DataService.getALaCarte()
+ };
+ if ( !(DataService.getALaCarte()) ) {
+ // for macro delete include cloud config.
+ var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+ if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ }
+ requestDetails.cloudConfiguration = {
+ lcpCloudRegionId : lcpRegion,
+ tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+ }
+ break;
+ case COMPONENT.VNF:
+ console.log("getMsoRequestDetails COMPONENT.VNF");
+ var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+ if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ }
+ requestDetails.cloudConfiguration = {
+ lcpCloudRegionId : lcpRegion,
+ tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+
+ break;
+ case COMPONENT.VF_MODULE:
+ case COMPONENT.NETWORK:
+ var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+ if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ }
+ requestDetails.cloudConfiguration = {
+ lcpCloudRegionId : lcpRegion,
+ tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+ if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ }
+ requestDetails.cloudConfiguration = {
+ lcpCloudRegionId : lcpRegion,
+ tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+
+ break;
+ default:
+ requestDetails.cloudConfiguration = {
+ lcpCloudRegionId : DataService.getLcpRegion(),
+ tenantId : DataService.getTenant()
+ };
+ }
+ return requestDetails;
+ }
+
+ var getLcpRegion = function() {
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ var parameter = "";
+ if ( UtilityService.hasContents (cloudRegionTenantList) ) {
+ parameter = FIELD.PARAMETER.LCP_REGION;
+ parameter.optionList = new Array();
+ for (var i = 0; i < cloudRegionTenantList.length; i++) {
+ for (var j = 0; j < parameter.optionList.length; j++) {
+ if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) {
+ break;
+ }
+ }
+ if (j < parameter.optionList.length) {
+ continue;
+ }
+ parameter.optionList.push({
+ id : cloudRegionTenantList[i].cloudRegionId
+ });
+ }
+ }
+ return parameter;
+ };
+
+ var getTenantList = function(cloudRegionId) {
+ var parameter = "";
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ if ( UtilityService.hasContents (cloudRegionTenantList) ) {
+ var parameter = FIELD.PARAMETER.TENANT_ENABLED;
+ parameter.optionList = new Array();
+ for (var i = 0; i < cloudRegionTenantList.length; i++) {
+ if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) {
+ parameter.optionList.push({
+ id : cloudRegionTenantList[i].tenantId,
+ name : cloudRegionTenantList[i].tenantName
+ });
+ }
+ }
+ }
+ return parameter;
+
+ };
+
+ var addOptionList = function(parameter, optionSimpleArray) {
+ var optionList = new Array();
+ if (!angular.isArray(optionSimpleArray)) {
+ return optionList;
+ }
+ for (var i = 0; i < optionSimpleArray.length; i++) {
+ optionList.push({
+ name : optionSimpleArray[i]
+ });
+ }
+ parameter.optionList = optionList;
+ return parameter;
+ };
+
+ var getValueFromList = function(id, parameterList) {
+ for (var i = 0; i < parameterList.length; i++) {
+ if (parameterList[i].id === id) {
+ return parameterList[i].value;
+ }
+ }
+ };
+
+ var updateUserParameterList = function(updatedId, parameterListControl) {
+ if (updatedId === FIELD.ID.LCP_REGION) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+ parameterListControl
+ .updateList([ getTenantList(list[0].value) ]);
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ if (list[0].value === FIELD.KEY.LCP_REGION_TEXT) {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_VISIBLE ]);
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN ]);
+ }
+ } else if (updatedId === FIELD.ID.SUBSCRIBER_NAME) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+ DataService.setGlobalCustomerId(list[0].value);
+
+ AaiService.getSubscriptionServiceTypeList(DataService
+ .getGlobalCustomerId(), function(response) {
+ DataService.setSubscriptionServiceTypeList(response);
+ var serviceTypeParameters = FIELD.PARAMETER.SERVICE_TYPE;
+ serviceTypeParameters.optionList = [];
+
+ for (var i = 0; i < response.length; i++) {
+ serviceTypeParameters.optionList.push({
+ "id" : response[i],
+ "name" : response[i]
+ });
+ }
+ parameterListControl.updateList([ serviceTypeParameters ]);
+ });
+
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
+ }
+ }
+ };
+
+ return {
+ initializeComponent : function(componentId) {
+ _this.componentId = ComponentService.initialize(componentId);
+ },
+ getComponentDisplayName : ComponentService.getComponentDisplayName,
+ getSummaryList : getSummaryList,
+ getParameters : function(getParametersHandler) {
+ _this.getParametersHandler = getParametersHandler;
+ UtilityService.setHttpErrorHandler(_this.httpErrorHandler);
+ UtilityService.startAsyncOperations(getAsyncOperationList(),
+ internalGetParametersHandler);
+ },
+ updateUserParameterList : updateUserParameterList,
+ getMsoRequestDetails : getMsoRequestDetails,
+ getMsoUrl : getMsoUrl
+ }
+}
+
+appDS2.factory("DeletionService", [ "$log", "AaiService", "AsdcService",
+ "DataService", "ComponentService", "COMPONENT", "FIELD",
+ "UtilityService", DeletionService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/detailsService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/detailsService.js
new file mode 100755
index 000000000..37220ffd1
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/detailsService.js
@@ -0,0 +1,98 @@
+/*-
+ * ============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 DetailsService = function($log, DataService, ComponentService, COMPONENT,
+ FIELD, UtilityService) {
+
+ var _this = this;
+
+ var getSummaryList = function() {
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ case COMPONENT.SERVICE:
+ case COMPONENT.VNF:
+ case COMPONENT.VF_MODULE:
+ case COMPONENT.VOLUME_GROUP:
+ return [ {
+ name : FIELD.NAME.SUBSCRIBER_NAME,
+ value : DataService.getSubscriberName()
+ }, {
+ name : FIELD.NAME.SERVICE_INSTANCE_ID,
+ value : DataService.getServiceInstanceId()
+ }, {
+ name : FIELD.NAME.SERVICE_TYPE,
+ value : DataService.getServiceType()
+ } ];
+ }
+ };
+
+ var getDetailsList = function() {
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ case COMPONENT.SERVICE:
+ case COMPONENT.VNF:
+ case COMPONENT.VF_MODULE:
+ case COMPONENT.VOLUME_GROUP:
+ return ComponentService.getDisplayNames(ComponentService
+ .getInventoryParameterList(_this.componentId, DataService
+ .getInventoryItem(), false));
+ }
+ };
+
+ var getMsoFilterString = function() {
+
+ var instanceId = "";
+
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ instanceId = DataService.getNetworkInstanceId();
+ break;
+ case COMPONENT.SERVICE:
+ instanceId = DataService.getServiceInstanceId();
+ break;
+ case COMPONENT.VNF:
+ instanceId = DataService.getVnfInstanceId();
+ break;
+ case COMPONENT.VF_MODULE:
+ instanceId = DataService.getVfModuleInstanceId();
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ instanceId = DataService.getVolumeGroupInstanceId();
+ }
+
+ return "filter=" + _this.componentId + "InstanceId:EQUALS:"
+ + instanceId;
+ };
+
+ return {
+ initializeComponent : function(componentId) {
+ _this.componentId = ComponentService.initialize(componentId);
+ },
+ getComponentDisplayName : ComponentService.getComponentDisplayName,
+ getSummaryList : getSummaryList,
+ getDetailsList : getDetailsList,
+ getMsoFilterString : getMsoFilterString
+ }
+}
+
+appDS2.factory("DetailsService", [ "$log", "DataService", "ComponentService",
+ "COMPONENT", "FIELD", "UtilityService", DetailsService ]);
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
new file mode 100755
index 000000000..864abe67d
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/msoService.js
@@ -0,0 +1,175 @@
+/*-
+ * ============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 MsoService = function($http, $log, PropertyService, UtilityService, COMPONENT, FIELD) {
+
+ 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);
+ }
+ }
+ }
+}
+
+appDS2.factory("MsoService", [ "$http", "$log", "PropertyService",
+ "UtilityService", "COMPONENT", "FIELD", MsoService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/propertyService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/propertyService.js
new file mode 100755
index 000000000..ad9bf7dfa
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/propertyService.js
@@ -0,0 +1,89 @@
+/*-
+ * ============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 PropertyService = function($location, $http, VIDCONFIGURATION ) {
+
+ var RE = /.*?:\/\/.*?:.*?\/(.*?)\//g;
+ var BASE_PATH = "vid";
+ var DEFAULT_AAI_BASE_URL = "/" + BASE_PATH;
+ var DEFAULT_ASDC_BASE_URL = "asdc";
+ var DEFAULT_MSO_MAX_POLLING_INTERVAL_MSEC = 60000;
+ var DEFAULT_MSO_MAX_POLLS = 10;
+ var DEFAULT_MSO_BASE_URL = "/" + BASE_PATH + "/mso";
+ var DEFAULT_SERVER_RESPONSE_TIMEOUT_MSEC = 60000;
+ var MSO_POLLING_INTERVAL_MSECS = "mso_polling_interval_msecs";
+ var MSO_MAX_POLLS = "mso_max_polls";
+
+ var _this = this;
+
+ _this.asdcBaseUrl = DEFAULT_ASDC_BASE_URL;
+ _this.aaiBaseUrl = DEFAULT_AAI_BASE_URL;
+ _this.msoMaxPollingIntervalMsec = DEFAULT_MSO_MAX_POLLING_INTERVAL_MSEC;
+ _this.msoMaxPolls = DEFAULT_MSO_MAX_POLLS;
+ _this.msoBaseUrl = DEFAULT_MSO_BASE_URL;
+ _this.serverResponseTimeoutMsec = DEFAULT_SERVER_RESPONSE_TIMEOUT_MSEC;
+
+ return {
+
+ setAaiBaseUrl : function(aaiBaseUrl) {
+ _this.aaiBaseUrl = aaiBaseUrl;
+ },
+
+ setAsdcBaseUrl : function(asdcBaseUrl) {
+ _this.asdcBaseUrl = asdcBaseUrl;
+ },
+ retrieveMsoMaxPollingIntervalMsec : function() {
+ _this.msoMaxPollingIntervalMsec = VIDCONFIGURATION.MSO_POLLING_INTERVAL_MSECS;
+ return _this.msoMaxPollingIntervalMsec;
+ },
+ getMsoMaxPollingIntervalMsec : function() {
+ return _this.msoMaxPollingIntervalMsec;
+ },
+ setMsoMaxPollingIntervalMsec : function(msoMaxPollingIntervalMsec) {
+ _this.msoMaxPollingIntervalMsec = msoMaxPollingIntervalMsec;
+ },
+ retrieveMsoMaxPolls : function() {
+ _this.msoMaxPolls = VIDCONFIGURATION.MSO_MAX_POLLS;
+ return _this.msoMaxPolls;
+ },
+ getMsoMaxPolls : function() {
+ return _this.msoMaxPolls;
+ },
+ setMsoMaxPolls : function(msoMaxPolls) {
+ _this.msoMaxPolls = msoMaxPolls;
+ },
+ getMsoBaseUrl : function() {
+ return "mso";
+ },
+ setMsoBaseUrl : function(msoBaseUrl) {
+ _this.msoBaseUrl = msoBaseUrl;
+ },
+ getServerResponseTimeoutMsec : function() {
+ return _this.serverResponseTimeoutMsec;
+ },
+ setServerResponseTimeoutMsec : function(serverResponseTimeoutMsec) {
+ _this.serverResponseTimeoutMsec = serverResponseTimeoutMsec;
+ }
+ };
+}
+
+appDS2.factory("PropertyService", PropertyService);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/statusService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/statusService.js
new file mode 100755
index 000000000..3ed56c393
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/statusService.js
@@ -0,0 +1,185 @@
+/*-
+ * ============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 StatusService = function($log, AaiService, DataService, ComponentService, COMPONENT,
+ FIELD, PARAMETER, UtilityService) {
+
+ var _this = this;
+
+ var getAsyncOperationList = function() {
+
+ return [ getTargetProvStatus ];
+
+ };
+
+ var getSummaryList = function() {
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ case COMPONENT.SERVICE:
+ case COMPONENT.VNF:
+ case COMPONENT.VF_MODULE:
+ case COMPONENT.VOLUME_GROUP:
+ return [ {
+ name : FIELD.NAME.SUBSCRIBER_NAME,
+ value : DataService.getSubscriberName()
+ }, {
+ name : FIELD.NAME.SERVICE_INSTANCE_ID,
+ value : DataService.getServiceInstanceId()
+ }, {
+ name : FIELD.NAME.SERVICE_INSTANCE_ID,
+ value : DataService.getServiceInstanceName()
+ }, {
+ name : FIELD.NAME.SERVICE_TYPE,
+ value : DataService.getServiceType()
+ } ];
+ }
+ };
+
+ var getVNFStatusList = function() {
+ var inventoryItem = DataService.getInventoryItem();
+ var newProvStatus = DataService.getUpdatedVNFProvStatus();
+ if ( UtilityService.hasContents(newProvStatus) ) {
+
+ }
+ else
+ {
+ newProvStatus = inventoryItem['prov-status'];
+ }
+ return [ {
+ name : FIELD.NAME.VNF_VNF_ID,
+ value : inventoryItem['vnf-id']
+ }, {
+ name : FIELD.NAME.VNF_VNF_Name,
+ value : inventoryItem['vnf-name']
+ }, {
+ name : FIELD.NAME.VNF_VNF_Type,
+ value : inventoryItem['vnf-type']
+ }, {
+ name : FIELD.NAME.VNF_Service_ID,
+ value : inventoryItem['service-id']
+ }, {
+ name : FIELD.NAME.VNF_ORCHESTRATION_STATUS,
+ value :inventoryItem['orchestration-status']
+ }, {
+ name : FIELD.NAME.VNF_In_Maint,
+ value :inventoryItem['in-maint']
+ }, {
+ name : FIELD.NAME.VNF_Operational_Status,
+ value :inventoryItem['operational-state']
+ },
+ {
+ name : FIELD.NAME.VNF_Current_Prov_Status,
+ value : newProvStatus
+ }
+ ];
+ };
+
+ var internalGetParametersHandler = function() {
+ if (angular.isFunction(_this.getParametersHandler)) {
+ if (_this.componentId == COMPONENT.SERVICE)
+ _this.getParametersHandler({
+ summaryList : getSummaryList(),
+ userProvidedList : getUserProvidedList()
+ }, true);
+ else
+ _this.getParametersHandler({
+ summaryList : getSummaryList(),
+ userProvidedList : getUserProvidedList()
+ }, false);
+ }
+ };
+
+ var getTargetProvStatus = function() {
+ AaiService.getProvOptionsFromSystemProp(function(response) {
+ DataService.setSystemPropProvStatus(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getUserProvidedList = function() {
+
+ var parameterList = [];
+
+ parameterList = parameterList.concat([
+ getTargetProvParameter()]);
+
+ return parameterList;
+ };
+
+ var getTargetProvParameter = function() {
+ var provStatus = DataService.getSystemPropProvStatus();
+ var parameter = FIELD.PARAMETER.VNF_TARGET_PROVSTATUS;
+ var provArray = provStatus.data.split(",");
+ parameter.optionList = new Array();
+ for (var i = 0; i < provArray.length; i++) {
+ parameter.optionList.push({
+ id : i+1,
+ name : provArray[i]
+ });
+ }
+ return parameter;
+ };
+
+ var getTargetProvParameterText = function(index) {
+ var provStatus = DataService.getSystemPropProvStatus();
+ var parameter = FIELD.PARAMETER.VNF_TARGET_PROVSTATUS;
+ var provArray = provStatus.data.split(",");
+
+ return provArray[index-1];
+ };
+
+ var getTargetProvParameters = function() {
+ var provStatus = DataService.getSystemPropProvStatus();
+
+ };
+
+ var updateUserParameterList = function(updatedId, parameterListControl) {
+ console.log ("updateUserParameterList() updatedId=" + updatedId);
+ if (updatedId === FIELD.ID.VNF_TARGETPROVSTATUS) {
+ var list = parameterListControl.getList(updatedId);
+
+ }
+ };
+
+ return {
+ initializeComponent : function(componentId) {
+ _this.componentId = ComponentService.initialize(componentId);
+ },
+ setHttpErrorHandler : function(httpErrorHandler) {
+ _this.httpErrorHandler = httpErrorHandler;
+ },
+ getComponentDisplayName : ComponentService.getComponentDisplayName,
+ getSummaryList : getSummaryList,
+ getVNFStatusList : getVNFStatusList,
+ getParameters : function(getParametersHandler) {
+ _this.getParametersHandler = getParametersHandler;
+ UtilityService.setHttpErrorHandler(_this.httpErrorHandler);
+ UtilityService.startAsyncOperations(getAsyncOperationList(),
+ internalGetParametersHandler);
+ },
+ updateUserParameterList : updateUserParameterList,
+ getTargetProvParameterText : getTargetProvParameterText
+ }
+}
+
+appDS2.factory("StatusService", [ "$log", "AaiService", "DataService", "ComponentService",
+ "COMPONENT", "FIELD", "PARAMETER", "UtilityService", StatusService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/utilityService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/utilityService.js
new file mode 100755
index 000000000..133326943
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/utilityService.js
@@ -0,0 +1,640 @@
+/*-
+ * ============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";
+
+/*
+ * "UtilityService" contains various generic methods.
+ *
+ * (*** DEPRECATED - Use PropertyService instead ***) setProperties() and
+ * getProperties()
+ *
+ * SYNTAX: hasContents(object)
+ *
+ * Returns "true" if "object" contains contents (i.e. is NOT undefined, null or
+ * ""), "false" otherwise.
+ *
+ * SYNTAX: checkUndefined(name, value)
+ *
+ * Throws an exception if "value" is undefined. The exception includes "name" as
+ * the cause of the exception. Returns "value" if it is defined.
+ *
+ * SYNTAX: getCurrentTime()
+ *
+ * Returns the current local date and time in the format "MM/DD/YY HH:MM:SS"
+ *
+ * SYNTAX: setHttpErrorHandler(function)
+ *
+ * Sets the HTTP error handler to "function".
+ *
+ * SYNTAX: runHttpErrorHandler(response, status)
+ *
+ * Logs warning messages and the runs the HTTP error handler previously set by
+ * "setHttpErrorHandler". The intended usage is for "$http" calls. Example:
+ * $http.get(...).then(...)["catch"](UtilityService.runHttpErrorHandler);
+ *
+ * SYNTAX: getHttpStatusText(statusCode)
+ *
+ * Expects "statusCode" to be an HTTP response code (e.g. 404). The function
+ * returns a string that includes both the code and an equivalent text summary.
+ * Example: "Not found (404)"
+ *
+ * SYNTAX: getHttpErrorMessage(response)
+ *
+ * Expects "response" to be the response object generated by a "$http" error
+ * condition. "getHttpErrorMessage" examines the object and returns a summary
+ * string for some known conditions.
+ */
+
+var UtilityService = function($log, DataService) {
+
+ var _this = this;
+ var convertModel = function (serviceModel) {
+
+ var isNewFlow = false;
+
+ for (var networkCustomizationName in serviceModel.networks) {
+ var networkModel = serviceModel.networks[networkCustomizationName];
+ if ( networkModel.customizationUuid != null ) {
+ isNewFlow = true;
+ break;
+ }
+ }
+ if ( !isNewFlow ) {
+ for (var vnfCustomizationName in serviceModel.vnfs) {
+ var vnfModel = serviceModel.vnfs[vnfCustomizationName];
+ if ( vnfModel.customizationUuid != null ) {
+ isNewFlow = true;
+ break;
+ }
+ }
+ }
+ if ( isNewFlow ) {
+ return (convertNewModel (serviceModel) );
+ }
+ else {
+ return (convertOldModel (serviceModel) );
+ }
+ };
+ var convertNewModel = function (serviceModel ) {
+ var completeResources = new Array();
+ var resource = {};
+ var convertedAsdcModel = {
+ "service": serviceModel.service,
+ "networks": {},
+ "vnfs": {},
+ "completeDisplayInputs": {},
+ "isNewFlow": true
+ };
+ var networkModelDisplayInputs = {};
+ var vnfModelDisplayInputs = {};
+ for (var networkCustomizationName in serviceModel.networks) {
+ var networkModel = serviceModel.networks[networkCustomizationName];
+
+ convertedAsdcModel.networks[networkModel.customizationUuid] = {
+ "uuid": networkModel.uuid,
+ "invariantUuid": networkModel.invariantUuid,
+ "version": networkModel.version,
+ "name": networkModel.name,
+ "modelCustomizationName": networkModel.modelCustomizationName,
+ "customizationUuid": networkModel.customizationUuid,
+ "inputs": "",
+ "description": networkModel.description,
+ "commands": {},
+ "displayInputs": {}
+ }
+ resource = {
+ "name": networkModel.modelCustomizationName,
+ "description": networkModel.description
+ };
+ completeResources.push (resource);
+
+ if (networkModel.commands != null) {
+ /*
+ * commands:
+ * internal_net_param_ntu: {
+ * command: get_input,
+ * displaName: internal_net_param_ntu,
+ * inputName: vccfd1_internal_net_param_ntu // pointer to input key
+ * }
+ * If the input name (ptr) is one of instance_node_target, naming_policy or vf_instance_name
+ * then ignore it
+ *
+ */
+
+ for ( var cmd in networkModel.commands ) {
+ var cmdObj = networkModel.commands[cmd];
+ if ( cmdObj.inputName != null ) {
+ switch (cmdObj.inputName) {
+ case "instance_node_target":
+ break;
+ case "naming_policy":
+ break;
+ case "vf_instance_name":
+ break;
+ default:
+ if (serviceModel.service != null && serviceModel.service.inputs != null &&
+ serviceModel.service.inputs[cmdObj.inputName] != null ) {
+ networkModelDisplayInputs[cmdObj.inputName] = (serviceModel.service.inputs[cmdObj.inputName]);
+ }
+ }
+
+ }
+
+ }
+ convertedAsdcModel.networks[networkModel.customizationUuid].displayInputs=networkModelDisplayInputs;
+
+ }
+ }
+
+ for (var vnfCustomizationName in serviceModel.vnfs) {
+ var vnfModel = serviceModel.vnfs[vnfCustomizationName];
+ var vnfCustomizationUuid = vnfModel.customizationUuid;
+ convertedAsdcModel.vnfs[vnfModel.customizationUuid] = {
+ "uuid": vnfModel.uuid,
+ "invariantUuid": vnfModel.invariantUuid,
+ "version": vnfModel.version,
+ "name": vnfModel.name,
+ "modelCustomizationName": vnfModel.modelCustomizationName,
+ "customizationUuid": vnfModel.customizationUuid,
+ "inputs": "",
+ "description": vnfModel.description,
+ "vfModules": {},
+ "volumeGroups": {},
+ "commands": {},
+ "displayInputs": {},
+ "properties": {},
+ "nfRole": "",
+ "nfType": ""
+ }
+
+ resource = {
+ "name": vnfModel.modelCustomizationName,
+ "description": vnfModel.description
+ };
+ completeResources.push (resource);
+
+ if (vnfModel.commands != null) {
+ /*
+ * commands: {
+ * internal_net_param_ntu: {
+ * command: get_input,
+ * displaName: internal_net_param_ntu,
+ * inputName: vccfd1_internal_net_param_ntu // pointer to input key
+ * }
+ * If the input name (ptr) is one of instance_node_target, naming_policy or vf_instance_name
+ * then ignore it
+ *
+ */
+
+ for ( var cmd in vnfModel.commands ) {
+ var cmdObj = vnfModel.commands[cmd];
+ if ( cmdObj.inputName != null ) {
+ // To Do: Make this list configurable
+ switch (cmdObj.inputName) {
+ case "instance_node_target":
+ break;
+ case "naming_policy":
+ break;
+ case "vf_instance_name":
+ break;
+ default:
+ if (serviceModel.service != null && serviceModel.service.inputs != null &&
+ serviceModel.service.inputs[cmdObj.inputName] != null ) {
+ vnfModelDisplayInputs[cmdObj.inputName] = (serviceModel.service.inputs[cmdObj.inputName]);
+ }
+ }
+
+ }
+
+ }
+
+ convertedAsdcModel.vnfs[vnfCustomizationUuid].displayInputs=vnfModelDisplayInputs;
+ convertedAsdcModel.vnfs[vnfCustomizationUuid].properties=vnfModel.properties;
+ //
+ var vnf_type = "";
+ var vnf_role = "";
+ var vnf_function = "";
+ var vnf_code = "";
+ if ( !( isObjectEmpty(vnfModel.properties) ) ) {
+ if (hasContents (vnfModel.properties.nf_type) ) {
+ vnf_type = vnfModel.properties.nf_type;
+ }
+ if (hasContents (vnfModel.properties.nf_role) ) {
+ vnf_role = vnfModel.properties.nf_role;
+ }
+ if (hasContents (vnfModel.properties.nf_function) ) {
+ vnf_function = vnfModel.properties.nf_function;
+ }
+ if (hasContents (vnfModel.properties.nf_code) ) {
+ vnf_code = vnfModel.properties.nf_code;
+ }
+ }
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfType"] = vnf_type;
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfRole"] = vnf_role;
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfFunction"] = vnf_function;
+ convertedAsdcModel.vnfs[vnfCustomizationUuid]["nfCode"] = vnf_code;
+ //
+ for (var vfModuleCustomizationName in serviceModel.vnfs[vnfCustomizationName].vfModules) {
+ var vfModuleModel = serviceModel.vnfs[vnfCustomizationName].vfModules[vfModuleCustomizationName];
+ convertedAsdcModel.vnfs[vnfCustomizationUuid].vfModules[vfModuleModel.customizationUuid] = vfModuleModel;
+ }
+
+ for (var volumeGroupCustomizationName in serviceModel.vnfs[vnfCustomizationName].volumeGroups) {
+ var volumeGroupModel = serviceModel.vnfs[vnfCustomizationName].volumeGroups[volumeGroupCustomizationName];
+ convertedAsdcModel.vnfs[vnfCustomizationUuid].volumeGroups[volumeGroupModel.customizationUuid] = volumeGroupModel;
+ }
+ }
+ }
+
+ var completeDisplayInputs = {};
+
+ for (var key in vnfModelDisplayInputs) {
+ completeDisplayInputs[key] = vnfModelDisplayInputs[key];
+ }
+ for (var key in networkModelDisplayInputs) {
+ completeDisplayInputs[key] = networkModelDisplayInputs[key];
+ }
+
+ convertedAsdcModel.completeDisplayInputs = completeDisplayInputs;
+ // Need to collect all the model customization names (node template tag) and descriptions
+ DataService.setResources (completeResources);
+
+ console.log ("convertedAsdcModel: "); console.log (JSON.stringify ( convertedAsdcModel, null, 4 ));
+ return (convertedAsdcModel);
+ };
+
+ var convertOldModel = function (serviceModel ) {
+
+ var resource = {};
+ var convertedAsdcModel = {
+ "service": serviceModel.service,
+ "networks": {},
+ "vnfs": {},
+ "completeDisplayInputs": {},
+ "isNewFlow": false
+ };
+ var completeResources = new Array();
+ var resource = {};
+ var vnfModelDisplayInputs = {};
+ var networkModelDisplayInputs = {};
+ for (var networkCustomizationName in serviceModel.networks) {
+ var networkModel = serviceModel.networks[networkCustomizationName];
+ convertedAsdcModel.networks[networkModel.invariantUuid] = {};
+ //convertedAsdcModel.networks[networkModel.invariantUuid][networkModel.version] = networkModel;
+ // need a network model to test this
+ convertedAsdcModel.networks[networkModel.uuid] = {
+ "uuid": networkModel.uuid,
+ "invariantUuid": networkModel.invariantUuid,
+ "version": networkModel.version,
+ "name": networkModel.name,
+ "modelCustomizationName": networkModel.modelCustomizationName,
+ "customizationUuid": networkModel.customizationUuid,
+ "inputs": "",
+ "description": networkModel.description,
+ "commands": {},
+ "displayInputs": {}
+ }
+ resource = {
+ "name": networkModel.modelCustomizationName,
+ "description": networkModel.description
+ };
+ completeResources.push (resource);
+ if (networkModel.commands != null) {
+ /*
+ * commands:
+ * internal_net_param_ntu: {
+ * command: get_input,
+ * displaName: internal_net_param_ntu,
+ * inputName: vccfd1_internal_net_param_ntu // pointer to input key
+ * }
+ * If the input name (ptr) is one of instance_node_target, naming_policy or vf_instance_name
+ * then ignore it
+ *
+ */
+
+ for ( var cmd in networkModel.commands ) {
+ var cmdObj = networkModel.commands[cmd];
+ if ( cmdObj.inputName != null ) {
+ switch (cmdObj.inputName) {
+ case "instance_node_target":
+ break;
+ case "naming_policy":
+ break;
+ case "vf_instance_name":
+ break;
+ default:
+ if (serviceModel.service != null && serviceModel.service.inputs != null &&
+ serviceModel.service.inputs[cmdObj.inputName] != null ) {
+ networkModelDisplayInputs[cmdObj.inputName] = (serviceModel.service.inputs[cmdObj.inputName]);
+ }
+ }
+
+ }
+
+ }
+ convertedAsdcModel.networks[networkModel.uuid].displayInputs=networkModelDisplayInputs;
+ }
+ }
+
+ for (var vnfCustomizationName in serviceModel.vnfs) {
+ var vnfModel = serviceModel.vnfs[vnfCustomizationName];
+ convertedAsdcModel.vnfs[vnfModel.uuid] = {
+ "uuid": vnfModel.uuid,
+ "invariantUuid": vnfModel.invariantUuid,
+ "version": vnfModel.version,
+ "name": vnfModel.name,
+ "modelCustomizationName": vnfModel.modelCustomizationName,
+ "customizationUuid": vnfModel.customizationUuid,
+ "inputs": "",
+ "description": vnfModel.description,
+ "vfModules": {},
+ "volumeGroups": {},
+ "commands": {},
+ "displayInputs": {}
+ }
+ resource = {
+ "name": vnfModel.modelCustomizationName,
+ "description": vnfModel.description
+ };
+ completeResources.push (resource);
+
+ if (vnfModel.commands != null) {
+ /*
+ * commands: {
+ * internal_net_param_ntu: {
+ * command: get_input,
+ * displaName: internal_net_param_ntu,
+ * inputName: vccfd1_internal_net_param_ntu // pointer to input key
+ * }
+ * If the input name (ptr) is one of instance_node_target, naming_policy or vf_instance_name
+ * then ignore it
+ *
+ */
+
+ for ( var cmd in vnfModel.commands ) {
+ var cmdObj = vnfModel.commands[cmd];
+ if ( cmdObj.inputName != null ) {
+ // To Do: Make this list configurable
+ switch (cmdObj.inputName) {
+ case "instance_node_target":
+ break;
+ case "naming_policy":
+ break;
+ case "vf_instance_name":
+ break;
+ default:
+ if (serviceModel.service != null && serviceModel.service.inputs != null &&
+ serviceModel.service.inputs[cmdObj.inputName] != null ) {
+ vnfModelDisplayInputs[cmdObj.inputName] = (serviceModel.service.inputs[cmdObj.inputName]);
+ }
+ }
+
+ }
+
+ }
+ convertedAsdcModel.vnfs[vnfModel.uuid].displayInputs=vnfModelDisplayInputs;
+ }
+
+ for (var vfModuleCustomizationName in serviceModel.vnfs[vnfCustomizationName].vfModules) {
+ var vfModuleModel = serviceModel.vnfs[vnfCustomizationName].vfModules[vfModuleCustomizationName];
+ convertedAsdcModel.vnfs[vnfModel.uuid].vfModules[vfModuleModel.uuid] = vfModuleModel;
+ }
+
+ for (var volumeGroupCustomizationName in serviceModel.vnfs[vnfCustomizationName].volumeGroups) {
+ var volumeGroupModel = serviceModel.vnfs[vnfCustomizationName].volumeGroups[volumeGroupCustomizationName];
+ convertedAsdcModel.vnfs[vnfModel.uuid].volumeGroups[volumeGroupModel.uuid] = volumeGroupModel;
+ }
+ }
+ //console.log ("convertedAsdcModel: "); console.log (JSON.stringify ( convertedAsdcModel, null, 4 ) );
+
+ var completeDisplayInputs = {};
+
+ for (var key in vnfModelDisplayInputs) {
+ completeDisplayInputs[key] = vnfModelDisplayInputs[key];
+ }
+ for (var key in networkModelDisplayInputs) {
+ completeDisplayInputs[key] = networkModelDisplayInputs[key];
+ }
+
+ convertedAsdcModel.completeDisplayInputs = completeDisplayInputs;
+ // Need to collect all the model customization names (node template tag) and descriptions
+ DataService.setResources (completeResources);
+ console.log ("convertedAsdcModel: "); console.log (JSON.stringify ( convertedAsdcModel, null, 4 ));
+ return (convertedAsdcModel);
+ };
+
+ function hasContents(object) {
+ if (object === undefined || object === null || object === "") {
+ return false;
+ }
+ return true;
+ };
+ function isObjectEmpty(o) {
+ var len = 0;
+ if (hasContents(o)){
+ var keys = Object.keys(o);
+ len = keys.length;
+ if ( len == 0 ) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return true;
+ }
+ };
+ function padZero(number) {
+ if (number < 10) {
+ return "0" + number;
+ } else {
+ return "" + number;
+ }
+ };
+
+ var httpErrorHandler = function(response, status) {
+ $log.warn("UtilityService:httpErrorHandler: response:");
+ $log.warn(response);
+ $log.warn("UtilityService:httpErrorHandler: status:");
+ $log.warn(status);
+ if (angular.isFunction(_this.httpErrorHandler)) {
+ _this.httpErrorHandler(response, status);
+ }
+ };
+
+ var startNextAsyncOperation = function() {
+ if (_this.asyncOperations.count < _this.asyncOperations.operationList.length) {
+ _this.asyncOperations.operationList[_this.asyncOperations.count++]
+ ();
+ } else {
+ if (angular.isFunction(_this.asyncOperations.callbackFunction)) {
+ _this.asyncOperations.callbackFunction();
+ }
+ }
+ };
+
+ return {
+ setProperties : function(properties) {
+ _this.properties = properties;
+ },
+ getProperties : function() {
+ return _this.properties;
+ },
+ hasContents : hasContents,
+ checkUndefined : function(name, value) {
+ if (value === undefined) {
+ throw {
+ type : "undefinedObject",
+ message : "undefined object: \"" + name + "\""
+ };
+ }
+ return value;
+ },
+ jsonConcat : function (o1, o2) {
+ for (var key in o2) {
+ o1[key] = o2[key];
+ }
+ return o1;
+ },
+ getCurrentTime : function() {
+ var time = new Date();
+ return padZero(time.getMonth() + 1) + "/"
+ + padZero(time.getDate()) + "/"
+ + (time.getFullYear() - 2000) + " "
+ + padZero(time.getHours()) + ":"
+ + padZero(time.getMinutes()) + ":"
+ + padZero(time.getSeconds())
+ },
+ getHttpStatusText : function(statusCode) {
+ var statusMap = {
+ "200" : "OK",
+ "201" : "Created",
+ "202" : "Accepted",
+ "400" : "Bad Request",
+ "401" : "Unauthorized",
+ "404" : "Not Found",
+ "405" : "Method Not Allowed",
+ "409" : "Locked",
+ "500" : "Internal Server Error",
+ "503" : "Service Unavailable",
+ "504" : "Gateway Timeout"
+ }
+
+ if (status === undefined) {
+ return "Undefined";
+ }
+
+ var statusText = statusMap[statusCode];
+ if (statusText === undefined) {
+ statusText = "Unknown";
+ }
+
+ return statusText + " (" + statusCode + ")";
+ },
+ getHttpErrorMessage : function(response) {
+ var data = response.data;
+ if (response.status === 500 && hasContents(data.exception)) {
+ var summary = "exception: " + data.exception;
+ if (hasContents(data.message)) {
+ summary += " message: " + data.message;
+ }
+ return summary;
+ }
+ if (response.status === 0 && response.statusText === "") {
+ /*
+ * This logic is somewhat "fuzzy". Potential (brainstorming)
+ * enhancements if users find the message unreliable include:
+ *
+ * A) SERVER TIMEOUT: perhaps a newer version of Angular can
+ * reliably determine timeouts.
+ *
+ * B) SERVER TIMEOUT: recording start / end times and using that
+ * to determine if timeout occured
+ *
+ * C) SESSION TIMEOUT "Potentially" examine cookies, although
+ * that may not be feasible if cookies are set to "httponly".
+ */
+ if (data === null) {
+ //return "possible server timeout";
+ return "VID has timed out waiting for a response. To see status, close this popup and the screen will be refreshed automatically";
+ }
+ if (data === "") {
+ return "Possible reasons include a session timeout or a server issue. "
+ + "A session timeout might be resolved by refreshing the screen and re-logging in";
+ }
+ }
+ var summary = "";
+ if (response.status !== undefined && response.status > 0) {
+ summary = "status: " + response.status;
+ }
+ if (hasContents(response.statusText)) {
+ if (summary !== "") {
+ summary += " ";
+ }
+ summary += "message: " + response.statusText;
+ }
+ return summary;
+ },
+ setHttpErrorHandler : function(httpErrorHandler) {
+ _this.httpErrorHandler = httpErrorHandler;
+ },
+ runHttpErrorHandler : function(response, status) {
+ httpErrorHandler(response, status);
+ },
+ startAsyncOperations : function(operationList, callbackFunction) {
+ for (var i = 0; i < operationList.length; i++) {
+ if (!angular.isFunction(operationList[i])) {
+ throw "UtilityService:startAsyncOperations: invalid function: index: "
+ + i;
+ }
+ }
+ _this.asyncOperations = {
+ operationList : operationList,
+ callbackFunction : callbackFunction,
+ count : 0
+ };
+ startNextAsyncOperation();
+ },
+ startNextAsyncOperation : startNextAsyncOperation,
+ stopAsyncOperations : function() {
+ _this.asyncOperations.count = _this.asyncOperations.operationList.length;
+ },
+ isObjectEmpty : isObjectEmpty,
+ convertModel : convertModel,
+ convertNewModel : convertNewModel,
+ convertOldModel : convertOldModel,
+ arrayContains : function (a, obj) {
+ var i = a.length;
+ if ( i > 0 ) {
+ while (i--) {
+ if (a[i] === obj) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+}
+
+//app.factory("UtilityService", UtilityService);
+appDS2.factory("UtilityService", [ "$log", "DataService", UtilityService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js
new file mode 100755
index 000000000..836279b9f
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js
@@ -0,0 +1,82 @@
+/*-
+ * ============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 VnfService = function($http, $log, VIDCONFIGURATION, FIELD, UtilityService) {
+ var isVnfStatusValid = function(vnfInstance) {
+
+ if ( (UtilityService.isObjectEmpty(vnfInstance)) || (UtilityService.isObjectEmpty(vnfInstance.object)) ) {
+ return (errorInternalMsg);
+ }
+ var status = {
+ "provStatus": "",
+ "orchestrationStatus": "",
+ "inMaint": false,
+ "operationalStatus": null
+ };
+ var errorAaiStatusMsg = "The prov-status, orchestration-status or in-maint fields are not captured correctly in A&AI for this VNF: "
+ + vnfInstance.object['vnf-name'] + ". Please update these statuses in A&AI before attempting this change.";
+ var errorInvalidCombinationMsg = "The VNF: " + vnfInstance.object['vnf-name'] +
+ ", has reached a status where further changes cannot be made in VID. Additional changes should be made through the Change Management Processes.";
+ var errorInternalMsg = "Internal VID Error: The VNF Instance is not populated."
+
+ if ( ( UtilityService.hasContents ( vnfInstance.object[FIELD.ID.ORCHESTRATION_STATUS] ) ) &&
+ ( UtilityService.hasContents ( vnfInstance.object[FIELD.ID.IN_MAINT] ) ) &&
+ ( UtilityService.hasContents ( vnfInstance.object[FIELD.ID.PROV_STATUS] ) ) ) {
+
+ status.provStatus = vnfInstance.object[FIELD.ID.PROV_STATUS].toLowerCase();
+ status.orchestrationStatus = vnfInstance.object[FIELD.ID.ORCHESTRATION_STATUS].toLowerCase();
+ status.inMaint = vnfInstance.object[FIELD.ID.IN_MAINT];
+
+ if ( UtilityService.hasContents(vnfInstance.object[FIELD.ID.OPERATIONAL_STATUS]) ) {
+ status.operationalStatus = vnfInstance.object[FIELD.ID.OPERATIONAL_STATUS].toLowerCase();
+ }
+
+ if ( UtilityService.arrayContains ( VIDCONFIGURATION.VNF_VALID_STATUS_LIST, status ) ) {
+ return ("");
+ }
+ else {
+ return (errorInvalidCombinationMsg);
+ }
+ }
+ else {
+ return (errorAaiStatusMsg);
+ }
+ };
+ var isVnfListStatusValid = function(vnfArray) {
+ var msg = "";
+ for(var i = 0; i < vnfArray.length; i++) {
+ var vnf = vnfArray[i];
+ msg = isVnfStatusValid (vnf);
+ if ( msg != "" ) {
+ return (msg);
+ }
+ }
+ return (msg);
+ };
+ return {
+ isVnfStatusValid: isVnfStatusValid,
+ isVnfListStatusValid : isVnfListStatusValid
+ }
+};
+
+appDS2.factory("VnfService", [ "$http", "$log", "VIDCONFIGURATION", "FIELD",
+ "UtilityService", VnfService ]);