...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package org.onap.holmes.mdonsPnf; dialect "java" import org.onap.holmes.common.api.stat.VesAlarm; import org.onap.holmes.common.api.stat.AlarmAdditionalField; import org.onap.holmes.common.aai.AaiQueryMdons; 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 comorg.alibabaonap.fastjson.JSONArray; import com.alibaba.fastjson.JSONObjectholmes.common.dmaap.store.UniqueRequestIdCache; import java.util.List; import java.util.Map; import java.util.ArrayList; import java.util.HashMap; import java.util.UUID; function Map<String, String> processAlarm(String sourceId) { AaiQueryMdonsAaiQueryMdons mdons = AaiQueryMdons.newInstance(); DroolsLogDroolsLog.printInfo("Alarm pnf id " + sourceId); StringString pnfName = mdons.getPnfNameFromPnfId(sourceId); DroolsLogDroolsLog.printInfo("Pnf name from AAI" + pnfName); mdonsmdons.updatePnfOperationalStatus(pnfName, "down"); Map<StringMap<String, String> accessMap = mdons.processPnf(pnfName); DroolsLogDroolsLog.printInfo("Access List from AAI" + accessMap.toString()); mdonsmdons.updateLinksForAccessService(accessMap); returnreturn accessMap; } function void processAlarmCleared(String sourceId) { AaiQueryMdonsAaiQueryMdons mdons = AaiQueryMdons.newInstance(); DroolsLogDroolsLog.printInfo("Alarm pnf id " + sourceId); StringString pnfName = mdons.getPnfNameFromPnfId(sourceId); DroolsLogDroolsLog.printInfo("Pnf name from AAI" + pnfName); mdonsmdons.updatePnfOperationalStatus(pnfName, "up"); } function PolicyMsg createPolicyMsg(VesAlarm alarm, String serviceInstanceId, String serviceName) { PolicyMsgPolicyMsg m = new PolicyMsg(); mm.setPolicyVersion("1.0.0"); mm.setVersion("0.0.1"); mm.setPolicyName("mdons"); mm.setPolicyScope("service=OTNService,type=SampleType,closedLoopControlName=ControlLoop-MDONS-2179b738-fd36-4843-a71a-a8c24c70c66b"); mm.setClosedLoopControlName("ControlLoop-MDONS-2179b738-fd36-4843-a71a-a8c24c70c66b"); mm.setRequestID(UUID.randomUUID().toString()); mm.setClosedLoopAlarmStart(alarm.getStartEpochMicrosec()); mm.setClosedLoopAlarmEnd(alarm.getLastEpochMicrosec()); mm.setTarget("vserver.vserver-name"); mm.setAai(getAaiObjectPolicy(serviceName, serviceInstanceId)); DmaapService.alarmUniqueRequestID ServiceLocatorHolder.getLocator().getService(UniqueRequestIdCache.class).put(alarm.getEventId(), m.getRequestID()); returnreturn m; } function Map<String, Object> getAaiObjectPolicy(String serviceName, String serviceInstanceId){ Map<StringMap<String, Object> aaiMap = new HashMap<String, Object>(); aaiMapaaiMap.put("service-name", serviceName); aaiMapaaiMap.put("request-id" , serviceInstanceId); aaiMapaaiMap.put("service-type" , "MDONS_OTN"); returnreturn aaiMap; } rule "Process Alarms MSA" nono-loop true saliencesalience 200 whenwhen $a$a: VesAlarm(sourceId.contains("OWBSPDRNE"), rootFlagrootFlag != 1, eventSeverity.equals("MAJOR")) thenthen DroolsLogDroolsLog.printInfo("MSA Alarm: ID for alarm raised=" + $a.getEventId() + ", Event Name=" + $a.getSourceId()); Map<StringMap<String, String> map = processAlarm($a.getSourceId() + "-XPDR1"); forfor(Map.Entry<String,String> entry : map.entrySet()){ PolicyMsgPolicyMsg msg = createPolicyMsg($a, entry.getKey(), entry.getValue()); DmaapServiceDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class); dmaapServicedmaapService.publishPolicyMsg(msg, "unauthenticated.DCAE_Output_Event"); DroolsLogDroolsLog.printInfo("Published to policy=" + msg.toString()); } $a$a.setRootFlag(1); end rule "Process Alarms TAPI" nono-loop true saliencesalience 200 whenwhen $a$a: VesAlarm(eventId.contains("FW950074SDN"), rootFlagrootFlag != 1, eventSeverity.equals("MINOR")) thenthen DroolsLogDroolsLog.printInfo("TAPI Alarm: ID for alarm raised=" + $a.getEventId() + ", Event Name=" + $a.getSourceId()); Map<StringMap<String, String> map = processAlarm($a.getEventId()); forfor(Map.Entry<String,String> entry : map.entrySet()){ PolicyMsgPolicyMsg msg = createPolicyMsg($a, entry.getKey(), entry.getValue()); DmaapServiceDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class); dmaapServicedmaapService.publishPolicyMsg(msg, "unauthenticated.DCAE_Output_Event"); DroolsLogDroolsLog.printInfo("Published to policy=" + msg.toString()); } $a$a.setRootFlag(1); end rule "Process Alarms cleared MSA" nono-loop true saliencesalience 200 whenwhen $a$a: VesAlarm(sourceId.contains("OWBSPDRNE"), rootFlagrootFlag != 1, eventSeverity.equals("NORMAL")) thenthen DroolsLogDroolsLog.printInfo("MSA Alarm: ID for Alarm cleared =" + $a.getEventId() + ", Event Name=" + $a.getSourceId()); processAlarmClearedprocessAlarmCleared($a.getSourceId() + "-XPDR1"); $a$a.setRootFlag(1); end rule "Process Alarms cleared TAPI" nono-loop true saliencesalience 200 whenwhen $a$a: VesAlarm(eventId.contains("FW950074SDN"), rootFlagrootFlag != 1, eventSeverity.equals("NORMAL")) thenthen DroolsLogDroolsLog.printInfo("TAPI Alarm: ID for Alarm cleared =" + $a.getEventId() + ", Event Name=" + $a.getSourceId()); processAlarmClearedprocessAlarmCleared($a.getEventId()); $a$a.setRootFlag(1); end |
Upon receiving NNI up notification - update the status of the NNI in AAI.
...