diff options
author | maopeng zhang <zhang.maopeng1@zte.com.cn> | 2020-02-18 09:19:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-18 09:19:58 +0000 |
commit | b7d87af11036d724710a50116fd3edabe25afd5b (patch) | |
tree | 34bcecf77a134b6ff92440fc60044f37cb155d11 /catalog/packages | |
parent | 6215857a5a88907c2ba522b862992815e47f4960 (diff) | |
parent | 9812671ef6df484b944355bf5101732d5cf9ea03 (diff) |
Merge "modify filters to filter"
Diffstat (limited to 'catalog/packages')
-rw-r--r-- | catalog/packages/biz/notificationsutil.py | 10 | ||||
-rw-r--r-- | catalog/packages/biz/nsdm_subscription.py | 2 | ||||
-rw-r--r-- | catalog/packages/biz/vnf_pkg_subscription.py | 8 | ||||
-rw-r--r-- | catalog/packages/serializers/vnf_pkg_subscription.py | 2 | ||||
-rw-r--r-- | catalog/packages/tests/const.py | 2 |
5 files changed, 12 insertions, 12 deletions
diff --git a/catalog/packages/biz/notificationsutil.py b/catalog/packages/biz/notificationsutil.py index 8cdfd80..114f922 100644 --- a/catalog/packages/biz/notificationsutil.py +++ b/catalog/packages/biz/notificationsutil.py @@ -41,7 +41,7 @@ class NotificationsUtil(object): def send_notification(self): notification = self.prepare_notification() - subscriptions_filter = {v + "__contains": notification[k] for k, v in self.filters.items()} + subscriptions_filter = {v + "__contains": notification[k] for k, v in self.filter.items()} subscriptions_filter = remove_none_key(subscriptions_filter) logger.debug('send_notification subscriptions_filter = %s' % subscriptions_filter) q1 = Q() @@ -51,7 +51,7 @@ class NotificationsUtil(object): subscriptions = self.SubscriptionModel.objects.filter(q1) if not subscriptions.exists(): - logger.info("No subscriptions created for the filters %s" % notification) + logger.info("No subscriptions created for the filter %s" % notification) return logger.info("Start sending notifications") for sub in subscriptions: @@ -102,7 +102,7 @@ class NotificationsUtil(object): class PkgNotifications(NotificationsUtil): def __init__(self, notification_type, vnf_pkg_id, change_type=None, operational_state=None): super(PkgNotifications, self).__init__(notification_type) - self.filters = { + self.filter = { 'vnfdId': 'vnfd_id', 'vnfPkgId': 'vnf_pkg_id' } @@ -150,7 +150,7 @@ class PkgNotifications(NotificationsUtil): class NsdNotifications(NotificationsUtil): def __init__(self, notification_type, nsd_info_id, nsd_id, failure_details=None, operational_state=None): super(NsdNotifications, self).__init__(notification_type) - self.filters = { + self.filter = { 'nsdInfoId': 'nsdInfoId', 'nsdId': 'nsdId', } @@ -195,7 +195,7 @@ class NsdNotifications(NotificationsUtil): class PnfNotifications(NotificationsUtil): def __init__(self, notification_type, pnfd_info_id, pnfd_id, failure_details=None): super(PnfNotifications, self).__init__(notification_type) - self.filters = { + self.filter = { 'pnfdId': 'pnfdId', 'pnfdInfoIds': 'pnfdInfoIds', } diff --git a/catalog/packages/biz/nsdm_subscription.py b/catalog/packages/biz/nsdm_subscription.py index e2af6e4..652e9a7 100644 --- a/catalog/packages/biz/nsdm_subscription.py +++ b/catalog/packages/biz/nsdm_subscription.py @@ -76,7 +76,7 @@ class NsdmSubscription: for query, value in list(self.params.items()): if query in const.NSDM_NOTIFICATION_FILTERS and value: query_data[query + '__icontains'] = json.dumps(list(set(value))) - # Query the database with filters if the request + # Query the database with filter if the request # has fields in request params, else fetch all records if query_data: subscriptions = NsdmSubscriptionModel.objects.filter(**query_data) diff --git a/catalog/packages/biz/vnf_pkg_subscription.py b/catalog/packages/biz/vnf_pkg_subscription.py index 69ce2e8..6abe10e 100644 --- a/catalog/packages/biz/vnf_pkg_subscription.py +++ b/catalog/packages/biz/vnf_pkg_subscription.py @@ -48,7 +48,7 @@ class CreateSubscription(object): def __init__(self, data): self.data = data - self.filter = ignore_case_get(self.data, "filters", {}) + self.filter = ignore_case_get(self.data, "filter", {}) self.callback_uri = ignore_case_get(self.data, "callbackUri") self.authentication = ignore_case_get(self.data, "authentication", {}) self.notification_types = ignore_case_get(self.filter, "notificationTypes", []) @@ -104,7 +104,7 @@ class CreateSubscription(object): if not is_filter_type_equal(getattr(self, filter_type), ast.literal_eval(getattr(sub, filter_type))): return False - # If all the above types are same then check id filters + # If all the above types are same then check id filter for id_filter in ["vnfd_id", "vnf_pkg_id"]: if not is_filter_type_equal(getattr(self, id_filter), ast.literal_eval(getattr(sub, id_filter))): @@ -151,11 +151,11 @@ class QuerySubscription(object): def query_multi_subscriptions(self, params): query_data = {} logger.debug("QuerySubscription--get--multi--subscriptions--biz::> Check " - "for filters in query params %s" % params) + "for filter in query params %s" % params) for query, value in list(params.items()): if query in ROOT_FILTERS: query_data[ROOT_FILTERS[query] + '__icontains'] = value - # Query the database with filters if the request has fields in request params, else fetch all records + # Query the database with filter if the request has fields in request params, else fetch all records if query_data: subscriptions = VnfPkgSubscriptionModel.objects.filter(**query_data) else: diff --git a/catalog/packages/serializers/vnf_pkg_subscription.py b/catalog/packages/serializers/vnf_pkg_subscription.py index 8b98ca8..1c29ba0 100644 --- a/catalog/packages/serializers/vnf_pkg_subscription.py +++ b/catalog/packages/serializers/vnf_pkg_subscription.py @@ -39,7 +39,7 @@ class LinkSelfSerializer(serializers.Serializer): class PkgmSubscriptionRequestSerializer(serializers.Serializer): - filters = vnf_pkg_notifications.PkgmNotificationsFilter( + filter = vnf_pkg_notifications.PkgmNotificationsFilter( help_text="Filter settings for this subscription, " "to define the subset of all notifications" " this subscription relates to", diff --git a/catalog/packages/tests/const.py b/catalog/packages/tests/const.py index fc4869c..79cedfc 100644 --- a/catalog/packages/tests/const.py +++ b/catalog/packages/tests/const.py @@ -555,7 +555,7 @@ sd_data = { } vnf_subscription_data = { - "filters": { + "filter": { "notificationTypes": [ "VnfPackageOnboardingNotification" ], |