summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
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)