X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2app%2Fentrypoints%2Fredis_eventconsumer.py;h=439619bc869c3c788d3b303150560ce291519e7b;hb=refs%2Fchanges%2F83%2F12783%2F3;hp=1410f7691f63118ea3308024d3ef8f80a082f291;hpb=0a3e34246589157182335ed85605c362525a2768;p=pti%2Fo2.git diff --git a/o2app/entrypoints/redis_eventconsumer.py b/o2app/entrypoints/redis_eventconsumer.py index 1410f76..439619b 100644 --- a/o2app/entrypoints/redis_eventconsumer.py +++ b/o2app/entrypoints/redis_eventconsumer.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Wind River Systems, Inc. +# Copyright (C) 2021-2024 Wind River Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import redis import json from o2app import bootstrap from o2common.config import config +from o2common.adapter.notifications import SmoNotifications from o2dms.domain import commands from o2ims.domain import commands as imscmd from o2ims.domain.subscription_obj import Message2SMO, RegistrationMessage @@ -36,7 +37,10 @@ inventory_api_version = config.get_o2ims_inventory_api_v1() def main(): logger.info("Redis pubsub starting") - bus = bootstrap.bootstrap() + + notifications = SmoNotifications() + bus = bootstrap.bootstrap(notifications=notifications) + pubsub = r.pubsub(ignore_subscribe_messages=True) pubsub.subscribe("NfDeploymentStateChanged") pubsub.subscribe('OcloudChanged') @@ -45,6 +49,7 @@ def main(): pubsub.subscribe('DmsChanged') pubsub.subscribe('ResourceChanged') pubsub.subscribe('AlarmEventChanged') + pubsub.subscribe('AlarmEventPurged') for m in pubsub.listen(): try: @@ -120,8 +125,8 @@ def handle_changed(m, bus): data = json.loads(datastr) logger.info('OcloudChanged with cmd:{}'.format(data)) cmd = imscmd.Register2SMO(data=RegistrationMessage( - data['notificationEventType'], - id=data['id'])) + id=data['id'], eventtype=data['notificationEventType'], + updatetime=data['updatetime'])) bus.handle(cmd) elif channel == 'AlarmEventChanged': datastr = m['data'] @@ -134,6 +139,17 @@ def handle_changed(m, bus): eventtype=data['notificationEventType'], updatetime=data['updatetime'])) bus.handle(cmd) + elif channel == 'AlarmEventPurged': + datastr = m['data'] + data = json.loads(datastr) + logger.info('AlarmEventPurged with cmd:{}'.format(data)) + ref = api_monitoring_base + \ + monitor_api_version + '/alarms/' + data['id'] + cmd = imscmd.PurgeAlarmEvent(data=AlarmEvent2SMO( + id=data['id'], ref=ref, + eventtype=data['notificationEventType'], + updatetime=data['updatetime'])) + bus.handle(cmd) else: logger.info("unhandled:{}".format(channel))