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 ifDecision = executor.inFields["decision"];
27 var ifMatchStart = executor.inFields["matchStart"];
29 var albumCustomerMap = executor.getContextAlbum("albumCustomerMap");
30 var albumProblemMap = executor.getContextAlbum("albumProblemMap");
32 switch (ifDecision.get("decision").toString()) {
34 executor.outFields["edgeName"] = "";
35 executor.outFields["action"] = "";
38 for (var i = 0; i < ifDecision.get("customers").size(); i++) {
39 customer = albumCustomerMap.get(ifDecision.get("customers").get(i).toString());
40 executor.outFields["edgeName"] = customer.get("links").get(0);
41 executor.outFields["action"] = "firewall";
45 // finally solved, remove problem
46 albumProblemMap.remove(ifDecision.get("problemID"));
47 executor.outFields["edgeName"] = "L10"; // this is ###static###
48 executor.outFields["action"] = "rebuild"; // this is ###static###
54 if (executor.outFields["action"] != "") {
55 logger.info("vpnsla: action is to " + executor.outFields["action"] + " " + executor.outFields["edgeName"]);
57 logger.info("vpnsla: no action required");
60 logger.trace("-- outfields: " + executor.outFields);
61 logger.trace("finished: " + executor.subject.id);
64 var now = new Date().getTime();
65 logger.info("VPN SLA finished in " + (now - ifMatchStart) + " ms");