225a0da4de59567062ff9809651937a598fe94e2
[policy/apex-pdp.git] /
1 /*
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
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
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.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 import org.onap.policy.apex.examples.aadm.concepts.ENodeBStatus;
21 import org.onap.policy.apex.examples.aadm.concepts.ImsiStatus;
22
23 logger.debug(subject.id + ":" + subject.taskName + " execution logic");
24 logger.debug(inFields);
25
26 outFields["ACTTASK"] = "act";
27 outFields["TRIGGER_SPEC"] = "XSTREAM_AADM_ACT_EVENT";
28 outFields["MAJ_MIN_MAINT_VERSION"] = "0.0.1";
29 outFields["PROBE_ON"] = true;
30 outFields["TCP_ON"] = false;
31 outFields["IMSI"] = inFields["IMSI"];
32
33 if (inFields["IMSI_IP"] != null) {
34     outFields["IMSI_IP"] = inFields["IMSI_IP"];
35 }
36 else{
37     outFields["IMSI_IP"] = inFields["UE_IP_ADDRESS"];
38 }
39
40 if (inFields["NW_IP"] != null) {
41     outFields["NW_IP"] = inFields["NW_IP"];
42 }
43 else{
44     outFields["NW_IP"] = inFields["SGW_IP_ADDRESS"];
45 }
46
47 ImsiStatus imsiStatus = getContextAlbum("IMSIStatusAlbum").get((String)inFields["IMSI"]);
48 logger.debug(imsiStatus);
49
50 ENodeBStatus eNodeBStatus = getContextAlbum("ENodeBStatusAlbum").get(imsiStatus.getENodeBId());
51 eNodeBStatus.setBeingProbed(false);
52
53 leaveProbingOn = false;
54 for (ENodeBStatus enbStatus : getContextAlbum("ENodeBStatusAlbum").values) {
55     if (enbStatus.getBeingProbed()) {
56         leaveProbingOn = true;
57     }
58 }
59
60 if (!leaveProbingOn) {
61     outFields["PROBE_ON"] = false;
62     outFields["TCP_ON"] = false;
63 }
64
65 eNodeBStatus.decrementDosCount();
66 logger.debug(eNodeBStatus.getENodeB() + ": dosCount is " + eNodeBStatus.getDosCount());
67
68 imsiStatus.setAnomalous(false);
69
70 logger.debug("imsi: " + imsiStatus.getImsi() + " anamalous " + imsiStatus.getAnomalous());
71
72 getContextAlbum("IMSIStatusAlbum")  .put(imsiStatus.getImsi(),     imsiStatus);
73 getContextAlbum("ENodeBStatusAlbum").put(eNodeBStatus.getENodeB(), eNodeBStatus);
74
75 outFields["THRESHOLD"]    = 0;
76 outFields["PROFILE"]      = "";
77 outFields["VERSION"]      = "0.0.1";
78 outFields["BLACKLIST_ON"] = false;
79
80 return true;