Modify job serializer 43/59943/1
authorbiancunkang <bian.cunkang@zte.com.cn>
Fri, 10 Aug 2018 01:48:52 +0000 (09:48 +0800)
committerbiancunkang <bian.cunkang@zte.com.cn>
Fri, 10 Aug 2018 01:52:03 +0000 (09:52 +0800)
add job_identifier.py

Change-Id: I0aa811dc642a98d3fe48754df93b7d857e86b601
Issue-ID: VFC-1015
Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
lcm/lcm/nf/serializers/job_identifier.py [new file with mode: 0644]
lcm/lcm/nf/views/terminate_vnf_view.py

diff --git a/lcm/lcm/nf/serializers/job_identifier.py b/lcm/lcm/nf/serializers/job_identifier.py
new file mode 100644 (file)
index 0000000..cfd06a6
--- /dev/null
@@ -0,0 +1,23 @@
+# Copyright 2018 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from rest_framework import serializers
+
+
+class JobIdentifierSerializer(serializers.Serializer):
+    jobId = serializers.CharField(
+        help_text="jobId",
+        required=True,
+        max_length=255,
+        allow_null=True)
index 8cd2646..c1903b7 100644 (file)
@@ -21,7 +21,8 @@ from rest_framework.response import Response
 from rest_framework.views import APIView\r
 \r
 from lcm.nf.biz.terminate_vnf import TerminateVnf\r
-from lcm.nf.serializers.serializers import InstOrTeriVnfResponseSerializer, TerminateVnfRequestSerializer\r
+from lcm.nf.serializers.terminate_vnf_req import TerminateVnfRequestSerializer\r
+from lcm.nf.serializers.job_identifier import JobIdentifierSerializer\r
 from lcm.pub.exceptions import NFLCMException\r
 from lcm.pub.utils.jobutil import JobUtil\r
 \r
@@ -33,7 +34,7 @@ class TerminateVnfView(APIView):
     @swagger_auto_schema(\r
         request_body=TerminateVnfRequestSerializer(),\r
         responses={\r
-            status.HTTP_202_ACCEPTED: InstOrTeriVnfResponseSerializer(),\r
+            status.HTTP_202_ACCEPTED: JobIdentifierSerializer(),\r
             status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"\r
         }\r
     )\r
@@ -48,7 +49,7 @@ class TerminateVnfView(APIView):
             JobUtil.add_job_status(job_id, 0, "TERM_VNF_READY")\r
             TerminateVnf(terminate_vnf_request_serializer.data, instanceid, job_id).start()\r
 \r
-            terminate_vnf_response_serializer = InstOrTeriVnfResponseSerializer(data={"jobId": job_id})\r
+            terminate_vnf_response_serializer = JobIdentifierSerializer(data={"jobId": job_id})\r
             if not terminate_vnf_response_serializer.is_valid():\r
                 raise NFLCMException(terminate_vnf_response_serializer.errors)\r
 \r