summaryrefslogtreecommitdiffstats
path: root/lcm/lcm/nf/biz
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-04-03 14:49:30 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-04-03 14:56:44 +0800
commit493ef37c5865cf551644b9cadb3ee01dbf181ae0 (patch)
treebe3cac37517be8be2798af9ab9274c5153fa9460 /lcm/lcm/nf/biz
parent963ef90e1a289a541524b7eb218531bfc982562e (diff)
Add logic for upd vnf
Change-Id: Ide1d75e1bdad76fac160e34195e3a5f23a888397 Issue-ID: VFC-1306 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm/lcm/nf/biz')
-rw-r--r--lcm/lcm/nf/biz/update_vnf.py38
1 files changed, 37 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)