Code Review
/
vfc
/
gvnfm
/
vnflcm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
vfclcm upgrade from python2 to python3
[vfc/gvnfm/vnflcm.git]
/
lcm
/
lcm
/
nf
/
biz
/
scale_vnf.py
diff --git
a/lcm/lcm/nf/biz/scale_vnf.py
b/lcm/lcm/nf/biz/scale_vnf.py
index
dfabec2
..
2f5b31e
100644
(file)
--- a/
lcm/lcm/nf/biz/scale_vnf.py
+++ b/
lcm/lcm/nf/biz/scale_vnf.py
@@
-19,9
+19,11
@@
from threading import Thread
from lcm.nf.biz import common
from lcm.nf.biz.grant_vnf import grant_resource
from lcm.nf.biz import common
from lcm.nf.biz.grant_vnf import grant_resource
-from lcm.nf.const import
VNF_STATUS,
GRANT_TYPE, CHANGE_TYPE
+from lcm.nf.const import GRANT_TYPE, CHANGE_TYPE
from lcm.nf.const import RESOURCE_MAP, OPERATION_STATE_TYPE
from lcm.nf.const import INSTANTIATION_STATE
from lcm.nf.const import RESOURCE_MAP, OPERATION_STATE_TYPE
from lcm.nf.const import INSTANTIATION_STATE
+from lcm.nf.const import OPERATION_TYPE
+from lcm.nf.const import OPERATION_TASK
from lcm.pub.database.models import NfInstModel
from lcm.pub.database.models import VNFCInstModel, PortInstModel
from lcm.pub.database.models import VmInstModel
from lcm.pub.database.models import NfInstModel
from lcm.pub.database.models import VNFCInstModel, PortInstModel
from lcm.pub.database.models import VmInstModel
@@
-31,6
+33,7
@@
from lcm.pub.utils.values import ignore_case_get
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
from lcm.pub.vimapi import adaptor
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
from lcm.pub.vimapi import adaptor
+from .operate_vnf_lcm_op_occ import VnfLcmOpOcc
logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
@@
-44,30
+47,40
@@
class ScaleVnf(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.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.SCALE,
+ task=OPERATION_TASK.SCALE
+ )
+ self.op_type = OPERATION_TYPE.SCALE
def run(self):
try:
self.scale_pre()
def run(self):
try:
self.scale_pre()
+ self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.STARTING)
JobUtil.add_job_status(self.job_id,
50,
"Start to apply grant.")
self.apply_grant()
JobUtil.add_job_status(self.job_id,
50,
"Start to apply grant.")
self.apply_grant()
+ self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.PROCESSING)
JobUtil.add_job_status(self.job_id,
75,
"Start to scale Vnf.")
self.do_operation()
JobUtil.add_job_status(self.job_id,
75,
"Start to scale Vnf.")
self.do_operation()
+ self.send_notification()
JobUtil.add_job_status(self.job_id,
100,
"Scale Vnf success.")
self.vnf_insts.update(status=INSTANTIATION_STATE.INSTANTIATED,
lastuptime=now_time())
except NFLCMException as e:
JobUtil.add_job_status(self.job_id,
100,
"Scale Vnf success.")
self.vnf_insts.update(status=INSTANTIATION_STATE.INSTANTIATED,
lastuptime=now_time())
except NFLCMException as e:
- logger.error(e.
message
)
- self.vnf_scale_failed_handle(e.
message
)
+ logger.error(e.
args[0]
)
+ self.vnf_scale_failed_handle(e.
args[0]
)
except Exception as e:
except Exception as e:
- logger.error(e.
message
)
+ logger.error(e.
args[0]
)
logger.error(traceback.format_exc())
logger.error(traceback.format_exc())
- self.vnf_scale_failed_handle(e.
message
)
+ self.vnf_scale_failed_handle(e.
args[0]
)
def scale_pre(self):
self.scale_type = self.data.get("type")
def scale_pre(self):
self.scale_type = self.data.get("type")
@@
-183,7
+196,7
@@
class ScaleVnf(Thread):
def do_notify_del_vim_res(self, res_type, res_id):
logger.debug('Scaling in [%s] resource, resourceid [%s]', res_type, res_id)
def do_notify_del_vim_res(self, res_type, res_id):
logger.debug('Scaling in [%s] resource, resourceid [%s]', res_type, res_id)
- resource_type =
RESOURCE_MAP.keys()[RESOURCE_MAP.values(
).index(res_type)]
+ resource_type =
list(RESOURCE_MAP.keys())[list(RESOURCE_MAP.values()
).index(res_type)]
resource_table = globals().get(resource_type + 'InstModel')
resource_table.objects.filter(instid=self.nf_inst_id, resourceid=res_id).delete()
if res_type == "vm":
resource_table = globals().get(resource_type + 'InstModel')
resource_table.objects.filter(instid=self.nf_inst_id, resourceid=res_id).delete()
if res_type == "vm":
@@
-276,6
+289,7
@@
class ScaleVnf(Thread):
def vnf_scale_failed_handle(self, error_msg):
logger.error('VNF scaling failed, detail message: %s', error_msg)
def vnf_scale_failed_handle(self, error_msg):
logger.error('VNF scaling failed, detail message: %s', error_msg)
- self.vnf_insts.update(status=VNF_STATUS.FAILED,
- lastuptime=now_time())
+ self.vnf_insts.update( # status=VNF_STATUS.FAILED,
+ lastuptime=now_time())
+ self.lcm_op_occ.notify_lcm(OPERATION_STATE_TYPE.FAILED, error_msg)
JobUtil.add_job_status(self.job_id, 255, error_msg)
JobUtil.add_job_status(self.job_id, 255, error_msg)