summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-04-05 17:30:13 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-04-05 17:30:13 +0800
commit10815c65561e07b6d3dae0aeb04f43904116401c (patch)
tree91fc9a3bcf2873d087cdedc3e492750b39fc8c88 /lcm
parent29b2066940c6b38af8a0a6b43ddc35ca07bd3d94 (diff)
Refactor codes for inst vnf
Change-Id: I619ff8d2bf6c8506079768c159448a10c6d05ca3 Issue-ID: VFC-1306 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/views/instantiate_vnf_view.py38
1 files changed, 15 insertions, 23 deletions
diff --git a/lcm/lcm/nf/views/instantiate_vnf_view.py b/lcm/lcm/nf/views/instantiate_vnf_view.py
index 3b4a3bee..1a7905aa 100644
--- a/lcm/lcm/nf/views/instantiate_vnf_view.py
+++ b/lcm/lcm/nf/views/instantiate_vnf_view.py
@@ -13,7 +13,6 @@
# limitations under the License.
import logging
-import traceback
from drf_yasg.utils import swagger_auto_schema
from lcm.nf.biz.instantiate_vnf import InstantiateVnf
@@ -39,25 +38,18 @@ class InstantiateVnfView(APIView):
)
def post(self, request, instanceid):
logger.debug("InstantiateVnf--post::> %s" % request.data)
- try:
- instantiate_vnf_request_serializer = InstantiateVnfRequestSerializer(data=request.data)
- if not instantiate_vnf_request_serializer.is_valid():
- raise NFLCMException(instantiate_vnf_request_serializer.errors)
-
- job_id = JobUtil.create_job('NF', 'INSTANTIATE', instanceid)
- JobUtil.add_job_status(job_id, 0, "INST_VNF_READY")
- InstantiateVnf(instantiate_vnf_request_serializer.data, instanceid, job_id).start()
-
- job_identifier_serializer = JobIdentifierSerializer(data={"jobId": job_id})
- resp_isvalid = job_identifier_serializer.is_valid()
- if not resp_isvalid:
- raise NFLCMException(job_identifier_serializer.errors)
-
- return Response(data=job_identifier_serializer.data, status=status.HTTP_202_ACCEPTED)
- except NFLCMException as e:
- logger.error(e.message)
- return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
- except Exception as e:
- logger.error(e.message)
- logger.error(traceback.format_exc())
- return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+ instantiate_vnf_request_serializer = InstantiateVnfRequestSerializer(data=request.data)
+ if not instantiate_vnf_request_serializer.is_valid():
+ raise NFLCMException(instantiate_vnf_request_serializer.errors)
+
+ job_id = JobUtil.create_job('NF', 'INSTANTIATE', instanceid)
+ JobUtil.add_job_status(job_id, 0, "INST_VNF_READY")
+ InstantiateVnf(instantiate_vnf_request_serializer.data, instanceid, job_id).start()
+
+ job_identifier_serializer = JobIdentifierSerializer(data={"jobId": job_id})
+ resp_isvalid = job_identifier_serializer.is_valid()
+ if not resp_isvalid:
+ raise NFLCMException(job_identifier_serializer.errors)
+
+ return Response(data=job_identifier_serializer.data, status=status.HTTP_202_ACCEPTED)