From: ying.yunlong Date: Wed, 10 Jan 2018 02:21:21 +0000 (+0800) Subject: Fix vfc-vnflcm pep8 issues X-Git-Tag: v1.1.0~85 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vfc%2Fgvnfm%2Fvnflcm.git;a=commitdiff_plain;h=358310fd8c7c0863800de3b22a5a9d8ce2fb3b7e Fix vfc-vnflcm pep8 issues Change-Id: Ie95e04333e1665f3d14cde716e8c8b175feef572 Issue-ID: VFC-630 Signed-off-by: ying.yunlong --- diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index 7965072d..2c4a2ea9 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -106,7 +106,7 @@ class TestNFInstantiate(TestCase): self.assert_job_result(self.job_id, 255, "VNF nf_inst_id is not exist.") @mock.patch.object(restcall, 'call_req') - def test_instantiate_vnf_when_get_rawdata_by_csarid_failed(self, mock_call_req): + def test_instantiate_vnf_when_get_packageinfo_by_csarid_failed(self, mock_call_req): NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222', diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py index 495e782a..cfdf2800 100644 --- a/lcm/lcm/nf/vnfs/views.py +++ b/lcm/lcm/nf/vnfs/views.py @@ -38,7 +38,8 @@ class CreateVnfAndQueryVnfs(APIView): except NFLCMException as e: logger.error(e.message) return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - except: + except Exception as e: + logger.error(e.message) logger.error(traceback.format_exc()) return Response(data={'error': 'Failed to get Vnfs'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) @@ -51,7 +52,8 @@ class CreateVnfAndQueryVnfs(APIView): except NFLCMException as e: logger.error(e.message) return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - except Exception: + except Exception as e: + logger.error(e.message) logger.error(traceback.format_exc()) return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) rsp = { @@ -70,7 +72,8 @@ class InstantiateVnf(APIView): except NFLCMException as e: logger.error(e.message) return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - except Exception: + except Exception as e: + logger.error(e.message) logger.error(traceback.format_exc()) return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) rsp = { @@ -87,7 +90,8 @@ class DeleteVnfAndQueryVnf(APIView): except NFLCMException as e: logger.error(e.message) return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - except: + except Exception as e: + logger.eror(e.message) logger.error(traceback.format_exc()) return Response(data={'error': 'Failed to get Vnf(%s)' % instanceid}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) @@ -100,7 +104,8 @@ class DeleteVnfAndQueryVnf(APIView): except NFLCMException as e: logger.error(e.message) return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - except Exception: + except Exception as e: + logger.error(e.message) logger.error(traceback.format_exc()) return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(data=None, status=status.HTTP_204_NO_CONTENT) @@ -116,7 +121,8 @@ class TerminateVnf(APIView): except NFLCMException as e: logger.error(e.message) return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) - except Exception: + except Exception as e: + logger.error(e.message) logger.error(traceback.format_exc()) return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) rsp = { diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py index 65dc677e..d24cc081 100644 --- a/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py @@ -13,6 +13,7 @@ # limitations under the License. import logging +import traceback from lcm.pub.database.models import NfInstModel, NfvoRegInfoModel from lcm.pub.exceptions import NFLCMException @@ -31,7 +32,9 @@ class DeleteVnf: self.delete_info_from_db() except NFLCMException as e: logger.debug('Delete VNF instance[%s] failed: %s', self.nf_inst_id, e.message) - except: + except Exception as e: + logger.error(e.message) + logger.error(traceback.format_exc()) logger.debug('Delete VNF instance[%s] failed' % self.nf_inst_id) def check_parameter(self): diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py index 12df170b..21babf51 100644 --- a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py @@ -60,7 +60,8 @@ class TermVnf(Thread): JobUtil.add_job_status(self.job_id, 100, "Terminate Vnf success.") except NFLCMException as e: self.vnf_term_failed_handle(e.message) - except: + except Exception as e: + logger.error(e.message) self.vnf_term_failed_handle(traceback.format_exc()) def term_pre(self): diff --git a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py index 593248dd..12f540da 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py @@ -13,6 +13,7 @@ # limitations under the License. import logging +import traceback import uuid from lcm.pub.database.models import NfInstModel @@ -41,7 +42,9 @@ class CreateVnf: except NFLCMException as e: logger.debug('Create VNF instance[%s]: %s', self.nf_inst_id, e.message) raise NFLCMException(e.message) - except: + except Exception as e: + logger.error(e.message) + logger.error(traceback.format_exc()) NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name=self.vnf_instance_mame, package_id='', diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index a1f66391..59ec9930 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -53,7 +53,8 @@ class InstVnf(Thread): JobUtil.add_job_status(self.job_id, 100, "Instantiate Vnf success.") except NFLCMException as e: self.vnf_inst_failed_handle(e.message) - except: + except Exception as e: + logger.error(e.message) logger.error(traceback.format_exc()) self.vnf_inst_failed_handle('unexpected exception')