1e9d6be7105146c726a52ecf562832908860b91a
[policy/apex-pdp.git] /
1 /*
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 var logger = executor.logger;
23 logger.trace("start: " + executor.subject.id);
24 logger.trace("-- infields: " + executor.inFields);
25
26 var ifEdgeName = executor.inFields["edgeName"];
27 var ifEdgeStatus = executor.inFields["status"];
28
29 var albumTopoEdges = executor.getContextAlbum("albumTopoEdges");
30
31 logger.trace("-- got infields, testing existing edge");
32
33 var ctxtEdge = albumTopoEdges.get(ifEdgeName);
34 if (ctxtEdge != null) {
35     albumTopoEdges.remove(ifEdgeName);
36     logger.trace("-- removed edge: <" + ifEdgeName + ">");
37 }
38
39 logger.trace("-- creating edge: <" + ifEdgeName + ">");
40 ctxtEdge = "{name:" + ifEdgeName + ", start:" + executor.inFields["start"] + ", end:" + executor.inFields["end"]
41         + ", active:" + ifEdgeStatus + "}";
42 albumTopoEdges.put(ifEdgeName, ctxtEdge);
43
44 if (logger.isTraceEnabled()) {
45     logger.trace("   >> *** Edges ***");
46     if (albumTopoEdges != null) {
47         for (var i = 0; i < albumTopoEdges.values().size(); i++) {
48             logger.trace("   >> >> " + albumTopoEdges.values().get(i).get("name") + " \t "
49                     + albumTopoEdges.values().get(i).get("start") + " --> " + albumTopoEdges.values().get(i).get("end")
50                     + " \t " + albumTopoEdges.values().get(i).get("active"));
51         }
52     } else {
53         logger.trace("   >> >> edge album is null");
54     }
55 }
56
57 executor.outFields["report"] = "edge ctxt :: added edge " + ifEdgeName;
58
59 logger.info("vpnsla: ctxt added edge " + ifEdgeName);
60
61 logger.trace("finished: " + executor.subject.id);
62 logger.debug(".");
63
64 true;