diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-22 14:55:02 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2019-04-22 15:06:56 +0800 |
commit | c9c20b831923443196e945a25ee16c3db7eafe5a (patch) | |
tree | fc4759066815725de97e1faea969ea8ac14bcfb0 /lcm | |
parent | bc82e6770245e30a8f2396975a3f52c1ca12e451 (diff) |
Add ETag for vnf get
Change-Id: I4918ba5a193c4b12782e0a9508acf5d40553fea5
Issue-ID: VFC-1306
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf/views/common.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lcm/lcm/nf/views/common.py b/lcm/lcm/nf/views/common.py index 0d3222db..8f353694 100644 --- a/lcm/lcm/nf/views/common.py +++ b/lcm/lcm/nf/views/common.py @@ -14,6 +14,7 @@ import traceback import logging +import uuid from rest_framework import status from rest_framework.response import Response @@ -27,9 +28,12 @@ from lcm.pub.exceptions import NFLCMExceptionSeeOther from lcm.pub.database.models import NfInstModel from lcm.pub.utils.jobutil import JobUtil from lcm.nf.const import OPERATION_TYPE +from lcm.nf.serializers.vnf_instance import VnfInstanceSerializer logger = logging.getLogger(__name__) +CACHE_ETAG = None + def make_error_resp(status, detail): return Response( @@ -121,9 +125,16 @@ def deal_vnf_action(logger, opt_type, opt_status, instid, req, req_serializer, a def deal_indivdual_query(res_serializer, query_fun, *args): + global CACHE_ETAG + res = query_fun(*args) resp_serializer = res_serializer(data=res) if not resp_serializer.is_valid(): raise NFLCMException(resp_serializer.errors) - return Response(data=resp_serializer.data, status=status.HTTP_200_OK) + resp = Response(data=resp_serializer.data, status=status.HTTP_200_OK) + if res_serializer == VnfInstanceSerializer: + CACHE_ETAG = "%s" % uuid.uuid1() + logger.debug("set CACHE_ETAG = %s", CACHE_ETAG) + resp["ETag"] = CACHE_ETAG + return resp |