summaryrefslogtreecommitdiffstats
path: root/lcm/lcm/nf/biz
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-04-11 12:03:13 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-04-11 12:03:13 +0800
commitb92d2628810369f70705737e12100ac246b7278a (patch)
treed0d06a6cfa4b021aa8b48cbcea1b03e24f860938 /lcm/lcm/nf/biz
parent9f562b86973f080d392d10db2655b80d74826a4e (diff)
Add ut cases for update vnf
Change-Id: I830453076392fe5dc33b3c61d2709ffea2283b0c 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.py44
1 files changed, 31 insertions, 13 deletions
diff --git a/lcm/lcm/nf/biz/update_vnf.py b/lcm/lcm/nf/biz/update_vnf.py
index 0721c5d9..311c24aa 100644
--- a/lcm/lcm/nf/biz/update_vnf.py
+++ b/lcm/lcm/nf/biz/update_vnf.py
@@ -12,13 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
+import traceback
from threading import Thread
from lcm.pub.database.models import NfInstModel
+from lcm.pub.exceptions import NFLCMException
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.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
logger = logging.getLogger(__name__)
@@ -34,19 +37,34 @@ class UpdateVnf(Thread):
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())
+ try:
+ JobUtil.add_job_status(self.job_id, 50, "Start updating VNF.")
+
+ 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())
+
+ JobUtil.add_job_status(self.job_id, 75, "Start sending notification.")
+ self.send_notification()
+
+ JobUtil.add_job_status(self.job_id, 100, "Update VNF success.")
+ except NFLCMException as e:
+ logger.error(e.message)
+ JobUtil.add_job_status(self.job_id, 255, e.message)
+ except Exception as e:
+ logger.error(e.message)
+ logger.error(traceback.format_exc())
+ JobUtil.add_job_status(self.job_id, 255, e.message)
def send_notification(self):
notify_data = prepare_notification(nfinstid=self.nf_inst_id,