2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 load("nashorn:mozilla_compat.js");
23 var now = new Date().getTime();
24 executor.outFields["matchStart"] = now;
26 importClass(org.slf4j.LoggerFactory);
28 var logger = executor.logger;
29 logger.trace("start: " + executor.subject.id);
30 logger.trace("-- infields: " + executor.inFields);
32 var rootLogger = LoggerFactory.getLogger(logger.ROOT_LOGGER_NAME);
34 var ifEdgeName = executor.inFields["edgeName"];
35 var ifLinkStatus = executor.inFields["status"];
37 var albumTopoEdges = executor.getContextAlbum("albumTopoEdges");
39 logger.trace("-- got infields, checking albumTopoEdges changes");
42 switch (ifLinkStatus.toString()) {
51 logger.error("-- trigger sent unknown link status <" + ifLinkStatus + "> for link <" + ifEdgeName + ">");
52 rootLogger.error(executor.subject.id + " " + "-- trigger sent unknown link status <" + ifLinkStatus
53 + "> for link <" + ifEdgeName + ">");
56 var link = albumTopoEdges.get(ifEdgeName);
58 logger.trace("-- link <" + ifEdgeName + "> not in albumTopoEdges");
60 logger.trace("-- found link <" + link + "> in albumTopoEdges");
61 logger.trace("-- active <" + active + "> : link.active <" + link.get("active") + ">");
62 if (active != link.get("active")) {
63 link.put("active", active);
64 logger.trace("-- link <" + ifEdgeName + "> status changed to <active:" + link.get("active") + ">");
65 executor.outFields["hasChanged"] = true;
67 logger.trace("-- link <" + ifEdgeName + "> status not changed <active:" + link.get("active") + ">");
68 executor.outFields["hasChanged"] = false;
72 executor.outFields["edgeName"] = ifEdgeName;
73 executor.outFields["status"] = ifLinkStatus;
75 logger.info("vpnsla: detected " + ifEdgeName + " as " + ifLinkStatus);
77 var returnValueType = Java.type("java.lang.Boolean");
78 var returnValue = new returnValueType(true);
79 logger.trace("finished: " + executor.subject.id);