diff options
author | egernug <gerard.nugent@est.tech> | 2021-12-06 13:11:15 +0000 |
---|---|---|
committer | egernug <gerard.nugent@est.tech> | 2021-12-09 12:56:03 +0000 |
commit | 15dde94eccad074dda76c420f900c977c184b66f (patch) | |
tree | 263bc1ac72ca91311a0b77aeb5e49a8292d71965 | |
parent | 10aa7f851d2256c5b158f8b4c5d3e2756890f7b7 (diff) |
[PMSH] Add NF list to the Read by Subname call
Issue-ID: DCAEGEN2-2992
Add the list of NFs when a request is made for a subscription. This will assist with testing and visibility for the user.
Change-Id: I6061f1dd1cbc6c579e98605c1d7bcbcea3c4e77b
Signed-off-by: egernug <gerard.nugent@est.tech>
5 files changed, 9 insertions, 2 deletions
diff --git a/components/pm-subscription-handler/Changelog.md b/components/pm-subscription-handler/Changelog.md index 8e0ee2f9..b3468736 100755 --- a/components/pm-subscription-handler/Changelog.md +++ b/components/pm-subscription-handler/Changelog.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Read subscription API by using subscription name (DCAEGEN2-2818) * Read All subscriptions API (DCAEGEN2-2847) * PMSH Response Event Handler Integration (DCAEGEN2-2915) +* Updated to get NFs list when requesting a specific subscription (DCAEGEN2-2992) ## [1.3.2] ### Changed diff --git a/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py b/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py index 96a803ba..9ecc80e6 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py +++ b/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py @@ -67,6 +67,7 @@ class SubscriptionModel(db.Model): 'operationalPolicyName': self.operational_policy_name, 'controlLoopName': self.control_loop_name, 'nfFilter': self.network_filter.serialize(), + 'nfs': [nf.nf_name for nf in self.nfs], 'measurementGroups': [mg.serialize() for mg in self.measurement_groups]}} diff --git a/components/pm-subscription-handler/pmsh_service/mod/api/services/subscription_service.py b/components/pm-subscription-handler/pmsh_service/mod/api/services/subscription_service.py index c33c82fb..73467821 100644 --- a/components/pm-subscription-handler/pmsh_service/mod/api/services/subscription_service.py +++ b/components/pm-subscription-handler/pmsh_service/mod/api/services/subscription_service.py @@ -306,7 +306,8 @@ def query_subscription_by_name(subscription_name): logger.info(f'Attempting to fetch subscription by name: {subscription_name}') subscription_model = db.session.query(SubscriptionModel) \ .options(joinedload(SubscriptionModel.network_filter), - joinedload(SubscriptionModel.measurement_groups)) \ + joinedload(SubscriptionModel.measurement_groups), + joinedload(SubscriptionModel.nfs)) \ .filter_by(subscription_name=subscription_name).first() db.session.remove() return subscription_model diff --git a/components/pm-subscription-handler/tests/base_setup.py b/components/pm-subscription-handler/tests/base_setup.py index be7d1b8f..33e2e91b 100755 --- a/components/pm-subscription-handler/tests/base_setup.py +++ b/components/pm-subscription-handler/tests/base_setup.py @@ -22,7 +22,7 @@ from unittest import TestCase from unittest.mock import patch, MagicMock from mod import create_app, db -from mod.api.db_models import NetworkFunctionFilterModel, MeasurementGroupModel, SubscriptionModel +from mod.api.db_models import NetworkFunctionFilterModel, MeasurementGroupModel, SubscriptionModel, NfSubRelationalModel from mod.network_function import NetworkFunctionFilter from mod.pmsh_utils import AppConfig from mod.pmsh_config import AppConfig as NewAppConfig @@ -66,6 +66,9 @@ def create_subscription_data(subscription_name): 'pmsh_control_loop_name', 'LOCKED') subscription_model.network_filter = nf_filter subscription_model.measurement_groups = mg_list + nf1 = NfSubRelationalModel(subscription_name, "pnf_101", "LOCKED") + nf2 = NfSubRelationalModel(subscription_name, "pnf_102", "LOCKED") + subscription_model.nfs = [nf1, nf2] return subscription_model diff --git a/components/pm-subscription-handler/tests/services/test_subscription_service.py b/components/pm-subscription-handler/tests/services/test_subscription_service.py index 8f3f0f4f..44fb4eff 100644 --- a/components/pm-subscription-handler/tests/services/test_subscription_service.py +++ b/components/pm-subscription-handler/tests/services/test_subscription_service.py @@ -370,6 +370,7 @@ class SubscriptionServiceTestCase(BaseClassSetup): ['measurementGroupName'], 'MG1') self.assertEqual(len(subs[1]['subscription']['measurementGroups']), 2) self.assertEqual(len(subs), 2) + self.assertEqual(len(subs[0]['subscription']['nfs']), 2) @patch('mod.api.services.subscription_service.query_all_subscriptions', MagicMock(return_value=[])) |