Fix vfc-vnflcm pep8 issues 69/27769/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Wed, 10 Jan 2018 02:21:21 +0000 (10:21 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Wed, 10 Jan 2018 02:21:21 +0000 (10:21 +0800)
Change-Id: Ie95e04333e1665f3d14cde716e8c8b175feef572
Issue-ID: VFC-630
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
lcm/lcm/nf/vnfs/tests/test_vnf_create.py
lcm/lcm/nf/vnfs/views.py
lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py
lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py
lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py
lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py

index 7965072..2c4a2ea 100644 (file)
@@ -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',
index 495e782..cfdf280 100644 (file)
@@ -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 = {
index 65dc677..d24cc08 100644 (file)
@@ -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):
index 12df170..21babf5 100644 (file)
@@ -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):
index 593248d..12f540d 100644 (file)
@@ -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='',
index a1f6639..59ec993 100644 (file)
@@ -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')