diff options
author | biancunkang <bian.cunkang@zte.com.cn> | 2018-08-10 09:48:52 +0800 |
---|---|---|
committer | biancunkang <bian.cunkang@zte.com.cn> | 2018-08-10 09:52:03 +0800 |
commit | 6dba09acb334b868eec0ccf84bd2267bec191532 (patch) | |
tree | 4584b034de119ded1ebd11f5ca26d0ad66b4c65b | |
parent | 1c6b6ddc07d5e54aabdbd017009368ccc0c0744e (diff) |
Modify job serializer
add job_identifier.py
Change-Id: I0aa811dc642a98d3fe48754df93b7d857e86b601
Issue-ID: VFC-1015
Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
-rw-r--r-- | lcm/lcm/nf/serializers/job_identifier.py | 23 | ||||
-rw-r--r-- | lcm/lcm/nf/views/terminate_vnf_view.py | 7 |
2 files changed, 27 insertions, 3 deletions
diff --git a/lcm/lcm/nf/serializers/job_identifier.py b/lcm/lcm/nf/serializers/job_identifier.py new file mode 100644 index 00000000..cfd06a63 --- /dev/null +++ b/lcm/lcm/nf/serializers/job_identifier.py @@ -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) diff --git a/lcm/lcm/nf/views/terminate_vnf_view.py b/lcm/lcm/nf/views/terminate_vnf_view.py index 8cd26467..c1903b76 100644 --- a/lcm/lcm/nf/views/terminate_vnf_view.py +++ b/lcm/lcm/nf/views/terminate_vnf_view.py @@ -21,7 +21,8 @@ from rest_framework.response import Response from rest_framework.views import APIView
from lcm.nf.biz.terminate_vnf import TerminateVnf
-from lcm.nf.serializers.serializers import InstOrTeriVnfResponseSerializer, TerminateVnfRequestSerializer
+from lcm.nf.serializers.terminate_vnf_req import TerminateVnfRequestSerializer
+from lcm.nf.serializers.job_identifier import JobIdentifierSerializer
from lcm.pub.exceptions import NFLCMException
from lcm.pub.utils.jobutil import JobUtil
@@ -33,7 +34,7 @@ class TerminateVnfView(APIView): @swagger_auto_schema(
request_body=TerminateVnfRequestSerializer(),
responses={
- status.HTTP_202_ACCEPTED: InstOrTeriVnfResponseSerializer(),
+ status.HTTP_202_ACCEPTED: JobIdentifierSerializer(),
status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
}
)
@@ -48,7 +49,7 @@ class TerminateVnfView(APIView): JobUtil.add_job_status(job_id, 0, "TERM_VNF_READY")
TerminateVnf(terminate_vnf_request_serializer.data, instanceid, job_id).start()
- terminate_vnf_response_serializer = InstOrTeriVnfResponseSerializer(data={"jobId": job_id})
+ terminate_vnf_response_serializer = JobIdentifierSerializer(data={"jobId": job_id})
if not terminate_vnf_response_serializer.is_valid():
raise NFLCMException(terminate_vnf_response_serializer.errors)
|