summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js')
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/vnfService.js82
1 files changed, 82 insertions, 0 deletions
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 00000000..836279b9
--- /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 ]);