+ callback_smo(sub, data, msg_type, dms_dict)
+
+
+def _notify_resource(uow, cmd):
+ data = cmd.data
+ msg_type = cmd.type
+ with uow:
+ resource = uow.resources.get(data.id)
+ if resource is None:
+ logger.warning('Resource {} does not exists.'.format(data.id))
+ return
+ res_pool_id = resource.serialize()['resourcePoolId']
+ logger.debug('res pool id is {}'.format(res_pool_id))
+
+ subs = uow.subscriptions.list()
+ for sub in subs:
+ sub_data = sub.serialize()
+ logger.debug('Subscription: {}'.format(sub_data['subscriptionId']))
+ if not sub_data.get('filter', None):
+ callback_smo(sub, data, msg_type)
+ continue
+ try:
+ args = gen_orm_filter(ocloud.Resource, sub_data['filter'])
+ except KeyError:
+ logger.warning(
+ 'Subscription {} filter {} has wrong attribute name '
+ 'or value. Ignore the filter.'.format(
+ sub_data['subscriptionId'], sub_data['filter']))
+ callback_smo(sub, data, msg_type)
+ continue
+ args.append(ocloud.Resource.resourceId == data.id)
+ ret = uow.resources.list_with_count(res_pool_id, *args)
+ if ret[0] != 0:
+ logger.debug(
+ 'Resource {} skip for subscription {} because of the '
+ 'filter.'
+ .format(data.id, sub_data['subscriptionId']))
+ continue
+ callback_smo(sub, data, msg_type)