aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-02-07 13:59:40 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-02-07 13:59:40 +0800
commit8eed2283a9e405e8839304e5a85efb656c0e6393 (patch)
tree79877582271203403827f2442c12a9f7d46103ad
parent87fbe80289c9c974b7c8485c7fc8be00d314aa21 (diff)
Add notify vnf swagger generate logic
Change-Id: Ie2456cc9bad31d40362f1b6ce56a518aaa922de6 Issue-ID: VFC-714 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/ns/vnfs/views.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/lcm/ns/vnfs/views.py b/lcm/ns/vnfs/views.py
index 963fe7d7..45d46f42 100644
--- a/lcm/ns/vnfs/views.py
+++ b/lcm/ns/vnfs/views.py
@@ -39,6 +39,7 @@ from lcm.ns.vnfs.serializers import TerminateVnfReqSerializer
from lcm.ns.vnfs.serializers import TerminateVnfRespSerializer
from lcm.ns.vnfs.serializers import GrantVnfReqSerializer
from lcm.ns.vnfs.serializers import GrantVnfRespSerializer
+from lcm.ns.vnfs.serializers import NotifyLcmReqSerializer
logger = logging.getLogger(__name__)
@@ -173,10 +174,20 @@ class NfGrant(APIView):
class LcmNotify(APIView):
- def post(self, request_paras, vnfmid, vnfInstanceId):
- logger.debug("LcmNotify--post::> %s" % request_paras.data)
+ @swagger_auto_schema(
+ request_body=NotifyLcmReqSerializer(),
+ responses={
+ status.HTTP_201_CREATED: None,
+ status.HTTP_409_CONFLICT: "Inner error"
+ }
+ )
+ def post(self, request, vnfmid, vnfInstanceId):
+ logger.debug("LcmNotify--post::> %s" % request.data)
try:
- NotifyLcm(vnfmid, vnfInstanceId, request_paras.data).do_biz()
+ req_serializer = NotifyLcmReqSerializer(data=request.data)
+ if not req_serializer.is_valid():
+ raise Exception(req_serializer.errors)
+ NotifyLcm(vnfmid, vnfInstanceId, request.data).do_biz()
return Response(data={}, status=status.HTTP_201_CREATED)
except Exception as e:
logger.error(e.message)