X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2app%2Fentrypoints%2Fredis_eventconsumer.py;h=84729490f4569ac2ecf3f705133d834141d817ba;hb=d14329a57d8d01d443e4158fa5030a5b5ada4060;hp=188eb87f79c67ad7e10a07fe8ff80861fe77b23c;hpb=5e02e76308e1677fb106572b885a366eb6c0fbec;p=pti%2Fo2.git diff --git a/o2app/entrypoints/redis_eventconsumer.py b/o2app/entrypoints/redis_eventconsumer.py index 188eb87..8472949 100644 --- a/o2app/entrypoints/redis_eventconsumer.py +++ b/o2app/entrypoints/redis_eventconsumer.py @@ -13,11 +13,14 @@ # limitations under the License. # import json +from logging import log import redis - +import json from o2app import bootstrap from o2common.config import config # from o2common.domain import commands +from o2dms.domain import commands +from o2dms.domain import events from o2common.helper import o2logging logger = o2logging.get_logger(__name__) @@ -29,17 +32,31 @@ def main(): logger.info("Redis pubsub starting") bus = bootstrap.bootstrap() pubsub = r.pubsub(ignore_subscribe_messages=True) - pubsub.subscribe("dms_changed") + pubsub.subscribe("NfDeploymentStateChanged") for m in pubsub.listen(): - handle_dms_changed(m, bus) + try: + handle_dms_changed(m, bus) + except Exception as ex: + logger.warning("{}".format(str(ex))) + continue def handle_dms_changed(m, bus): logger.info("handling %s", m) - # data = json.loads(m["data"]) - # cmd = commands.UpdateDms(ref=data["dmsid"]) - # bus.handle(cmd) + channel = m['channel'].decode("UTF-8") + if channel == "NfDeploymentStateChanged": + datastr = m['data'] + data = json.loads(datastr) + logger.info('HandleNfDeploymentStateChanged with cmd:{}'.format(data)) + cmd = commands.HandleNfDeploymentStateChanged( + NfDeploymentId = data['NfDeploymentId'], + FromState = data['FromState'], + ToState = data['ToState'] + ) + bus.handle(cmd) + else: + logger.info("unhandled:{}".format(channel)) if __name__ == "__main__":