From: Zhang Rong(Jon) Date: Tue, 29 Nov 2022 14:03:33 +0000 (+0800) Subject: Fix priorObjectState and postObjectState to string type; fix only objectType in filte... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=7057b7c3d9dd4a397968baa2917c5bcff51aecaa;p=pti%2Fo2.git Fix priorObjectState and postObjectState to string type; fix only objectType in filter; fix logger level Signed-off-by: Zhang Rong(Jon) Change-Id: I52f7440061810fc08d4bd4730a816684925537c6 --- diff --git a/o2ims/service/command/notify_alarm_handler.py b/o2ims/service/command/notify_alarm_handler.py index d5e049e..dd32b96 100644 --- a/o2ims/service/command/notify_alarm_handler.py +++ b/o2ims/service/command/notify_alarm_handler.py @@ -43,7 +43,7 @@ def notify_alarm_to_smo( with uow: alarm = uow.alarm_event_records.get(data.id) if alarm is None: - logger.debug('Alarm Event {} does not exists.'.format(data.id)) + logger.warning('Alarm Event {} does not exists.'.format(data.id)) return subs = uow.alarm_subscriptions.list() @@ -99,8 +99,8 @@ def callback_smo(sub: AlarmSubscription, msg: AlarmEvent2SMO, } # logger.warning(callback) callback_data = json.dumps(callback) - logger.info('URL: {}, data: {}'.format( - sub_data['callback'], callback_data)) + logger.info('URL: {}'.format(sub_data['callback'])) + logger.debug('callback data: {}'.format(callback_data)) o = urlparse(sub_data['callback']) if o.scheme == 'https': diff --git a/o2ims/service/command/notify_handler.py b/o2ims/service/command/notify_handler.py index 01c91c5..947942f 100644 --- a/o2ims/service/command/notify_handler.py +++ b/o2ims/service/command/notify_handler.py @@ -89,8 +89,9 @@ def _notify_resourcetype(uow, data): sub_data['subscriptionId'], sub_data['filter'])) continue - if len(args) == 0: - continue + if len(args) == 0 and 'objectType' in filter: + filter_effect += 1 + break args.append(ocloud.ResourceType.resourceTypeId == data.id) ret = uow.resource_types.list_with_count(*args) if ret[0] > 0: @@ -138,8 +139,9 @@ def _notify_resourcepool(uow, data): sub_data['subscriptionId'], sub_data['filter'])) continue - if len(args) == 0: - continue + if len(args) == 0 and 'objectType' in filter: + filter_effect += 1 + break args.append(ocloud.ResourcePool.resourcePoolId == data.id) ret = uow.resource_pools.list_with_count(*args) if ret[0] > 0: @@ -189,8 +191,9 @@ def _notify_dms(uow, data): sub_data['subscriptionId'], sub_data['filter'])) continue - if len(args) == 0: - continue + if len(args) == 0 and 'objectType' in filter: + filter_effect += 1 + break args.append( ocloud.DeploymentManager.deploymentManagerId == data.id) ret = uow.deployment_managers.list_with_count(*args) @@ -241,8 +244,9 @@ def _notify_resource(uow, data): sub_data['subscriptionId'], sub_data['filter'])) continue - if len(args) == 0: - continue + if len(args) == 0 and 'objectType' in filter: + filter_effect += 1 + break args.append(ocloud.Resource.resourceId == data.id) ret = uow.resources.list_with_count(res_pool_id, *args) if ret[0] > 0: @@ -294,15 +298,15 @@ def callback_smo(sub: Subscription, msg: Message2SMO, obj_dict: dict = None): } if msg.notificationEventType in [NotificationEventEnum.DELETE, NotificationEventEnum.MODIFY]: - callback['priorObjectState'] = obj_dict + callback['priorObjectState'] = json.dumps(obj_dict) if msg.notificationEventType in [NotificationEventEnum.CREATE, NotificationEventEnum.MODIFY]: - callback['postObjectState'] = obj_dict + callback['postObjectState'] = json.dumps(obj_dict) if msg.notificationEventType == NotificationEventEnum.DELETE: callback.pop('objectRef') callback_data = json.dumps(callback) - logger.info('URL: {}, data: {}'.format( - sub_data['callback'], callback_data)) + logger.info('URL: {}'.format(sub_data['callback'])) + logger.debug('callback data: {}'.format(callback_data)) # Call SMO through the SMO callback url o = urlparse(sub_data['callback'])