From e47257b82be1034ad205c676332071f6842e3702 Mon Sep 17 00:00:00 2001 From: fujinhua Date: Mon, 22 Apr 2019 14:07:25 +0800 Subject: Add Indivdual query common fun Change-Id: I3070c2a8e0f5074a32899334cdc0fcd3aac8a62a Issue-ID: VFC-1306 Signed-off-by: fujinhua --- lcm/lcm/nf/views/common.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lcm/lcm/nf/views/common.py b/lcm/lcm/nf/views/common.py index 9e039a97..0d3222db 100644 --- a/lcm/lcm/nf/views/common.py +++ b/lcm/lcm/nf/views/common.py @@ -118,3 +118,12 @@ def deal_vnf_action(logger, opt_type, opt_status, instid, req, req_serializer, a act_task(req.data, instid, job_id).start() return Response(data={"jobId": job_id}, status=status.HTTP_202_ACCEPTED) + + +def deal_indivdual_query(res_serializer, query_fun, *args): + 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) -- cgit 1.2.3-korg