summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-04-24 15:54:04 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-04-24 16:04:43 +0800
commitb644c9b0970c8a345abc1d0eee404e901efa5eac (patch)
treec06525c511a900abfb9246e94e3c748610dfda20 /lcm
parenta950cff842896b4a435fb17a5e6ffa3c40c2c46d (diff)
Add lcm op occ to chg flavour
Change-Id: I833293a5876dd51a4035b05e6043af10ed6c776f Issue-ID: VFC-1306 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/biz/change_vnf_flavour.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lcm/lcm/nf/biz/change_vnf_flavour.py b/lcm/lcm/nf/biz/change_vnf_flavour.py
index f4871688..7e1eaa7c 100644
--- a/lcm/lcm/nf/biz/change_vnf_flavour.py
+++ b/lcm/lcm/nf/biz/change_vnf_flavour.py
@@ -20,12 +20,15 @@ from threading import Thread
from lcm.nf.biz.grant_vnf import grant_resource
from lcm.nf.const import GRANT_TYPE, CHANGE_TYPE
from lcm.nf.const import VNF_STATUS
+from lcm.nf.const import OPERATION_TYPE, OPERATION_TASK
+from lcm.nf.const import OPERATION_STATE_TYPE
from lcm.pub.utils.notificationsutil import NotificationsUtil, prepare_notification_data
from lcm.pub.utils.values import ignore_case_get
from lcm.pub.utils.timeutil import now_time
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.exceptions import NFLCMException
from lcm.pub.database.models import NfInstModel
+from .operate_vnf_lcm_op_occ import VnfLcmOpOcc
logger = logging.getLogger(__name__)
@@ -37,13 +40,21 @@ class ChangeVnfFlavour(Thread):
self.nf_inst_id = nf_inst_id
self.job_id = job_id
self.vnf_insts = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
+ self.lcm_op_occ = VnfLcmOpOcc(
+ vnf_inst_id=nf_inst_id,
+ lcm_op_id=job_id,
+ operation=OPERATION_TYPE.CHANGE_FLAVOUR,
+ task=OPERATION_TASK.CHANGE_FLAVOUR
+ )
def run(self):
try:
+ self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.STARTING)
JobUtil.add_job_status(self.job_id,
10,
"Start to apply grant.")
self.apply_grant()
+ self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.PROCESSING)
JobUtil.add_job_status(self.job_id,
50,
"Start to change vnf flavour.")
@@ -53,6 +64,7 @@ class ChangeVnfFlavour(Thread):
lastuptime=now_time()
)
self.send_notification()
+ self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.COMPLETED)
JobUtil.add_job_status(self.job_id,
100,
"Change vnf flavour success.")
@@ -91,4 +103,5 @@ class ChangeVnfFlavour(Thread):
logger.error('Chnage vnf flavour failed, detail message: %s', error_msg)
self.vnf_insts.update(status=VNF_STATUS.FAILED,
lastuptime=now_time())
+ self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.FAILED)
JobUtil.add_job_status(self.job_id, 255, error_msg)