X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fnf%2Fvnfs%2Fviews.py;h=2330fa2cbc00b4c049cb62ede3718426390bf49e;hb=8caba28ed1db2c346185b2e7549cb4eb8be0778e;hp=ef997f056ed2b298103863983d04a127d7e7e82b;hpb=4571e2dd027035cca42d27dc0f8f0c2c94a3e019;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py index ef997f05..2330fa2c 100644 --- a/lcm/lcm/nf/vnfs/views.py +++ b/lcm/lcm/nf/vnfs/views.py @@ -11,9 +11,8 @@ # 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. -import json + import logging -import os import traceback from rest_framework import status @@ -61,8 +60,8 @@ class CreateVnfAndQueryVnfs(APIView): class InstantiateVnf(APIView): def post(self, request, instanceid): + logger.debug("InstantiateVnf--post::> %s" % request.data) try: - logger.debug("InstantiateVnf--post::> %s" % request.data) job_id = JobUtil.create_job('NF', 'INSTANTIATE', instanceid) JobUtil.add_job_status(job_id, 0, "INST_VNF_READY") InstVnf(request.data, instanceid, job_id).start() @@ -106,23 +105,15 @@ class DeleteVnfAndQueryVnf(APIView): class TerminateVnf(APIView): def post(self, request, instanceid): logger.debug("TerminateVnf--post::> %s" % request.data) - 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() + try: + 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() + except NFLCMException as e: + logger.error(e.message) + return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + except Exception: + logger.error(traceback.format_exc()) + return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) rsp = {"jobId": job_id} return Response(data=rsp, status=status.HTTP_202_ACCEPTED) - - -class QueryMultipleVnf(APIView): - def get(self, request): - logger.debug("QueryMultipleVnf--get::> %s" % request.data) - return Response(data='', status=status.HTTP_202_ACCEPTED) - - -class SwaggerJsonView(APIView): - def get(self, request): - json_file = os.path.join(os.path.dirname(__file__), 'swagger.json') - f = open(json_file) - json_data = json.JSONDecoder().decode(f.read()) - f.close() - return Response(json_data)