Merge "Fix the resource request handling with wrong resourcepoolId"
[pti/o2.git] / o2app / entrypoints / redis_eventconsumer.py
index 04ef31c..98e198b 100644 (file)
 #  limitations under the License.
 
 # import json
+
 import redis
 import json
 from o2app import bootstrap
 from o2common.config import config
-# from o2common.domain import commands
 from o2dms.domain import commands
 from o2ims.domain import commands as imscmd
+from o2ims.domain.subscription_obj import Message2SMO, RegistrationMessage
+from o2ims.domain.alarm_obj import AlarmEvent2SMO
 
 from o2common.helper import o2logging
-from o2ims.domain.subscription_obj import Message2SMO, NotificationEventEnum,\
-    RegistrationMessage
-from o2ims.domain.alarm_obj import AlarmEvent2SMO
 logger = o2logging.get_logger(__name__)
 
 r = redis.Redis(**config.get_redis_host_and_port())
@@ -39,7 +38,6 @@ def main():
     pubsub = r.pubsub(ignore_subscribe_messages=True)
     pubsub.subscribe("NfDeploymentStateChanged")
     pubsub.subscribe('ResourceChanged')
-    pubsub.subscribe('ConfigurationChanged')
     pubsub.subscribe('OcloudChanged')
     pubsub.subscribe('AlarmEventChanged')
 
@@ -75,19 +73,14 @@ def handle_changed(m, bus):
             eventtype=data['notificationEventType'],
             updatetime=data['updatetime']))
         bus.handle(cmd)
-    elif channel == 'ConfigurationChanged':
-        datastr = m['data']
-        data = json.loads(datastr)
-        logger.info('ConfigurationChanged with cmd:{}'.format(data))
-        cmd = imscmd.Register2SMO(data=RegistrationMessage(id=data['id']))
-        bus.handle(cmd)
     elif channel == 'OcloudChanged':
         datastr = m['data']
         data = json.loads(datastr)
         logger.info('OcloudChanged with cmd:{}'.format(data))
-        if data['notificationEventType'] == NotificationEventEnum.CREATE:
-            cmd = imscmd.Register2SMO(data=RegistrationMessage(is_all=True))
-            bus.handle(cmd)
+        cmd = imscmd.Register2SMO(data=RegistrationMessage(
+            data['notificationEventType'],
+            id=data['id']))
+        bus.handle(cmd)
     elif channel == 'AlarmEventChanged':
         datastr = m['data']
         data = json.loads(datastr)