X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2app%2Fentrypoints%2Fredis_eventconsumer.py;h=db39daa9fefcc26658a674ed450f33e11bb18016;hb=refs%2Fheads%2Fmaster;hp=439619bc869c3c788d3b303150560ce291519e7b;hpb=b533c03e9233171cbd114339f98bd428688998a7;p=pti%2Fo2.git diff --git a/o2app/entrypoints/redis_eventconsumer.py b/o2app/entrypoints/redis_eventconsumer.py index 439619b..8098d04 100644 --- a/o2app/entrypoints/redis_eventconsumer.py +++ b/o2app/entrypoints/redis_eventconsumer.py @@ -16,15 +16,17 @@ import redis import json + from o2app import bootstrap -from o2common.config import config from o2common.adapter.notifications import SmoNotifications +from o2common.config import config +from o2common.helper import o2logging from o2dms.domain import commands from o2ims.domain import commands as imscmd -from o2ims.domain.subscription_obj import Message2SMO, RegistrationMessage +from o2ims.domain.subscription_obj import Message2SMO, RegistrationMessage, \ + NotificationEventEnum from o2ims.domain.alarm_obj import AlarmEvent2SMO -from o2common.helper import o2logging logger = o2logging.get_logger(__name__) r = redis.Redis(**config.get_redis_host_and_port()) @@ -124,9 +126,17 @@ def handle_changed(m, bus): datastr = m['data'] data = json.loads(datastr) logger.info('OcloudChanged with cmd:{}'.format(data)) - cmd = imscmd.Register2SMO(data=RegistrationMessage( - id=data['id'], eventtype=data['notificationEventType'], - updatetime=data['updatetime'])) + if data['notificationEventType'] == NotificationEventEnum.CREATE: + cmd = imscmd.Register2SMO(data=RegistrationMessage( + id=data['id'], eventtype=data['notificationEventType'], + updatetime=data['updatetime'])) + elif data['notificationEventType'] == NotificationEventEnum.MODIFY: + ref = apibase + inventory_api_version + cmd = imscmd.PubMessage2SMO(data=Message2SMO( + id=data['id'], ref=ref, + eventtype=data['notificationEventType'], + updatetime=data['updatetime']), + type='OCloud') bus.handle(cmd) elif channel == 'AlarmEventChanged': datastr = m['data'] @@ -143,11 +153,8 @@ def handle_changed(m, bus): 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'], + id=data['id'], ref="", eventtype=data['notificationEventType'], updatetime=data['updatetime'])) bus.handle(cmd) else: