summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/network_function.py
diff options
context:
space:
mode:
authoremartin <ephraim.martin@est.tech>2020-02-24 14:13:03 +0000
committeremartin <ephraim.martin@est.tech>2020-02-26 15:25:50 +0000
commite7f6914ca5397987eddc6788a6e378c51b12ce52 (patch)
tree1c4a1015afa1030ee3e75fdf78c282a2ce994433 /components/pm-subscription-handler/pmsh_service/mod/network_function.py
parentde549f5f1bb3e0a6f94e9755ae0800b469114113 (diff)
Handle AAI Update and Delete events for PMSH
Change-Id: I7f84e4429011bbaea4de23077ce23629b897fd7d Issue-ID: DCAEGEN2-1846 Signed-off-by: emartin <ephraim.martin@est.tech>
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/network_function.py')
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/network_function.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/network_function.py b/components/pm-subscription-handler/pmsh_service/mod/network_function.py
index 9f21cc66..c4b9b56c 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py
@@ -32,6 +32,13 @@ class NetworkFunction:
def __str__(self):
return f'nf-name: {self.nf_name}, orchestration-status: {self.orchestration_status}'
+ def __eq__(self, other):
+ return self.nf_name == other.nf_name and \
+ self.orchestration_status == other.orchestration_status
+
+ def __hash__(self):
+ return hash((self.nf_name, self.orchestration_status))
+
def create(self):
""" Creates a NetworkFunction database entry """
existing_nf = NetworkFunctionModel.query.filter(
@@ -72,8 +79,7 @@ class NetworkFunction:
def delete(**kwargs):
""" Deletes a network function from the database """
nf_name = kwargs['nf_name']
- NetworkFunctionModel.query.filter(
- NetworkFunctionModel.nf_name == nf_name). \
- delete(synchronize_session='evaluate')
+ nf = NetworkFunctionModel.query.filter(
+ NetworkFunctionModel.nf_name == nf_name).one_or_none()
- db.session.commit()
+ db.session.delete(nf) if nf else None