summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Hurley <gabriel@strikeawe.com>2011-12-09 13:37:00 -0800
committerGabriel Hurley <gabriel@strikeawe.com>2011-12-09 13:37:59 -0800
commitf068f9e7901ed2802d2b1844b600b5a8038682a4 (patch)
tree063a757592d39178e3478e5d88bf590a7c264dfd
parent9e84bae97a8e056d5f3aeeb99777f3e36a3bbfec (diff)
downloadhorizon-f068f9e7901ed2802d2b1844b600b5a8038682a4.tar.gz
Cleans up error handling for index view api calls. Prevents 500 errors.
Also brings buildout config for glance into line with pip-requires. Fixes bug 893795. Change-Id: Ia5cc1d480cf160c682a6ec7a3d0bed9057e7acc9
-rwxr-xr-xhorizon/buildout.cfg9
-rw-r--r--horizon/horizon/dashboards/nova/containers/views.py9
-rw-r--r--horizon/horizon/dashboards/nova/images/tests.py14
-rw-r--r--horizon/horizon/dashboards/nova/images/views.py16
-rw-r--r--horizon/horizon/dashboards/nova/instances/views.py2
-rw-r--r--horizon/horizon/dashboards/nova/snapshots/tests.py2
-rw-r--r--horizon/horizon/dashboards/nova/snapshots/views.py2
-rw-r--r--horizon/horizon/dashboards/syspanel/flavors/views.py11
-rw-r--r--horizon/horizon/dashboards/syspanel/images/views.py2
-rw-r--r--horizon/horizon/dashboards/syspanel/quotas/views.py18
-rw-r--r--horizon/horizon/dashboards/syspanel/tenants/views.py10
-rw-r--r--horizon/horizon/dashboards/syspanel/users/views.py11
-rwxr-xr-xrun_tests.sh2
13 files changed, 64 insertions, 44 deletions
diff --git a/horizon/buildout.cfg b/horizon/buildout.cfg
index 33ca3cd65..b7e8ce425 100755
--- a/horizon/buildout.cfg
+++ b/horizon/buildout.cfg
@@ -3,6 +3,7 @@ download-cache = /tmp/.buildout_cache/
parts =
django
openstackx
+ glance
quantum
python-novaclient
python-keystoneclient
@@ -20,7 +21,6 @@ pep8 = 0.5.0
sqlalchemy = 0.6.3
sqlalchemy-migrate = 0.6
webob = 1.0.8
-glance = 2011.3
pycrypto = 2.3
@@ -33,7 +33,6 @@ eggs =
httplib2
python-cloudfiles
coverage
- glance
django-nose-selenium
CherryPy
pycrypto
@@ -95,6 +94,12 @@ repository = git://github.com/cloudbuilders/openstackx.git
as_egg = True
+[glance]
+recipe = zerokspot.recipe.git
+repository = git://github.com/openstack/glance.git
+as_egg = True
+
+
[quantum]
recipe = zerokspot.recipe.git
repository = git://github.com/openstack/quantum.git
diff --git a/horizon/horizon/dashboards/nova/containers/views.py b/horizon/horizon/dashboards/nova/containers/views.py
index 21f22d5dc..cf20e24b4 100644
--- a/horizon/horizon/dashboards/nova/containers/views.py
+++ b/horizon/horizon/dashboards/nova/containers/views.py
@@ -24,6 +24,7 @@ Views for managing Swift containers.
import logging
from django import http
+from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django import shortcuts
@@ -43,7 +44,13 @@ def index(request):
if handled:
return handled
- containers, more = api.swift_get_containers(request, marker=marker)
+ try:
+ containers, more = api.swift_get_containers(request, marker=marker)
+ except Exception, e:
+ containers, more = None, None
+ msg = _('Error retrieving container list: %s') % e
+ LOG.exception(msg)
+ messages.error(request, msg)
return shortcuts.render(request,
'nova/containers/index.html',
diff --git a/horizon/horizon/dashboards/nova/images/tests.py b/horizon/horizon/dashboards/nova/images/tests.py
index 0d2e49f4a..96b2205fe 100644
--- a/horizon/horizon/dashboards/nova/images/tests.py
+++ b/horizon/horizon/dashboards/nova/images/tests.py
@@ -100,10 +100,6 @@ class ImageViewTests(test.BaseViewTests):
self.mox.StubOutWithMock(api, 'image_list_detailed')
api.image_list_detailed(IsA(http.HttpRequest)).AndReturn([])
- self.mox.StubOutWithMock(api, 'tenant_quota_get')
- api.tenant_quota_get(IsA(http.HttpRequest), self.TEST_TENANT) \
- .AndReturn({})
-
self.mox.StubOutWithMock(messages, 'info')
messages.info(IsA(http.HttpRequest), IsA(basestring))
@@ -118,10 +114,6 @@ class ImageViewTests(test.BaseViewTests):
exception = glance_exception.ClientConnectionError('clientConnError')
api.image_list_detailed(IsA(http.HttpRequest)).AndRaise(exception)
- self.mox.StubOutWithMock(api, 'tenant_quota_get')
- api.tenant_quota_get(IsA(http.HttpRequest), self.TEST_TENANT) \
- .AndReturn({})
-
self.mox.StubOutWithMock(messages, 'error')
messages.error(IsA(http.HttpRequest), IsA(basestring))
@@ -134,13 +126,9 @@ class ImageViewTests(test.BaseViewTests):
def test_index_glance_error(self):
self.mox.StubOutWithMock(api, 'image_list_detailed')
- exception = glance_exception.Error('glanceError')
+ exception = glance_exception.GlanceException('glanceError')
api.image_list_detailed(IsA(http.HttpRequest)).AndRaise(exception)
- self.mox.StubOutWithMock(api, 'tenant_quota_get')
- api.tenant_quota_get(IsA(http.HttpRequest), self.TEST_TENANT) \
- .AndReturn({})
-
self.mox.StubOutWithMock(messages, 'error')
messages.error(IsA(http.HttpRequest), IsA(basestring))
diff --git a/horizon/horizon/dashboards/nova/images/views.py b/horizon/horizon/dashboards/nova/images/views.py
index 786b72780..07ef03e64 100644
--- a/horizon/horizon/dashboards/nova/images/views.py
+++ b/horizon/horizon/dashboards/nova/images/views.py
@@ -54,10 +54,10 @@ def index(request):
except glance_exception.ClientConnectionError, e:
LOG.exception("Error connecting to glance")
messages.error(request, _("Error connecting to glance: %s") % str(e))
- except glance_exception.Error, e:
+ except glance_exception.GlanceException, e:
LOG.exception("Error retrieving image list")
messages.error(request, _("Error retrieving image list: %s") % str(e))
- except api_exceptions.ApiException, e:
+ except Exception, e:
msg = _("Unable to retrieve image info from glance: %s") % str(e)
LOG.exception(msg)
messages.error(request, msg)
@@ -65,13 +65,13 @@ def index(request):
images = [im for im in all_images
if im['container_format'] not in ['aki', 'ari']]
- quotas = api.tenant_quota_get(request, request.user.tenant_id)
+ context = {'delete_form': DeleteImage(), 'images': images}
- return shortcuts.render(request,
- 'nova/images/index.html', {
- 'delete_form': DeleteImage(),
- 'quotas': quotas,
- 'images': images})
+ if images:
+ quotas = api.tenant_quota_get(request, request.user.tenant_id)
+ context['quotas'] = quotas
+
+ return shortcuts.render(request, 'nova/images/index.html', context)
@login_required
diff --git a/horizon/horizon/dashboards/nova/instances/views.py b/horizon/horizon/dashboards/nova/instances/views.py
index 9674b97fb..37dd44349 100644
--- a/horizon/horizon/dashboards/nova/instances/views.py
+++ b/horizon/horizon/dashboards/nova/instances/views.py
@@ -51,7 +51,7 @@ def index(request):
instances = []
try:
instances = api.server_list(request)
- except api_exceptions.ApiException as e:
+ except Exception as e:
LOG.exception(_('Exception in instance index'))
messages.error(request, _('Unable to get instance list: %s')
% e.message)
diff --git a/horizon/horizon/dashboards/nova/snapshots/tests.py b/horizon/horizon/dashboards/nova/snapshots/tests.py
index ac5881245..459ef8b36 100644
--- a/horizon/horizon/dashboards/nova/snapshots/tests.py
+++ b/horizon/horizon/dashboards/nova/snapshots/tests.py
@@ -106,7 +106,7 @@ class SnapshotsViewTests(test.BaseViewTests):
def test_index_glance_error(self):
self.mox.StubOutWithMock(api, 'snapshot_list_detailed')
- exception = glance_exception.Error('glanceError')
+ exception = glance_exception.GlanceException('glanceError')
api.snapshot_list_detailed(IsA(http.HttpRequest)).AndRaise(exception)
self.mox.StubOutWithMock(messages, 'error')
diff --git a/horizon/horizon/dashboards/nova/snapshots/views.py b/horizon/horizon/dashboards/nova/snapshots/views.py
index 7aef869f1..902beac83 100644
--- a/horizon/horizon/dashboards/nova/snapshots/views.py
+++ b/horizon/horizon/dashboards/nova/snapshots/views.py
@@ -52,7 +52,7 @@ def index(request):
msg = _('Error connecting to glance: %s') % str(e)
LOG.exception(msg)
messages.error(request, msg)
- except glance_exception.Error, e:
+ except glance_exception.GlanceException, e:
msg = _('Error retrieving image list: %s') % str(e)
LOG.exception(msg)
messages.error(request, msg)
diff --git a/horizon/horizon/dashboards/syspanel/flavors/views.py b/horizon/horizon/dashboards/syspanel/flavors/views.py
index 7be1c1ed3..63f25bfbe 100644
--- a/horizon/horizon/dashboards/syspanel/flavors/views.py
+++ b/horizon/horizon/dashboards/syspanel/flavors/views.py
@@ -24,7 +24,7 @@ from django import shortcuts
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _
-from openstackx.api import exceptions as api_exceptions
+from novaclient import exceptions as api_exceptions
from horizon import api
from horizon import forms
@@ -48,9 +48,12 @@ def index(request):
flavors = []
try:
flavors = api.flavor_list(request)
- except api_exceptions.ApiException, e:
- LOG.exception('ApiException while fetching usage info')
- messages.error(request, _('Unable to get usage info: %s') % e.message)
+ except api_exceptions.Unauthorized, e:
+ LOG.exception('Unauthorized attempt to access flavor list.')
+ messages.error(request, _('Unauthorized.'))
+ except Exception, e:
+ LOG.exception('Exception while fetching usage info')
+ messages.error(request, _('Unable to get flavor list: %s') % e.message)
flavors.sort(key=lambda x: x.id, reverse=True)
return shortcuts.render(request,
diff --git a/horizon/horizon/dashboards/syspanel/images/views.py b/horizon/horizon/dashboards/syspanel/images/views.py
index 611f05113..05f76b5e2 100644
--- a/horizon/horizon/dashboards/syspanel/images/views.py
+++ b/horizon/horizon/dashboards/syspanel/images/views.py
@@ -55,7 +55,7 @@ def index(request):
LOG.exception("Error connecting to glance")
messages.error(request,
_("Error connecting to glance: %s") % e.message)
- except glance_exception.Error, e:
+ except glance_exception.GlanceException, e:
LOG.exception("Error retrieving image list")
messages.error(request,
_("Error retrieving image list: %s") % e.message)
diff --git a/horizon/horizon/dashboards/syspanel/quotas/views.py b/horizon/horizon/dashboards/syspanel/quotas/views.py
index 73a1d4ee5..f69cedd7f 100644
--- a/horizon/horizon/dashboards/syspanel/quotas/views.py
+++ b/horizon/horizon/dashboards/syspanel/quotas/views.py
@@ -18,18 +18,28 @@
# License for the specific language governing permissions and limitations
# under the License.
+import logging
+
from django import shortcuts
+from django.contrib import messages
from django.contrib.auth.decorators import login_required
-from openstackx.api import exceptions as api_exceptions
from horizon import api
+LOG = logging.getLogger(__name__)
+
+
@login_required
def index(request):
- quotas = api.admin_api(request).quota_sets.get(True)._info
- quotas['ram'] = int(quotas['ram']) / 100
- quotas.pop('id')
+ try:
+ quotas = api.admin_api(request).quota_sets.get(True)._info
+ quotas['ram'] = int(quotas['ram']) / 100
+ quotas.pop('id')
+ except Exception, e:
+ quotas = None
+ LOG.exception('Exception while getting quota info')
+ messages.error(request, _('Unable to get quota info: %s') % e.message)
return shortcuts.render(request,
'syspanel/quotas/index.html', {
diff --git a/horizon/horizon/dashboards/syspanel/tenants/views.py b/horizon/horizon/dashboards/syspanel/tenants/views.py
index 6b995a44f..58900b8c8 100644
--- a/horizon/horizon/dashboards/syspanel/tenants/views.py
+++ b/horizon/horizon/dashboards/syspanel/tenants/views.py
@@ -25,7 +25,7 @@ from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _
-from openstackx.api import exceptions as api_exceptions
+from keystoneclient import exceptions as api_exceptions
from horizon import api
from horizon.dashboards.syspanel.tenants.forms import (AddUser, RemoveUser,
@@ -46,9 +46,13 @@ def index(request):
tenants = []
try:
tenants = api.tenant_list(request)
- except api_exceptions.ApiException, e:
- LOG.exception('ApiException while getting tenant list')
+ except api_exceptions.AuthorizationFailure, e:
+ LOG.exception("Unauthorized attempt to list tenants.")
messages.error(request, _('Unable to get tenant info: %s') % e.message)
+ except Exception, e:
+ LOG.exception('Exception while getting tenant list')
+ messages.error(request, _('Unable to get tenant info: %s') % e.message)
+
tenants.sort(key=lambda x: x.id, reverse=True)
return shortcuts.render(request,
'syspanel/tenants/index.html', {
diff --git a/horizon/horizon/dashboards/syspanel/users/views.py b/horizon/horizon/dashboards/syspanel/users/views.py
index aa9b3a63f..bdd1f1459 100644
--- a/horizon/horizon/dashboards/syspanel/users/views.py
+++ b/horizon/horizon/dashboards/syspanel/users/views.py
@@ -25,7 +25,7 @@ from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _
-from openstackx.api import exceptions as api_exceptions
+from keystoneclient import exceptions as api_exceptions
from horizon import api
from horizon.dashboards.syspanel.users.forms import (UserForm, UserUpdateForm,
@@ -45,9 +45,12 @@ def index(request):
users = []
try:
users = api.user_list(request)
- except api_exceptions.ApiException, e:
- messages.error(request, _('Unable to list users: %s') %
- e.message)
+ except api_exceptions.AuthorizationFailure, e:
+ LOG.exception("Unauthorized attempt to list users.")
+ messages.error(request, _('Unable to get user info: %s') % e.message)
+ except Exception, e:
+ LOG.exception('Exception while getting user list')
+ messages.error(request, _('Unable to get user info: %s') % e.message)
user_delete_form = UserDeleteForm()
toggle_form = UserEnableDisableForm()
diff --git a/run_tests.sh b/run_tests.sh
index 85e2e0c86..025003394 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -6,7 +6,7 @@ set -o errexit
# Increment me any time the environment should be rebuilt.
# This includes dependncy changes, directory renames, etc.
# Simple integer secuence: 1, 2, 3...
-environment_version=4
+environment_version=5
#--------------------------------------------------------#
function usage {