2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2020 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 var logger = executor.logger;
23 logger.trace("start: " + executor.subject.id);
24 logger.trace("-- infields: " + executor.inFields);
26 var ifCustomerName = executor.inFields["customerName"];
27 var ifLinks = executor.inFields["links"];
29 logger.trace("-- got infields, testing existing customer");
30 var ctxtCustomer = executor.getContextAlbum("albumCustomerMap").get(ifCustomerName);
31 if (ctxtCustomer != null) {
32 executor.getContextAlbum("albumCustomerMap").remove(ifCustomerName);
33 logger.trace("-- removed customer: <" + ifCustomerName + ">");
36 logger.trace("-- creating customer: <" + ifCustomerName + ">");
37 var links = new Array();
38 for (var i = 0; i < ifLinks.split(" ").length; i++) {
39 var link = executor.getContextAlbum("albumTopoEdges").get(ifLinks.split(" ")[i]);
41 logger.trace("-- link: <" + ifLinks.split(" ")[i] + ">");
42 links.push(ifLinks.split(" ")[i]);
44 logger.trace("-- unknown link: <" + ifLinks.split(" ")[i] + "> for customer <" + ifCustomerName + ">");
47 logger.trace("-- links: <" + links + ">");
48 ctxtCustomer = "{customerName:" + ifCustomerName + ", dtSLA:" + executor.inFields["dtSLA"] + ", dtYTD:"
49 + executor.inFields["dtYTD"] + ", priority:" + executor.inFields["priority"] + ", satisfaction:"
50 + executor.inFields["satisfaction"] + ", links:[" + links + "]}";
52 executor.getContextAlbum("albumCustomerMap").put(ifCustomerName, ctxtCustomer);
54 if (logger.isTraceEnabled()) {
55 logger.trace(" >> *** Customers ***");
56 if (executor.getContextAlbum("albumCustomerMap") != null) {
57 for (var i = 0; i < executor.getContextAlbum("albumCustomerMap").values().size(); i++) {
58 logger.trace(" >> >> " + executor.getContextAlbum("albumCustomerMap").values().get(i).get("customerName")
59 + " : " + "dtSLA=" + executor.getContextAlbum("albumCustomerMap").values().get(i).get("dtSLA")
60 + " : " + "dtYTD=" + executor.getContextAlbum("albumCustomerMap").values().get(i).get("dtYTD")
61 + " : " + "links=" + executor.getContextAlbum("albumCustomerMap").values().get(i).get("links")
63 + executor.getContextAlbum("albumCustomerMap").values().get(i).get("priority") + " : "
65 + executor.getContextAlbum("albumCustomerMap").values().get(i).get("satisfaction"));
68 logger.trace(" >> >> customer album is null");
72 executor.outFields["report"] = "customer ctxt :: added customer: " + ifCustomerName;
74 logger.info("vpnsla: ctxt added customer " + ifCustomerName);
76 logger.trace("finished: " + executor.subject.id);