summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2018-02-05 13:31:27 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2018-02-05 13:31:27 +0800
commitdf86145a053e46c5302fef9102bcc2f85abfb7ce (patch)
treefba50c85037dbab1958a8775755fa3591241fe85 /lcm
parent4843fc03ea373cd89c0b89324d9c18596081dfb4 (diff)
Fix vfc-vnflcm termination bug
Change-Id: I4ef7b47f1f0e1e513018878fd5c754f96ed3a15d Issue-ID: VFC-682 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py6
-rw-r--r--lcm/lcm/nf/vnfs/views.py9
2 files changed, 11 insertions, 4 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
index 228e9b1b..c2ce7055 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
@@ -119,8 +119,12 @@ class TestNFTerminate(TestCase):
@mock.patch.object(TermVnf, 'run')
def test_terminate_vnf(self, mock_run):
+ req_data = {
+ "terminationType": "GRACEFUL",
+ "gracefulTerminationTimeout": 120
+ }
mock_run.re.return_value = None
- response = self.client.post("/api/vnflcm/v1/vnf_instances/12/terminate", data={}, format='json')
+ response = self.client.post("/api/vnflcm/v1/vnf_instances/12/terminate", data=req_data, format='json')
self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
def test_terminate_vnf_when_inst_id_not_exist(self):
diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py
index 9f2b1fef..3f12648f 100644
--- a/lcm/lcm/nf/vnfs/views.py
+++ b/lcm/lcm/nf/vnfs/views.py
@@ -179,13 +179,16 @@ class TerminateVnf(APIView):
def post(self, request, instanceid):
logger.debug("TerminateVnf--post::> %s" % request.data)
try:
+ terminate_vnf_request_serializer = TerminateVnfRequestSerializer(data=request.data)
+ if not terminate_vnf_request_serializer.is_valid():
+ raise NFLCMException(terminate_vnf_request_serializer.errors)
+
job_id = JobUtil.create_job('NF', 'TERMINATE', instanceid)
JobUtil.add_job_status(job_id, 0, "TERM_VNF_READY")
- TermVnf(request.data, instanceid, job_id).start()
+ TermVnf(terminate_vnf_request_serializer.data, instanceid, job_id).start()
terminate_vnf_response_serializer = InstOrTeriVnfResponseSerializer(data={"jobId": job_id})
- resp_isvalid = terminate_vnf_response_serializer.is_valid()
- if not resp_isvalid:
+ if not terminate_vnf_response_serializer.is_valid():
raise NFLCMException(terminate_vnf_response_serializer.errors)
return Response(data=terminate_vnf_response_serializer.data, status=status.HTTP_202_ACCEPTED)