Code Review
/
vfc
/
gvnfm
/
vnflcm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix vfc-vnflcm pep8 issues
[vfc/gvnfm/vnflcm.git]
/
lcm
/
lcm
/
nf
/
vnfs
/
views.py
diff --git
a/lcm/lcm/nf/vnfs/views.py
b/lcm/lcm/nf/vnfs/views.py
index
8b026e5
..
cfdf280
100644
(file)
--- 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.
# 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 logging
-import os
import traceback
from rest_framework import status
import traceback
from rest_framework import status
@@
-33,13
+32,14
@@
logger = logging.getLogger(__name__)
class CreateVnfAndQueryVnfs(APIView):
def get(self, request):
class CreateVnfAndQueryVnfs(APIView):
def get(self, request):
- logger.debug("Query
Single
Vnf--get::> %s" % request.data)
+ logger.debug("Query
Multi
Vnf--get::> %s" % request.data)
try:
resp_data = QueryVnf(request.data).query_multi_vnf()
except NFLCMException as e:
logger.error(e.message)
return Response(data={'error': '%s' % e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
try:
resp_data = QueryVnf(request.data).query_multi_vnf()
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)
logger.error(traceback.format_exc())
return Response(data={'error': 'Failed to get Vnfs'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@
-52,10
+52,13
@@
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 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)
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
- rsp = {"vnfInstanceId": nf_inst_id}
+ rsp = {
+ "vnfInstanceId": nf_inst_id
+ }
return Response(data=rsp, status=status.HTTP_201_CREATED)
return Response(data=rsp, status=status.HTTP_201_CREATED)
@@
-69,10
+72,13
@@
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 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)
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
- rsp = {"jobId": job_id}
+ rsp = {
+ "jobId": job_id
+ }
return Response(data=rsp, status=status.HTTP_202_ACCEPTED)
return Response(data=rsp, status=status.HTTP_202_ACCEPTED)
@@
-84,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 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)
logger.error(traceback.format_exc())
return Response(data={'error': 'Failed to get Vnf(%s)' % instanceid},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@
-97,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 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)
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)
@@
-113,17
+121,11
@@
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 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)
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
- rsp = {"jobId": job_id}
+ rsp = {
+ "jobId": job_id
+ }
return Response(data=rsp, status=status.HTTP_202_ACCEPTED)
return Response(data=rsp, 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)