summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/lcm/nf/biz/update_vnf.py38
-rw-r--r--lcm/lcm/nf/views/curd_vnf_views.py2
2 files changed, 39 insertions, 1 deletions
diff --git a/lcm/lcm/nf/biz/update_vnf.py b/lcm/lcm/nf/biz/update_vnf.py
index 4a21140f..0721c5d9 100644
--- a/lcm/lcm/nf/biz/update_vnf.py
+++ b/lcm/lcm/nf/biz/update_vnf.py
@@ -1,4 +1,4 @@
-# Copyright 2017 ZTE Corporation.
+# Copyright 2019 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,6 +14,13 @@
import logging
from threading import Thread
+from lcm.pub.database.models import NfInstModel
+from lcm.nf.const import OPERATION_STATE_TYPE
+from lcm.nf.const import OPERATION_TYPE
+from lcm.pub.utils.notificationsutil import NotificationsUtil
+from lcm.pub.utils.notificationsutil import prepare_notification
+from lcm.pub.utils.timeutil import now_time
+
logger = logging.getLogger(__name__)
@@ -22,6 +29,35 @@ class UpdateVnf(Thread):
self.data = data
self.nf_inst_id = instanceid
self.job_id = job_id
+ self.vnf_insts = NfInstModel.objects.filter(nfinstid=instanceid)
def run(self):
logger.debug("start update for vnf %s", self.nf_inst_id)
+ key = "vnfInstanceName"
+ if key in self.data and self.data[key] is not None:
+ self.vnf_insts.update(nf_name=self.data[key],
+ lastuptime=now_time())
+
+ key = "vnfInstanceDescription"
+ if key in self.data and self.data[key] is not None:
+ self.vnf_insts.update(nf_desc=self.data[key],
+ lastuptime=now_time())
+
+ key = "vnfPkgId"
+ if key in self.data:
+ self.vnf_insts.update(vnfdid=self.data[key],
+ lastuptime=now_time())
+
+ def send_notification(self):
+ notify_data = prepare_notification(nfinstid=self.nf_inst_id,
+ jobid=self.job_id,
+ operation=OPERATION_TYPE.MODIFY_INFO,
+ operation_state=OPERATION_STATE_TYPE.COMPLETED)
+
+ notify_data["changedInfo"] = {}
+ for key in ("vnfInstanceName", "vnfInstanceDescription"):
+ if key in self.data and self.data[key] is not None:
+ notify_data["changedInfo"][key] = self.data[key]
+
+ logger.debug('Notification data: %s' % notify_data)
+ NotificationsUtil().send_notification(notify_data)
diff --git a/lcm/lcm/nf/views/curd_vnf_views.py b/lcm/lcm/nf/views/curd_vnf_views.py
index ea5d4289..abd6c62c 100644
--- a/lcm/lcm/nf/views/curd_vnf_views.py
+++ b/lcm/lcm/nf/views/curd_vnf_views.py
@@ -175,6 +175,8 @@ class DeleteVnfAndQueryVnf(APIView):
logger.error(e.message)
logger.error('Update VNF instance[%s] failed' % instanceid)
return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ except NFLCMExceptionNotFound as e:
+ return Response(data={'error': '%s' % e.message}, status=status.HTTP_404_NOT_FOUND)
except Exception as e:
logger.error(e.message)
logger.error(traceback.format_exc())