summaryrefslogtreecommitdiffstats
path: root/newton
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2017-03-28 14:54:38 +0800
committerBin Yang <bin.yang@windriver.com>2017-03-28 14:54:38 +0800
commit8d0ec8dcd8095f48db0912742cca96461e90bf06 (patch)
treeac82cef516e257fa828bbe009474ab125cebdb0b /newton
parentca20093c544d7ec5ce9e5efe8003576a4ce2e23c (diff)
Expose detail information upon API call failure
Change-Id: I6e42cebeb7e1c5edd3f77b8c0c6c091d04fcb364 Issue-Id: MULTIVIM-58 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'newton')
-rw-r--r--newton/newton/requests/views/flavor.py11
-rw-r--r--newton/newton/requests/views/hosts.py5
-rw-r--r--newton/newton/requests/views/image.py16
-rw-r--r--newton/newton/requests/views/limits.py5
-rw-r--r--newton/newton/requests/views/network.py11
-rw-r--r--newton/newton/requests/views/server.py11
-rw-r--r--newton/newton/requests/views/subnet.py11
-rw-r--r--newton/newton/requests/views/tenants.py5
-rw-r--r--newton/newton/requests/views/volume.py11
-rw-r--r--newton/newton/requests/views/vport.py11
10 files changed, 86 insertions, 11 deletions
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)},