modify ns instance 31/96131/2
authorhewei-cmss <hewei@cmss.chinamobile.com>
Mon, 23 Sep 2019 07:31:59 +0000 (15:31 +0800)
committerhewei-cmss <hewei@cmss.chinamobile.com>
Mon, 14 Oct 2019 01:13:00 +0000 (09:13 +0800)
Issue-ID: VFC-1504

Signed-off-by: hewei-cmss <hewei@cmss.chinamobile.com>
Change-Id: Iada86c9dd52b72b9bb9566ce1956eaee9747438b

lcm/ns/biz/ns_instant.py
lcm/ns/views/deprecated/inst_ns_post_deal_view.py

index 203d590..e6f0d1b 100644 (file)
@@ -35,6 +35,7 @@ from lcm.pub.utils.values import ignore_case_get
 from lcm.workflows import build_in
 from lcm.ns.biz.ns_instantiate_flow import run_ns_instantiate
 from lcm.ns.biz.ns_lcm_op_occ import NsLcmOpOcc
+from lcm.ns.enum import NS_INST_STATUS
 
 logger = logging.getLogger(__name__)
 
@@ -57,6 +58,7 @@ class InstantNSService(object):
     def do_biz(self):
         job_id = JobUtil.create_job("NS", "NS_INST", self.ns_inst_id)
         occ_id = NsLcmOpOcc.create(self.ns_inst_id, "INSTANTIATE", "PROCESSING", False, self.req_data)
+        NSInstModel.objects.filter(id=self.ns_inst_id).update(status=NS_INST_STATUS.INSTANTIATING)
 
         try:
             logger.debug('ns-instant(%s) workflow starting...' % self.ns_inst_id)
@@ -176,6 +178,7 @@ class InstantNSService(object):
             logger.error("ns-instant(%s) workflow error:%s" % (self.ns_inst_id, e.args[0]))
             NsLcmOpOcc.update(occ_id, operationState="FAILED", error=e.args[0])
             JobUtil.add_job_status(job_id, 255, 'NS instantiation failed')
+            build_in.post_deal(self.ns_inst_id, "false")
             return dict(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
     def start_wso2_workflow(self, job_id, ns_inst, plan_input, occ_id):
index 5978d63..85a844d 100644 (file)
@@ -26,6 +26,7 @@ from lcm.pub.database.models import NSInstModel, ServiceBaseInfoModel
 from lcm.pub.exceptions import BadRequestException
 from lcm.pub.utils.restcall import req_by_msb
 from lcm.pub.utils.values import ignore_case_get
+from lcm.ns.enum import NS_INST_STATUS
 from .common import view_safe_call_with_log
 
 logger = logging.getLogger(__name__)
@@ -43,7 +44,7 @@ class NSInstPostDealView(APIView):
     def post(self, request, ns_instance_id):
         logger.debug("Enter NSInstPostDealView::post %s, %s", request.data, ns_instance_id)
         ns_post_status = ignore_case_get(request.data, 'status')
-        ns_status = 'ACTIVE' if ns_post_status == 'true' else 'FAILED'
+        ns_status = NS_INST_STATUS.ACTIVE if ns_post_status == 'true' else NS_INST_STATUS.FAILED
         ns_opr_status = 'success' if ns_post_status == 'true' else 'failed'
         try:
             req_serializer = _InstNsPostDealReqSerializer(data=request.data)