X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fnf%2Fviews%2Fcommon.py;h=6bab28fb8a6e9eaef8d627fa635f136d62202893;hb=46ad7c172411214c5432ed93fda4271288077447;hp=57e6a6219cf6e4ab6277111e1ffd72485bec4db6;hpb=97ce57eed00e679487079b3ca5dc18ca65e8dc11;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/nf/views/common.py b/lcm/lcm/nf/views/common.py index 57e6a621..6bab28fb 100644 --- a/lcm/lcm/nf/views/common.py +++ b/lcm/lcm/nf/views/common.py @@ -51,43 +51,43 @@ def view_safe_call_with_log(logger): try: return func(*args, **kwargs) except NFLCMExceptionSeeOther as e: - logger.error(e.message) + logger.error(e.args[0]) resp = Response(status=status.HTTP_303_SEE_OTHER) - resp["Location"] = "" + resp["Location"] = e.args[0] # resp["Location"] = "subscriptions/%s" % e.id return resp except NFLCMExceptionNotFound as e: - logger.error(e.message) + logger.error(e.args[0]) return make_error_resp( - detail=e.message, + detail=e.args[0], status=status.HTTP_404_NOT_FOUND ) except NFLCMExceptionBadRequest as e: - logger.error(e.message) + logger.error(e.args[0]) return make_error_resp( - detail=e.message, + detail=e.args[0], status=status.HTTP_400_BAD_REQUEST ) except NFLCMExceptionConflict as e: - logger.error(e.message) + logger.error(e.args[0]) return make_error_resp( - detail=e.message, + detail=e.args[0], status=status.HTTP_409_CONFLICT ) except NFLCMExceptionPreconditionFailed as e: - logger.error(e.message) + logger.error(e.args[0]) return make_error_resp( - detail=e.message, + detail=e.args[0], status=status.HTTP_412_PRECONDITION_FAILED ) except NFLCMException as e: - logger.error(e.message) + logger.error(e.args[0]) return make_error_resp( - detail=e.message, + detail=e.args[0], status=status.HTTP_500_INTERNAL_SERVER_ERROR ) except Exception as e: - logger.error(e.message) + logger.error(e.args[0]) logger.error(traceback.format_exc()) return make_error_resp( detail='Unexpected exception', @@ -103,7 +103,7 @@ def deal_vnf_action(logger, opt_type, opt_status, instid, req, req_serializer, a act_vnf_req_serializer = req_serializer(data=req.data) if not act_vnf_req_serializer.is_valid(): - raise NFLCMException(act_vnf_req_serializer.errors) + raise NFLCMExceptionBadRequest(act_vnf_req_serializer.errors) vnf_insts = NfInstModel.objects.filter(nfinstid=instid) if not vnf_insts.exists(): @@ -117,21 +117,20 @@ def deal_vnf_action(logger, opt_type, opt_status, instid, req, req_serializer, a raise NFLCMExceptionConflict("VNF(%s) is not INSTANTIATED." % instid) req_etag = None - is_upd_vnf_opt = (opt_type == "UpdateVnf") - if is_upd_vnf_opt: + if opt_type == OPERATION_TYPE.MODIFY_INFO: req_etag = req.META.get("HTTP_IF_MATCH") logger.debug("req_etag=%s, CACHE_ETAG=%s", req_etag, CACHE_ETAG) - if req_etag != CACHE_ETAG: + if req_etag and req_etag != CACHE_ETAG: raise NFLCMExceptionPreconditionFailed("Etag mismatch") job_id = JobUtil.create_job('NF', opt_type, instid) JobUtil.add_job_status(job_id, 0, "VNF_%s_READY" % opt_type) - vnf_insts.update(status=opt_status) + # vnf_insts.update(status=opt_status) act_task(req.data, instid, job_id).start() resp = Response(data={"jobId": job_id}, status=status.HTTP_202_ACCEPTED) - if is_upd_vnf_opt: + if opt_type == OPERATION_TYPE.MODIFY_INFO: resp["ETag"] = req_etag return resp @@ -144,7 +143,7 @@ def deal_indivdual_query(res_serializer, query_fun, *args): if not resp_serializer.is_valid(): raise NFLCMException(resp_serializer.errors) - resp = Response(data=resp_serializer.data, status=status.HTTP_200_OK) + resp = Response(data=res, status=status.HTTP_200_OK) if res_serializer == VnfInstanceSerializer: CACHE_ETAG = "%s" % uuid.uuid1() logger.debug("set CACHE_ETAG = %s", CACHE_ETAG)