diff options
author | Bin Yang <bin.yang@windriver.com> | 2017-03-28 14:54:38 +0800 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2017-03-28 14:54:38 +0800 |
commit | 8d0ec8dcd8095f48db0912742cca96461e90bf06 (patch) | |
tree | ac82cef516e257fa828bbe009474ab125cebdb0b | |
parent | ca20093c544d7ec5ce9e5efe8003576a4ce2e23c (diff) |
Expose detail information upon API call failure
Change-Id: I6e42cebeb7e1c5edd3f77b8c0c6c091d04fcb364
Issue-Id: MULTIVIM-58
Signed-off-by: Bin Yang <bin.yang@windriver.com>
-rw-r--r-- | kilo/kilo/requests/views/flavor.py | 11 | ||||
-rw-r--r-- | kilo/kilo/requests/views/hosts.py | 5 | ||||
-rw-r--r-- | kilo/kilo/requests/views/image.py | 14 | ||||
-rw-r--r-- | kilo/kilo/requests/views/limits.py | 5 | ||||
-rw-r--r-- | kilo/kilo/requests/views/network.py | 11 | ||||
-rw-r--r-- | kilo/kilo/requests/views/server.py | 11 | ||||
-rw-r--r-- | kilo/kilo/requests/views/subnet.py | 11 | ||||
-rw-r--r-- | kilo/kilo/requests/views/tenants.py | 5 | ||||
-rw-r--r-- | kilo/kilo/requests/views/volume.py | 11 | ||||
-rw-r--r-- | kilo/kilo/requests/views/vport.py | 11 | ||||
-rw-r--r-- | newton/newton/requests/views/flavor.py | 11 | ||||
-rw-r--r-- | newton/newton/requests/views/hosts.py | 5 | ||||
-rw-r--r-- | newton/newton/requests/views/image.py | 16 | ||||
-rw-r--r-- | newton/newton/requests/views/limits.py | 5 | ||||
-rw-r--r-- | newton/newton/requests/views/network.py | 11 | ||||
-rw-r--r-- | newton/newton/requests/views/server.py | 11 | ||||
-rw-r--r-- | newton/newton/requests/views/subnet.py | 11 | ||||
-rw-r--r-- | newton/newton/requests/views/tenants.py | 5 | ||||
-rw-r--r-- | newton/newton/requests/views/volume.py | 11 | ||||
-rw-r--r-- | newton/newton/requests/views/vport.py | 11 |
20 files changed, 171 insertions, 21 deletions
diff --git a/kilo/kilo/requests/views/flavor.py b/kilo/kilo/requests/views/flavor.py index fb8fb697..84cbc419 100644 --- a/kilo/kilo/requests/views/flavor.py +++ b/kilo/kilo/requests/views/flavor.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -118,6 +118,9 @@ class Flavors(APIView): return Response(data=content, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -241,6 +244,9 @@ class Flavors(APIView): self.delete_flavor(sess, flavorid) return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) @@ -309,6 +315,9 @@ class Flavors(APIView): return Response(status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/hosts.py b/kilo/kilo/requests/views/hosts.py index dfd34513..022c59e9 100644 --- a/kilo/kilo/requests/views/hosts.py +++ b/kilo/kilo/requests/views/hosts.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -76,6 +76,9 @@ class Hosts(APIView): return Response(data=content, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/image.py b/kilo/kilo/requests/views/image.py index c8f66b28..a3e70019 100644 --- a/kilo/kilo/requests/views/image.py +++ b/kilo/kilo/requests/views/image.py @@ -16,7 +16,7 @@ import json import urllib2 import threading import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -65,6 +65,9 @@ class imageThread (threading.Thread): logger.debug("response status code of transfer_image %s" % resp.status_code) return None + except HttpError as e: + logger.error("transfer_image, HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return None except Exception as e: logger.error(traceback.format_exc()) logger.debug("Failed to transfer_image:%s" % str(e)) @@ -90,6 +93,9 @@ class Images(APIView): return Response(data=content, status=status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -203,6 +209,9 @@ class Images(APIView): except urllib2.URLError as e: return Response(data={'error': 'image is not accessible:%s' % str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -223,6 +232,9 @@ class Images(APIView): return Response(status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/limits.py b/kilo/kilo/requests/views/limits.py index ee44124b..3b6f0528 100644 --- a/kilo/kilo/requests/views/limits.py +++ b/kilo/kilo/requests/views/limits.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -75,6 +75,9 @@ class Limits(APIView): return Response(data=content_all, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/network.py b/kilo/kilo/requests/views/network.py index eb45189b..61a409e4 100644 --- a/kilo/kilo/requests/views/network.py +++ b/kilo/kilo/requests/views/network.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -48,6 +48,9 @@ class Networks(APIView): except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -132,6 +135,9 @@ class Networks(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -155,6 +161,9 @@ class Networks(APIView): return Response(status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/server.py b/kilo/kilo/requests/views/server.py index 0da19c44..92440429 100644 --- a/kilo/kilo/requests/views/server.py +++ b/kilo/kilo/requests/views/server.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -79,6 +79,9 @@ class Servers(APIView): return Response(data=content, status=status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -240,6 +243,9 @@ class Servers(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -260,6 +266,9 @@ class Servers(APIView): return Response(status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/subnet.py b/kilo/kilo/requests/views/subnet.py index 3512a2f0..8dabafb1 100644 --- a/kilo/kilo/requests/views/subnet.py +++ b/kilo/kilo/requests/views/subnet.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -50,6 +50,9 @@ class Subnets(APIView): return Response(data=content, status=status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -134,6 +137,9 @@ class Subnets(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -157,6 +163,9 @@ class Subnets(APIView): return Response(status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/tenants.py b/kilo/kilo/requests/views/tenants.py index c8a7fff2..31b17a0b 100644 --- a/kilo/kilo/requests/views/tenants.py +++ b/kilo/kilo/requests/views/tenants.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -70,6 +70,9 @@ class Tenants(APIView): return Response(data=content, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/volume.py b/kilo/kilo/requests/views/volume.py index 6682a4c4..41a8f852 100644 --- a/kilo/kilo/requests/views/volume.py +++ b/kilo/kilo/requests/views/volume.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -50,6 +50,9 @@ class Volumes(APIView): return Response(data=content, status=status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -136,6 +139,9 @@ class Volumes(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -156,6 +162,9 @@ class Volumes(APIView): return Response(status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/kilo/kilo/requests/views/vport.py b/kilo/kilo/requests/views/vport.py index 987524dd..7fd6b900 100644 --- a/kilo/kilo/requests/views/vport.py +++ b/kilo/kilo/requests/views/vport.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -50,6 +50,9 @@ class Vports(APIView): return Response(data=content, status=status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -125,6 +128,9 @@ class Vports(APIView): return self.create_port(request, vimid, tenantid) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -189,6 +195,9 @@ class Vports(APIView): return Response(status=resp.status_code) except VimDriverKiloException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/flavor.py b/newton/newton/requests/views/flavor.py index c59c42cf..2b7377bf 100644 --- a/newton/newton/requests/views/flavor.py +++ b/newton/newton/requests/views/flavor.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -118,6 +118,9 @@ class Flavors(APIView): return Response(data=content, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -241,6 +244,9 @@ class Flavors(APIView): self.delete_flavor(sess, flavorid) return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) @@ -306,6 +312,9 @@ class Flavors(APIView): return Response(status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/hosts.py b/newton/newton/requests/views/hosts.py index 7801c557..8f05b7d5 100644 --- a/newton/newton/requests/views/hosts.py +++ b/newton/newton/requests/views/hosts.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -76,6 +76,9 @@ class Hosts(APIView): return Response(data=content, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/image.py b/newton/newton/requests/views/image.py index bf24771d..4e929d70 100644 --- a/newton/newton/requests/views/image.py +++ b/newton/newton/requests/views/image.py @@ -16,7 +16,7 @@ import json import urllib2 import threading import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -65,9 +65,12 @@ class imageThread (threading.Thread): logger.debug("response status code of transfer_image %s" % resp.status_code) return None + except HttpError as e: + logger.error("transfer_image, HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return None except Exception as e: logger.error(traceback.format_exc()) - logger.debug("Failed to transfer_image:%s" % str(e)) + logger.error("Failed to transfer_image:%s" % str(e)) return None pass @@ -90,6 +93,9 @@ class Images(APIView): return Response(data=content, status=status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -203,6 +209,9 @@ class Images(APIView): except urllib2.URLError as e: return Response(data={'error': 'image is not accessible:%s' % str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -223,6 +232,9 @@ class Images(APIView): return Response(status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/limits.py b/newton/newton/requests/views/limits.py index 83d0e505..01bee2ba 100644 --- a/newton/newton/requests/views/limits.py +++ b/newton/newton/requests/views/limits.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -75,6 +75,9 @@ class Limits(APIView): return Response(data=content_all, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/network.py b/newton/newton/requests/views/network.py index a1b440d8..c1eae5ed 100644 --- a/newton/newton/requests/views/network.py +++ b/newton/newton/requests/views/network.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -48,6 +48,9 @@ class Networks(APIView): except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -132,6 +135,9 @@ class Networks(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -155,6 +161,9 @@ class Networks(APIView): return Response(status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/server.py b/newton/newton/requests/views/server.py index 5aec1905..fad1281f 100644 --- a/newton/newton/requests/views/server.py +++ b/newton/newton/requests/views/server.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -79,6 +79,9 @@ class Servers(APIView): return Response(data=content, status=status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -239,6 +242,9 @@ class Servers(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -259,6 +265,9 @@ class Servers(APIView): return Response(status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/subnet.py b/newton/newton/requests/views/subnet.py index b37d4d33..6cf69858 100644 --- a/newton/newton/requests/views/subnet.py +++ b/newton/newton/requests/views/subnet.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -50,6 +50,9 @@ class Subnets(APIView): return Response(data=content, status=status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -134,6 +137,9 @@ class Subnets(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -157,6 +163,9 @@ class Subnets(APIView): return Response(status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/tenants.py b/newton/newton/requests/views/tenants.py index 7f82bb67..bcc80bd9 100644 --- a/newton/newton/requests/views/tenants.py +++ b/newton/newton/requests/views/tenants.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -75,6 +75,9 @@ class Tenants(APIView): return Response(data=content, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/volume.py b/newton/newton/requests/views/volume.py index a126aadc..3f958907 100644 --- a/newton/newton/requests/views/volume.py +++ b/newton/newton/requests/views/volume.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -50,6 +50,9 @@ class Volumes(APIView): return Response(data=content, status=status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -136,6 +139,9 @@ class Volumes(APIView): return Response(data=resp_body, status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -156,6 +162,9 @@ class Volumes(APIView): return Response(status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, diff --git a/newton/newton/requests/views/vport.py b/newton/newton/requests/views/vport.py index a5b8db93..cb806038 100644 --- a/newton/newton/requests/views/vport.py +++ b/newton/newton/requests/views/vport.py @@ -14,7 +14,7 @@ import logging import json import traceback - +from keystoneauth1.exceptions import HttpError from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView @@ -50,6 +50,9 @@ class Vports(APIView): return Response(data=content, status=status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -125,6 +128,9 @@ class Vports(APIView): return self.create_port(request, vimid, tenantid) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, @@ -189,6 +195,9 @@ class Vports(APIView): return Response(status=resp.status_code) except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) + except HttpError as e: + logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json())) + return Response(data=e.response.json(), status=e.http_status) except Exception as e: logger.error(traceback.format_exc()) return Response(data={'error': str(e)}, |