summaryrefslogtreecommitdiffstats
path: root/rules/ccvpn2-rule.drl
diff options
context:
space:
mode:
authorRama-Huawei <rama.subba.reddy.s@huawei.com>2019-03-28 10:21:17 +0530
committerRama-Huawei <rama.subba.reddy.s@huawei.com>2019-03-28 10:21:17 +0530
commit0615c0aee375288a994aae470ffa366ed0673462 (patch)
treeedd7dbc7bf8c9b7d9026e8230993226888590e17 /rules/ccvpn2-rule.drl
parentb0d81fb3801a9c3bca157a23326d74ec45ab28b1 (diff)
Prepare Rules for CCVPN Extension
This rule is used to support intelligent surveillance function in CCVPN extension Change-Id: Iae40327dbe8605e9a34156b4c8e5765b5155ac6b Issue-ID: HOLMES-193 Signed-off-by: Rama-Huawei <rama.subba.reddy.s@huawei.com>
Diffstat (limited to 'rules/ccvpn2-rule.drl')
-rw-r--r--rules/ccvpn2-rule.drl81
1 files changed, 81 insertions, 0 deletions
diff --git a/rules/ccvpn2-rule.drl b/rules/ccvpn2-rule.drl
new file mode 100644
index 0000000..89ce5ca
--- /dev/null
+++ b/rules/ccvpn2-rule.drl
@@ -0,0 +1,81 @@
+package org.onap.holmes.ccvpn;
+
+dialect "java"
+
+ import org.onap.holmes.common.api.stat.VesAlarm;
+ import org.onap.holmes.common.api.stat.AlarmAdditionalField;
+ import org.onap.holmes.common.aai.AaiQuery4Ccvpn2;
+ import org.onap.holmes.common.exception.CorrelationException;
+ import org.onap.holmes.common.dmaap.entity.PolicyMsg;
+ import org.onap.holmes.common.dmaap.DmaapService;
+ import org.onap.holmes.common.utils.DroolsLog;
+ import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
+
+ import com.alibaba.fastjson.JSONArray;
+ import com.alibaba.fastjson.JSONObject;
+
+ import java.util.List;
+ import java.util.Map;
+ import java.util.ArrayList;
+ import java.util.HashMap;
+ import java.util.UUID;
+
+ function String getAdditionalField(VesAlarm a, String field) {
+ List<AlarmAdditionalField> fields = a.getAlarmAdditionalInformation();
+ for (AlarmAdditionalField f : fields) {
+ if (f.getName().equals(field)) {
+ return f.getValue();
+ }
+ }
+ return null;
+ }
+
+ function Map<String, Object> getAdditionalResourceInfo(VesAlarm a, String bandwidth) {
+ AaiQuery4Ccvpn2 aai = AaiQuery4Ccvpn2.newInstance();
+ JSONObject instance = aai.getServiceInstance(getAdditionalField(a, "siteService"));
+ Map<String, Object> ret = new HashMap<String, Object>();
+ ret.put("service-instance.service-instance-id", instance.getString("service-instance-id"));
+ ret.put("vserver.vserver-name", "TBD");
+ ret.put("globalSubscriberId", instance.getString("globalSubscriberId"));
+ ret.put("serviceType", instance.getString("serviceType"));
+ ret.put("vserver.is-closed-loop-disabled", "false");
+ ret.put("vserver.prov-status", "ACTIVE");
+ ret.put("bandwidth", bandwidth);
+ ret.put("bandwidth-change-time", getAdditionalField(a, "timestamp"));
+ ret.put("vnfId", instance.getString("vnfId"));
+ return ret;
+ }
+
+ function PolicyMsg createPolicyMsg(VesAlarm alarm, String bandwidth) {
+ PolicyMsg m = new PolicyMsg();
+ m.setPolicyVersion("2.0.0");
+ m.setPolicyName("ccvpn");
+ m.setPolicyScope("service=SOTNService,type=SampleType,closedLoopControlName=CL-CCVPN-d925ed73-8231-4d02-9545-db4e101f88f8");
+ m.setClosedLoopControlName(DmaapService.loopControlNames.get("org.onap.holmes.ccvpn"));
+ m.setRequestID(UUID.randomUUID().toString());
+ m.setClosedLoopAlarmStart(alarm.getStartEpochMicrosec());
+ m.setClosedLoopAlarmEnd(alarm.getLastEpochMicrosec());
+ m.setTarget("vserver.vserver-name");
+ m.setAai(getAdditionalResourceInfo(alarm, bandwidth));
+
+ DmaapService.alarmUniqueRequestID.put(alarm.getEventId(), m.getRequestID());
+
+ return m;
+ }
+
+ rule "Analyse traffic exception"
+ no-loop true
+ salience 200
+ when
+ $a: VesAlarm(eventName.indexOf("bandwidth") != -1,
+ rootFlag != 1)
+ then
+ String bandwidth = "5000";
+ if ("Abnormal".equalsIgnoreCase(getAdditionalField($a, "exceptionType"))) {
+ bandwidth = "10000";
+ }
+ PolicyMsg msg = createPolicyMsg($a, bandwidth);
+ DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
+ dmaapService.publishPolicyMsg(msg, "unauthenticated.DCAE_CL_OUTPUT");
+ $a.setRootFlag(1);
+ end