Enable H201: do not write "except:"

Fixes all occurrences of this. We have a custom exception handler
in Horizon anyway that only catches ClientException in most of these
cases, but this commit lets us gate on the other cases.

Change-Id: Iea3dc13817f3e5b775b2024424bf3a906da5584b
Closes-Bug: #1211657
This commit is contained in:
Kieran Spear 2013-08-13 16:54:59 +10:00
parent fe659b231a
commit 242c8df495
106 changed files with 268 additions and 269 deletions

View File

@ -440,7 +440,7 @@ class Dashboard(Registry, HorizonComponent):
""" """
try: try:
return self._registered(self.default_panel).get_absolute_url() return self._registered(self.default_panel).get_absolute_url()
except: except Exception:
# Logging here since this will often be called in a template # Logging here since this will often be called in a template
# where the exception would be hidden. # where the exception would be hidden.
LOG.exception("Error reversing absolute URL for %s." % self) LOG.exception("Error reversing absolute URL for %s." % self)
@ -512,7 +512,7 @@ class Dashboard(Registry, HorizonComponent):
try: try:
before_import_registry = copy.copy(self._registry) before_import_registry = copy.copy(self._registry)
import_module('.%s.panel' % panel, package) import_module('.%s.panel' % panel, package)
except: except Exception:
self._registry = before_import_registry self._registry = before_import_registry
if module_has_submodule(mod, panel): if module_has_submodule(mod, panel):
raise raise
@ -750,7 +750,7 @@ class Site(Registry, HorizonComponent):
try: try:
before_import_registry = copy.copy(self._registry) before_import_registry = copy.copy(self._registry)
import_module('%s.%s' % (package, mod_name)) import_module('%s.%s' % (package, mod_name))
except: except Exception:
self._registry = before_import_registry self._registry = before_import_registry
if module_has_submodule(mod, mod_name): if module_has_submodule(mod, mod_name):
raise raise
@ -780,7 +780,7 @@ class Site(Registry, HorizonComponent):
try: try:
before_import_registry = copy.copy(self._registry) before_import_registry = copy.copy(self._registry)
import_module('%s.%s' % (app, mod_name)) import_module('%s.%s' % (app, mod_name))
except: except Exception:
self._registry = before_import_registry self._registry = before_import_registry
if module_has_submodule(mod, mod_name): if module_has_submodule(mod, mod_name):
raise raise

View File

@ -89,7 +89,7 @@ class ModalFormView(ModalFormMixin, generic.FormView):
def form_valid(self, form): def form_valid(self, form):
try: try:
handled = form.handle(self.request, form.cleaned_data) handled = form.handle(self.request, form.cleaned_data)
except: except Exception:
handled = None handled = None
exceptions.handle(self.request) exceptions.handle(self.request)

View File

@ -565,7 +565,7 @@ class Cell(html.HTMLElement):
data = self.column.empty_value(self.datum) data = self.column.empty_value(self.datum)
else: else:
data = self.column.empty_value data = self.column.empty_value
except: except Exception:
data = None data = None
exc_info = sys.exc_info() exc_info = sys.exc_info()
raise template.TemplateSyntaxError, exc_info[1], exc_info[2] raise template.TemplateSyntaxError, exc_info[1], exc_info[2]
@ -1210,7 +1210,7 @@ class DataTable(object):
datum = new_row.get_data(request, obj_id) datum = new_row.get_data(request, obj_id)
new_row.load_cells(datum) new_row.load_cells(datum)
error = False error = False
except: except Exception:
datum = None datum = None
error = exceptions.handle(request, ignore=True) error = exceptions.handle(request, ignore=True)
if request.is_ajax(): if request.is_ajax():
@ -1344,7 +1344,7 @@ class DataTable(object):
self.selected = True self.selected = True
row.classes.append('current_selected') row.classes.append('current_selected')
rows.append(row) rows.append(row)
except: except Exception:
# Exceptions can be swallowed at the template level here, # Exceptions can be swallowed at the template level here,
# re-raising as a TemplateSyntaxError makes them visible. # re-raising as a TemplateSyntaxError makes them visible.
LOG.exception("Error while rendering table rows.") LOG.exception("Error while rendering table rows.")

View File

@ -117,7 +117,7 @@ class TabGroup(html.HTMLElement):
if tab.load and not tab.data_loaded: if tab.load and not tab.data_loaded:
try: try:
tab._data = tab.get_context_data(self.request) tab._data = tab.get_context_data(self.request)
except: except Exception:
tab._data = False tab._data = False
exceptions.handle(self.request) exceptions.handle(self.request)
@ -303,7 +303,7 @@ class Tab(html.HTMLElement):
context = self.data context = self.data
except exceptions.Http302: except exceptions.Http302:
raise raise
except: except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info() exc_type, exc_value, exc_traceback = sys.exc_info()
raise TemplateSyntaxError, exc_value, exc_traceback raise TemplateSyntaxError, exc_value, exc_traceback
return render_to_string(self.get_template_name(self.request), context) return render_to_string(self.get_template_name(self.request), context)

View File

@ -40,7 +40,7 @@ class TabView(generic.TemplateView):
context["tab_group"] = tab_group context["tab_group"] = tab_group
# Make sure our data is pre-loaded to capture errors. # Make sure our data is pre-loaded to capture errors.
context["tab_group"].load_tab_data() context["tab_group"].load_tab_data()
except: except Exception:
exceptions.handle(self.request) exceptions.handle(self.request)
return context return context

View File

@ -44,7 +44,7 @@ class ParseDateNode(template.Node):
if not timezone.is_aware(parsed): if not timezone.is_aware(parsed):
parsed = timezone.make_aware(parsed, timezone.utc) parsed = timezone.make_aware(parsed, timezone.utc)
return parsed return parsed
except: except Exception:
pass pass
return None return None

View File

@ -68,7 +68,7 @@ class IPField(forms.Field):
self.ip = netaddr.IPNetwork(value) self.ip = netaddr.IPNetwork(value)
else: else:
self.ip = netaddr.IPAddress(value) self.ip = netaddr.IPAddress(value)
except: except Exception:
raise ValidationError(self.invalid_format_message) raise ValidationError(self.invalid_format_message)
if not any([self.version & IPv4 > 0 and self.ip.version == 4, if not any([self.version & IPv4 > 0 and self.ip.version == 4,

View File

@ -48,6 +48,6 @@ class APIView(generic.TemplateView):
context = self.get_context_data(**kwargs) context = self.get_context_data(**kwargs)
try: try:
context = self.get_data(request, context, *args, **kwargs) context = self.get_data(request, context, *args, **kwargs)
except: except Exception:
exceptions.handle(request) exceptions.handle(request)
return self.render_to_response(context) return self.render_to_response(context)

View File

@ -373,7 +373,7 @@ class Step(object):
workflow_context) workflow_context)
self._action = self.action_class(self.workflow.request, self._action = self.action_class(self.workflow.request,
context) context)
except: except Exception:
LOG.exception("Problem instantiating action class.") LOG.exception("Problem instantiating action class.")
raise raise
return self._action return self._action
@ -795,7 +795,7 @@ class Workflow(html.HTMLElement):
partial = True partial = True
else: else:
self.context = step.contribute(data or {}, self.context) self.context = step.contribute(data or {}, self.context)
except: except Exception:
partial = True partial = True
exceptions.handle(self.request) exceptions.handle(self.request)
if not self.handle(self.request, self.context): if not self.handle(self.request, self.context):

View File

@ -134,7 +134,7 @@ class WorkflowView(generic.TemplateView):
if workflow.is_valid(): if workflow.is_valid():
try: try:
success = workflow.finalize() success = workflow.finalize()
except: except Exception:
success = False success = False
exceptions.handle(request) exceptions.handle(request)
next = self.request.REQUEST.get(workflow.redirect_param_name, None) next = self.request.REQUEST.get(workflow.redirect_param_name, None)

View File

@ -303,14 +303,14 @@ def user_update(request, user, **data):
# Update user details # Update user details
try: try:
user = manager.update(user, **data) user = manager.update(user, **data)
except: except Exception:
error = exceptions.handle(request, ignore=True) error = exceptions.handle(request, ignore=True)
# Update default tenant # Update default tenant
try: try:
user_update_tenant(request, user, project) user_update_tenant(request, user, project)
user.tenantId = project user.tenantId = project
except: except Exception:
error = exceptions.handle(request, ignore=True) error = exceptions.handle(request, ignore=True)
# Check for existing roles # Check for existing roles
@ -329,7 +329,7 @@ def user_update(request, user, **data):
user_update_password(request, user, password) user_update_password(request, user, password)
if user == request.user.id: if user == request.user.id:
logout(request) logout(request)
except: except Exception:
error = exceptions.handle(request, ignore=True) error = exceptions.handle(request, ignore=True)
if error is not None: if error is not None:
@ -491,7 +491,7 @@ def get_default_role(request):
if default and DEFAULT_ROLE is None: if default and DEFAULT_ROLE is None:
try: try:
roles = keystoneclient(request, admin=True).roles.list() roles = keystoneclient(request, admin=True).roles.list()
except: except Exception:
roles = [] roles = []
exceptions.handle(request) exceptions.handle(request)
for role in roles: for role in roles:

View File

@ -51,7 +51,7 @@ class Pool(NeutronAPIDictWrapper):
pFormatted['subnet_id'] = self.subnet_id pFormatted['subnet_id'] = self.subnet_id
pFormatted['subnet_name'] = subnet_get( pFormatted['subnet_name'] = subnet_get(
request, self.subnet_id).cidr request, self.subnet_id).cidr
except: except Exception:
pFormatted['subnet_id'] = self.subnet_id pFormatted['subnet_id'] = self.subnet_id
pFormatted['subnet_name'] = self.subnet_id pFormatted['subnet_name'] = self.subnet_id
@ -60,7 +60,7 @@ class Pool(NeutronAPIDictWrapper):
pFormatted['vip_id'] = self.vip_id pFormatted['vip_id'] = self.vip_id
pFormatted['vip_name'] = vip_get( pFormatted['vip_name'] = vip_get(
request, self.vip_id).name request, self.vip_id).name
except: except Exception:
pFormatted['vip_id'] = self.vip_id pFormatted['vip_id'] = self.vip_id
pFormatted['vip_name'] = self.vip_id pFormatted['vip_name'] = self.vip_id
else: else:
@ -91,7 +91,7 @@ class Member(NeutronAPIDictWrapper):
mFormatted['pool_id'] = self.pool_id mFormatted['pool_id'] = self.pool_id
mFormatted['pool_name'] = pool_get( mFormatted['pool_name'] = pool_get(
request, self.pool_id).name request, self.pool_id).name
except: except Exception:
mFormatted['pool_id'] = self.pool_id mFormatted['pool_id'] = self.pool_id
mFormatted['pool_name'] = self.pool_id mFormatted['pool_name'] = self.pool_id

View File

@ -165,7 +165,7 @@ class SecurityGroupRule(NeutronAPIDictWrapper):
try: try:
ip_proto = int(self.ip_protocol) ip_proto = int(self.ip_protocol)
proto_port = "ip_proto=%d" % ip_proto proto_port = "ip_proto=%d" % ip_proto
except: except Exception:
# well-defined IP protocol name like TCP, UDP, ICMP. # well-defined IP protocol name like TCP, UDP, ICMP.
proto_port = self.ip_protocol proto_port = self.ip_protocol
else: else:

View File

@ -35,7 +35,7 @@ class AdminIndexView(tables.DataTableView):
aggregates = [] aggregates = []
try: try:
aggregates = api.nova.aggregate_list(self.request) aggregates = api.nova.aggregate_list(self.request)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve aggregate list.')) _('Unable to retrieve aggregate list.'))

View File

@ -111,7 +111,7 @@ class SetDomainContext(tables.Action):
messages.success(request, messages.success(request,
_('Domain Context updated to Domain %s.') % _('Domain Context updated to Domain %s.') %
domain.name) domain.name)
except: except Exception:
messages.error(request, messages.error(request,
_('Unable to set Domain Context.')) _('Unable to set Domain Context.'))

View File

@ -50,7 +50,7 @@ class IndexView(tables.DataTableView):
domains.append(domain) domains.append(domain)
else: else:
domains = api.keystone.domain_list(self.request) domains = api.keystone.domain_list(self.request)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve domain list.')) _('Unable to retrieve domain list.'))
return domains return domains
@ -75,7 +75,7 @@ class UpdateDomainView(workflows.WorkflowView):
domain_id) domain_id)
for field in DOMAIN_INFO_FIELDS: for field in DOMAIN_INFO_FIELDS:
initial[field] = getattr(domain_info, field, None) initial[field] = getattr(domain_info, field, None)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve domain details.'), _('Unable to retrieve domain details.'),
redirect=reverse(DOMAINS_INDEX_URL)) redirect=reverse(DOMAINS_INDEX_URL))

View File

@ -76,7 +76,7 @@ class CreateDomain(workflows.Workflow):
name=data['name'], name=data['name'],
description=desc, description=desc,
enabled=data['enabled']) enabled=data['enabled'])
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
return False return False
@ -121,7 +121,7 @@ class UpdateDomain(workflows.Workflow):
name=data['name'], name=data['name'],
description=data['description'], description=data['description'],
enabled=data['enabled']) enabled=data['enabled'])
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
return False return False
return True return True

View File

@ -44,7 +44,7 @@ class CreateExtraSpec(forms.SelfHandlingForm):
msg = _('Created extra spec "%s".') % data['key'] msg = _('Created extra spec "%s".') % data['key']
messages.success(request, msg) messages.success(request, msg)
return True return True
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_("Unable to create flavor extra spec.")) _("Unable to create flavor extra spec."))
@ -63,5 +63,5 @@ class EditExtraSpec(forms.SelfHandlingForm):
msg = _('Saved extra spec "%s".') % data['key'] msg = _('Saved extra spec "%s".') % data['key']
messages.success(request, msg) messages.success(request, msg)
return True return True
except: except Exception:
exceptions.handle(request, _("Unable to edit extra spec.")) exceptions.handle(request, _("Unable to edit extra spec."))

View File

@ -45,7 +45,7 @@ class ExtraSpecMixin(object):
try: try:
context['flavor'] = api.nova.flavor_get(self.request, context['flavor'] = api.nova.flavor_get(self.request,
self.kwargs['id']) self.kwargs['id'])
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve flavor data.")) _("Unable to retrieve flavor data."))
return context return context
@ -60,7 +60,7 @@ class IndexView(ExtraSpecMixin, forms.ModalFormMixin, tables.DataTableView):
flavor_id = self.kwargs['id'] flavor_id = self.kwargs['id']
extras_list = api.nova.flavor_get_extras(self.request, flavor_id) extras_list = api.nova.flavor_get_extras(self.request, flavor_id)
extras_list.sort(key=lambda es: (es.key,)) extras_list.sort(key=lambda es: (es.key,))
except: except Exception:
extras_list = [] extras_list = []
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve extra spec list.')) _('Unable to retrieve extra spec list.'))
@ -89,7 +89,7 @@ class EditView(ExtraSpecMixin, forms.ModalFormView):
extra_specs = api.nova.flavor_get_extras(self.request, extra_specs = api.nova.flavor_get_extras(self.request,
flavor_id, flavor_id,
raw=True) raw=True)
except: except Exception:
extra_specs = {} extra_specs = {}
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve flavor extra spec data.")) _("Unable to retrieve flavor extra spec data."))

View File

@ -59,7 +59,7 @@ class CreateFlavor(forms.SelfHandlingForm):
name = self.cleaned_data.get('name') name = self.cleaned_data.get('name')
try: try:
flavors = api.nova.flavor_list(self.request) flavors = api.nova.flavor_list(self.request)
except: except Exception:
flavors = [] flavors = []
msg = _('Unable to get flavor list') msg = _('Unable to get flavor list')
exceptions.check_message(["Connection", "refused"], msg) exceptions.check_message(["Connection", "refused"], msg)
@ -77,7 +77,7 @@ class CreateFlavor(forms.SelfHandlingForm):
flavor_id = self.data.get('flavor_id') flavor_id = self.data.get('flavor_id')
try: try:
flavors = api.nova.flavor_list(self.request) flavors = api.nova.flavor_list(self.request)
except: except Exception:
flavors = [] flavors = []
msg = _('Unable to get flavor list') msg = _('Unable to get flavor list')
exceptions.check_message(["Connection", "refused"], msg) exceptions.check_message(["Connection", "refused"], msg)
@ -104,7 +104,7 @@ class CreateFlavor(forms.SelfHandlingForm):
msg = _('Created flavor "%s".') % data['name'] msg = _('Created flavor "%s".') % data['name']
messages.success(request, msg) messages.success(request, msg)
return flavor return flavor
except: except Exception:
exceptions.handle(request, _("Unable to create flavor.")) exceptions.handle(request, _("Unable to create flavor."))
@ -140,5 +140,5 @@ class EditFlavor(CreateFlavor):
msg = _('Updated flavor "%s".') % data['name'] msg = _('Updated flavor "%s".') % data['name']
messages.success(request, msg) messages.success(request, msg)
return flavor return flavor
except: except Exception:
exceptions.handle(request, _("Unable to update flavor.")) exceptions.handle(request, _("Unable to update flavor."))

View File

@ -46,7 +46,7 @@ class IndexView(tables.DataTableView):
flavors = [] flavors = []
try: try:
flavors = api.nova.flavor_list(request) flavors = api.nova.flavor_list(request)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve flavor list.')) _('Unable to retrieve flavor list.'))
# Sort flavors by size # Sort flavors by size
@ -73,7 +73,7 @@ class EditView(forms.ModalFormView):
def get_initial(self): def get_initial(self):
try: try:
flavor = api.nova.flavor_get(self.request, self.kwargs['id']) flavor = api.nova.flavor_get(self.request, self.kwargs['id'])
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve flavor data.")) _("Unable to retrieve flavor data."))
return {'flavor_id': flavor.id, return {'flavor_id': flavor.id,

View File

@ -47,7 +47,7 @@ class CreateGroupForm(forms.SelfHandlingForm):
messages.success(request, messages.success(request,
_('Group "%s" was successfully created.') _('Group "%s" was successfully created.')
% data['name']) % data['name'])
except: except Exception:
exceptions.handle(request, _('Unable to create group.')) exceptions.handle(request, _('Unable to create group.'))
return False return False
return True return True
@ -71,7 +71,7 @@ class UpdateGroupForm(forms.SelfHandlingForm):
description=data['description']) description=data['description'])
messages.success(request, messages.success(request,
_('Group has been updated successfully.')) _('Group has been updated successfully.'))
except: except Exception:
exceptions.handle(request, _('Unable to update the group.')) exceptions.handle(request, _('Unable to update the group.'))
return False return False
return True return True

View File

@ -64,7 +64,7 @@ class IndexView(tables.DataTableView):
if group.domain_id == domain_context: if group.domain_id == domain_context:
domain_groups.append(group) domain_groups.append(group)
groups = domain_groups groups = domain_groups
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve group list.')) _('Unable to retrieve group list.'))
return groups return groups
@ -86,7 +86,7 @@ class UpdateView(forms.ModalFormView):
try: try:
self._object = api.keystone.group_get(self.request, self._object = api.keystone.group_get(self.request,
self.kwargs['group_id']) self.kwargs['group_id'])
except: except Exception:
redirect = reverse(GROUPS_INDEX_URL) redirect = reverse(GROUPS_INDEX_URL)
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to update group.'), _('Unable to update group.'),
@ -144,7 +144,7 @@ class ManageMembersView(GroupManageMixin, tables.DataTableView):
group_members = [] group_members = []
try: try:
group_members = self._get_group_members() group_members = self._get_group_members()
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve group users.')) _('Unable to retrieve group users.'))
return group_members return group_members
@ -165,7 +165,7 @@ class NonMembersView(GroupManageMixin, forms.ModalFormMixin,
group_non_members = [] group_non_members = []
try: try:
group_non_members = self._get_group_non_members() group_non_members = self._get_group_non_members()
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve users.')) _('Unable to retrieve users.'))
return group_non_members return group_non_members

View File

@ -35,7 +35,7 @@ class AdminIndexView(tables.DataTableView):
hypervisors = [] hypervisors = []
try: try:
hypervisors = api.nova.hypervisor_list(self.request) hypervisors = api.nova.hypervisor_list(self.request)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve hypervisor list.')) _('Unable to retrieve hypervisor list.'))

View File

@ -56,7 +56,7 @@ class IndexView(tables.DataTableView):
images, self._more = api.glance.image_list_detailed(self.request, images, self._more = api.glance.image_list_detailed(self.request,
marker=marker, marker=marker,
paginate=True) paginate=True)
except: except Exception:
self._more = False self._more = False
msg = _('Unable to retrieve image list.') msg = _('Unable to retrieve image list.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)

View File

@ -39,7 +39,7 @@ class DefaultQuotasTab(tabs.TableTab):
try: try:
quota_set = quotas.get_default_quota_data(request) quota_set = quotas.get_default_quota_data(request)
data = quota_set.items data = quota_set.items
except: except Exception:
data = [] data = []
exceptions.handle(self.request, _('Unable to get quota info.')) exceptions.handle(self.request, _('Unable to get quota info.'))
return data return data

View File

@ -80,7 +80,7 @@ class AdminIndexView(tables.DataTableView):
search_opts={'marker': marker, search_opts={'marker': marker,
'paginate': True}, 'paginate': True},
all_tenants=True) all_tenants=True)
except: except Exception:
self._more = False self._more = False
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve instance list.')) _('Unable to retrieve instance list.'))
@ -88,14 +88,14 @@ class AdminIndexView(tables.DataTableView):
# Gather our flavors to correlate against IDs # Gather our flavors to correlate against IDs
try: try:
flavors = api.nova.flavor_list(self.request) flavors = api.nova.flavor_list(self.request)
except: except Exception:
# If fails to retrieve flavor list, creates an empty list. # If fails to retrieve flavor list, creates an empty list.
flavors = [] flavors = []
# Gather our tenants to correlate against IDs # Gather our tenants to correlate against IDs
try: try:
tenants, has_more = api.keystone.tenant_list(self.request) tenants, has_more = api.keystone.tenant_list(self.request)
except: except Exception:
tenants = [] tenants = []
msg = _('Unable to retrieve instance project information.') msg = _('Unable to retrieve instance project information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -113,7 +113,7 @@ class AdminIndexView(tables.DataTableView):
# gets it via nova api. # gets it via nova api.
inst.full_flavor = api.nova.flavor_get( inst.full_flavor = api.nova.flavor_get(
self.request, flavor_id) self.request, flavor_id)
except: except Exception:
msg = _('Unable to retrieve instance size information.') msg = _('Unable to retrieve instance size information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
tenant = tenant_dict.get(inst.tenant_id, None) tenant = tenant_dict.get(inst.tenant_id, None)

View File

@ -66,7 +66,7 @@ class CreateNetwork(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return network return network
except: except Exception:
redirect = reverse('horizon:admin:networks:index') redirect = reverse('horizon:admin:networks:index')
msg = _('Failed to create network %s') % data['name'] msg = _('Failed to create network %s') % data['name']
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)
@ -95,7 +95,7 @@ class UpdateNetwork(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return network return network
except: except Exception:
msg = _('Failed to update network %s') % data['name'] msg = _('Failed to update network %s') % data['name']
LOG.info(msg) LOG.info(msg)
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)

View File

@ -65,7 +65,7 @@ class CreatePort(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return port return port
except: except Exception:
msg = _('Failed to create a port for network %s') \ msg = _('Failed to create a port for network %s') \
% data['network_id'] % data['network_id']
LOG.info(msg) LOG.info(msg)

View File

@ -39,7 +39,7 @@ class DeletePort(tables.DeleteAction):
def delete(self, request, obj_id): def delete(self, request, obj_id):
try: try:
api.neutron.port_delete(request, obj_id) api.neutron.port_delete(request, obj_id)
except: except Exception:
msg = _('Failed to delete subnet %s') % obj_id msg = _('Failed to delete subnet %s') % obj_id
LOG.info(msg) LOG.info(msg)
network_id = self.table.kwargs['network_id'] network_id = self.table.kwargs['network_id']

View File

@ -37,7 +37,7 @@ class OverviewTab(tabs.Tab):
port_id = self.tab_group.kwargs['port_id'] port_id = self.tab_group.kwargs['port_id']
try: try:
port = api.neutron.port_get(self.request, port_id) port = api.neutron.port_get(self.request, port_id)
except: except Exception:
redirect = reverse('horizon:admin:networks:index') redirect = reverse('horizon:admin:networks:index')
msg = _('Unable to retrieve port details.') msg = _('Unable to retrieve port details.')
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)

View File

@ -50,7 +50,7 @@ class CreateView(forms.ModalFormView):
network_id = self.kwargs["network_id"] network_id = self.kwargs["network_id"]
self._object = api.neutron.network_get(self.request, self._object = api.neutron.network_get(self.request,
network_id) network_id)
except: except Exception:
redirect = reverse(self.failure_url, redirect = reverse(self.failure_url,
args=(self.kwargs['network_id'],)) args=(self.kwargs['network_id'],))
msg = _("Unable to retrieve network.") msg = _("Unable to retrieve network.")

View File

@ -35,7 +35,7 @@ class DeleteSubnet(tables.DeleteAction):
def delete(self, request, obj_id): def delete(self, request, obj_id):
try: try:
api.neutron.subnet_delete(request, obj_id) api.neutron.subnet_delete(request, obj_id)
except: except Exception:
msg = _('Failed to delete subnet %s') % obj_id msg = _('Failed to delete subnet %s') % obj_id
LOG.info(msg) LOG.info(msg)
network_id = self.table.kwargs['network_id'] network_id = self.table.kwargs['network_id']

View File

@ -44,7 +44,7 @@ class CreateSubnet(project_workflows.CreateSubnet):
# created for if admin user does not belong to the tenant. # created for if admin user does not belong to the tenant.
network = api.neutron.network_get(request, network = api.neutron.network_get(request,
self.context['network_id']) self.context['network_id'])
except: except Exception:
msg = (_('Failed to retrieve network %s for a subnet') % msg = (_('Failed to retrieve network %s for a subnet') %
data['network_id']) data['network_id'])
LOG.info(msg) LOG.info(msg)

View File

@ -37,7 +37,7 @@ class DeleteNetwork(tables.DeleteAction):
def delete(self, request, obj_id): def delete(self, request, obj_id):
try: try:
api.neutron.network_delete(request, obj_id) api.neutron.network_delete(request, obj_id)
except: except Exception:
msg = _('Failed to delete network %s') % obj_id msg = _('Failed to delete network %s') % obj_id
LOG.info(msg) LOG.info(msg)
redirect = reverse('horizon:admin:networks:index') redirect = reverse('horizon:admin:networks:index')

View File

@ -47,7 +47,7 @@ class IndexView(tables.DataTableView):
if not hasattr(self, "_tenants"): if not hasattr(self, "_tenants"):
try: try:
tenants, has_more = api.keystone.tenant_list(self.request) tenants, has_more = api.keystone.tenant_list(self.request)
except: except Exception:
tenants = [] tenants = []
msg = _('Unable to retrieve instance project information.') msg = _('Unable to retrieve instance project information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -59,7 +59,7 @@ class IndexView(tables.DataTableView):
def get_data(self): def get_data(self):
try: try:
networks = api.neutron.network_list(self.request) networks = api.neutron.network_list(self.request)
except: except Exception:
networks = [] networks = []
msg = _('Network list can not be retrieved.') msg = _('Network list can not be retrieved.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -90,7 +90,7 @@ class DetailView(tables.MultiTableView):
network_id = self.kwargs['network_id'] network_id = self.kwargs['network_id']
subnets = api.neutron.subnet_list(self.request, subnets = api.neutron.subnet_list(self.request,
network_id=network_id) network_id=network_id)
except: except Exception:
subnets = [] subnets = []
msg = _('Subnet list can not be retrieved.') msg = _('Subnet list can not be retrieved.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -102,7 +102,7 @@ class DetailView(tables.MultiTableView):
try: try:
network_id = self.kwargs['network_id'] network_id = self.kwargs['network_id']
ports = api.neutron.port_list(self.request, network_id=network_id) ports = api.neutron.port_list(self.request, network_id=network_id)
except: except Exception:
ports = [] ports = []
msg = _('Port list can not be retrieved.') msg = _('Port list can not be retrieved.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -116,7 +116,7 @@ class DetailView(tables.MultiTableView):
network_id = self.kwargs['network_id'] network_id = self.kwargs['network_id']
network = api.neutron.network_get(self.request, network_id) network = api.neutron.network_get(self.request, network_id)
network.set_id_as_name_if_empty(length=0) network.set_id_as_name_if_empty(length=0)
except: except Exception:
redirect = self.failure_url redirect = self.failure_url
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve details for ' _('Unable to retrieve details for '

View File

@ -60,7 +60,7 @@ class GlobalOverview(usage.UsageView):
# Pre-fill project names # Pre-fill project names
try: try:
projects, has_more = api.keystone.tenant_list(self.request) projects, has_more = api.keystone.tenant_list(self.request)
except: except Exception:
projects = [] projects = []
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve project list.')) _('Unable to retrieve project list.'))

View File

@ -54,7 +54,7 @@ class TenantContextMixin(object):
self._object = api.keystone.tenant_get(self.request, self._object = api.keystone.tenant_get(self.request,
tenant_id, tenant_id,
admin=True) admin=True)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve project information.'), _('Unable to retrieve project information.'),
redirect=reverse(INDEX_URL)) redirect=reverse(INDEX_URL))
@ -84,7 +84,7 @@ class IndexView(tables.DataTableView):
domain=domain_context, domain=domain_context,
paginate=True, paginate=True,
marker=marker) marker=marker)
except: except Exception:
self._more = False self._more = False
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve project list.")) _("Unable to retrieve project list."))
@ -113,7 +113,7 @@ class CreateProjectView(workflows.WorkflowView):
for field in quotas.QUOTA_FIELDS: for field in quotas.QUOTA_FIELDS:
initial[field] = quota_defaults.get(field).limit initial[field] = quota_defaults.get(field).limit
except: except Exception:
error_msg = _('Unable to retrieve default quota values.') error_msg = _('Unable to retrieve default quota values.')
self.add_error_to_step(error_msg, 'update_quotas') self.add_error_to_step(error_msg, 'update_quotas')
@ -141,7 +141,7 @@ class UpdateProjectView(workflows.WorkflowView):
tenant_id=project_id) tenant_id=project_id)
for field in quotas.QUOTA_FIELDS: for field in quotas.QUOTA_FIELDS:
initial[field] = quota_data.get(field).limit initial[field] = quota_data.get(field).limit
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve project details.'), _('Unable to retrieve project details.'),
redirect=reverse(INDEX_URL)) redirect=reverse(INDEX_URL))

View File

@ -129,7 +129,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction):
msg = _('Could not find default role "%s" in Keystone') % \ msg = _('Could not find default role "%s" in Keystone') % \
default default
raise exceptions.NotFound(msg) raise exceptions.NotFound(msg)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
err_msg, err_msg,
redirect=reverse(INDEX_URL)) redirect=reverse(INDEX_URL))
@ -143,7 +143,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction):
try: try:
all_users = api.keystone.user_list(request, all_users = api.keystone.user_list(request,
domain=domain_context) domain=domain_context)
except: except Exception:
exceptions.handle(request, err_msg) exceptions.handle(request, err_msg)
users_list = [(user.id, user.name) for user in all_users] users_list = [(user.id, user.name) for user in all_users]
@ -151,7 +151,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction):
role_list = [] role_list = []
try: try:
role_list = api.keystone.role_list(request) role_list = api.keystone.role_list(request)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
err_msg, err_msg,
redirect=reverse(INDEX_URL)) redirect=reverse(INDEX_URL))
@ -170,7 +170,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction):
roles = api.keystone.roles_for_user(self.request, roles = api.keystone.roles_for_user(self.request,
user.id, user.id,
project_id) project_id)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
err_msg, err_msg,
redirect=reverse(INDEX_URL)) redirect=reverse(INDEX_URL))
@ -194,7 +194,7 @@ class UpdateProjectMembers(workflows.UpdateMembersStep):
if data: if data:
try: try:
roles = api.keystone.role_list(self.workflow.request) roles = api.keystone.role_list(self.workflow.request)
except: except Exception:
exceptions.handle(self.workflow.request, exceptions.handle(self.workflow.request,
_('Unable to retrieve user list.')) _('Unable to retrieve user list.'))
@ -237,7 +237,7 @@ class CreateProject(workflows.Workflow):
description=desc, description=desc,
enabled=data['enabled'], enabled=data['enabled'],
domain=domain_context) domain=domain_context)
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
return False return False
@ -265,7 +265,7 @@ class CreateProject(workflows.Workflow):
role=role.id) role=role.id)
users_added += 1 users_added += 1
users_to_add -= users_added users_to_add -= users_added
except: except Exception:
exceptions.handle(request, _('Failed to add %s project members ' exceptions.handle(request, _('Failed to add %s project members '
'and set project quotas.') 'and set project quotas.')
% users_to_add) % users_to_add)
@ -281,7 +281,7 @@ class CreateProject(workflows.Workflow):
cinder.tenant_quota_update(request, cinder.tenant_quota_update(request,
project_id, project_id,
**cinder_data) **cinder_data)
except: except Exception:
exceptions.handle(request, _('Unable to set project quotas.')) exceptions.handle(request, _('Unable to set project quotas.'))
return True return True
@ -338,7 +338,7 @@ class UpdateProject(workflows.Workflow):
name=data['name'], name=data['name'],
description=data['description'], description=data['description'],
enabled=data['enabled']) enabled=data['enabled'])
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
return False return False
@ -427,7 +427,7 @@ class UpdateProject(workflows.Workflow):
role=role.id) role=role.id)
users_added += 1 users_added += 1
users_to_modify -= users_added users_to_modify -= users_added
except: except Exception:
exceptions.handle(request, _('Failed to modify %s project members ' exceptions.handle(request, _('Failed to modify %s project members '
'and update project quotas.') 'and update project quotas.')
% users_to_modify) % users_to_modify)
@ -447,7 +447,7 @@ class UpdateProject(workflows.Workflow):
project_id, project_id,
**cinder_data) **cinder_data)
return True return True
except: except Exception:
exceptions.handle(request, _('Modified project information and ' exceptions.handle(request, _('Modified project information and '
'members, but unable to modify ' 'members, but unable to modify '
'project quotas.')) 'project quotas.'))

View File

@ -31,7 +31,7 @@ class CreateRoleForm(forms.SelfHandlingForm):
new_user = api.keystone.role_create(request, data["name"]) new_user = api.keystone.role_create(request, data["name"])
messages.success(request, _("Role created successfully.")) messages.success(request, _("Role created successfully."))
return new_user return new_user
except: except Exception:
exceptions.handle(request, _('Unable to create role.')) exceptions.handle(request, _('Unable to create role.'))
@ -44,5 +44,5 @@ class UpdateRoleForm(forms.SelfHandlingForm):
api.keystone.role_update(request, data['id'], data["name"]) api.keystone.role_update(request, data['id'], data["name"])
messages.success(request, _("Role updated successfully.")) messages.success(request, _("Role updated successfully."))
return True return True
except: except Exception:
exceptions.handle(request, _('Unable to update role.')) exceptions.handle(request, _('Unable to update role.'))

View File

@ -37,7 +37,7 @@ class IndexView(tables.DataTableView):
roles = [] roles = []
try: try:
roles = api.keystone.role_list(self.request) roles = api.keystone.role_list(self.request)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve roles list.')) _('Unable to retrieve roles list.'))
return roles return roles
@ -53,7 +53,7 @@ class UpdateView(forms.ModalFormView):
try: try:
self._object = api.keystone.role_get(self.request, self._object = api.keystone.role_get(self.request,
self.kwargs['role_id']) self.kwargs['role_id'])
except: except Exception:
redirect = reverse("horizon:admin:roles:index") redirect = reverse("horizon:admin:roles:index")
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to update role.'), _('Unable to update role.'),

View File

@ -44,7 +44,7 @@ class IndexView(r_views.IndexView, n_views.IndexView):
try: try:
routers = api.neutron.router_list(self.request, routers = api.neutron.router_list(self.request,
search_opts=search_opts) search_opts=search_opts)
except: except Exception:
routers = [] routers = []
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve router list.')) _('Unable to retrieve router list.'))

View File

@ -115,12 +115,12 @@ class CreateUserForm(BaseUserForm):
data['project'], data['project'],
new_user.id, new_user.id,
data['role_id']) data['role_id'])
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to add user ' _('Unable to add user '
'to primary project.')) 'to primary project.'))
return new_user return new_user
except: except Exception:
exceptions.handle(request, _('Unable to create user.')) exceptions.handle(request, _('Unable to create user.'))
@ -162,7 +162,7 @@ class UpdateUserForm(BaseUserForm):
api.keystone.user_update(request, user, **data) api.keystone.user_update(request, user, **data)
messages.success(request, messages.success(request,
_('User has been updated successfully.')) _('User has been updated successfully.'))
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
messages.error(request, _('Unable to update the user.')) messages.error(request, _('Unable to update the user.'))
return True return True

View File

@ -47,7 +47,7 @@ class IndexView(tables.DataTableView):
try: try:
users = api.keystone.user_list(self.request, users = api.keystone.user_list(self.request,
domain=domain_context) domain=domain_context)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve user list.')) _('Unable to retrieve user list.'))
return users return users
@ -69,7 +69,7 @@ class UpdateView(forms.ModalFormView):
self._object = api.keystone.user_get(self.request, self._object = api.keystone.user_get(self.request,
self.kwargs['user_id'], self.kwargs['user_id'],
admin=True) admin=True)
except: except Exception:
redirect = reverse("horizon:admin:users:index") redirect = reverse("horizon:admin:users:index")
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to update user.'), _('Unable to update user.'),
@ -103,7 +103,7 @@ class CreateView(forms.ModalFormView):
kwargs = super(CreateView, self).get_form_kwargs() kwargs = super(CreateView, self).get_form_kwargs()
try: try:
roles = api.keystone.role_list(self.request) roles = api.keystone.role_list(self.request)
except: except Exception:
redirect = reverse("horizon:admin:users:index") redirect = reverse("horizon:admin:users:index")
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve user roles."), _("Unable to retrieve user roles."),

View File

@ -38,7 +38,7 @@ class CreateVolumeType(forms.SelfHandlingForm):
messages.success(request, _('Successfully created volume type: %s') messages.success(request, _('Successfully created volume type: %s')
% data['name']) % data['name'])
return volume_type return volume_type
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to create volume type.')) _('Unable to create volume type.'))
return False return False

View File

@ -53,7 +53,7 @@ class IndexView(tables.MultiTableView, VolumeTableMixIn):
# Gather our tenants to correlate against IDs # Gather our tenants to correlate against IDs
try: try:
tenants, has_more = keystone.tenant_list(self.request) tenants, has_more = keystone.tenant_list(self.request)
except: except Exception:
tenants = [] tenants = []
msg = _('Unable to retrieve volume project information.') msg = _('Unable to retrieve volume project information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -69,7 +69,7 @@ class IndexView(tables.MultiTableView, VolumeTableMixIn):
def get_volume_types_data(self): def get_volume_types_data(self):
try: try:
volume_types = cinder.volume_type_list(self.request) volume_types = cinder.volume_type_list(self.request)
except: except Exception:
volume_types = [] volume_types = []
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve volume types")) _("Unable to retrieve volume types"))

View File

@ -52,7 +52,7 @@ def download_ec2_bundle(request):
keys = api.keystone.create_ec2_credentials(request, keys = api.keystone.create_ec2_credentials(request,
request.user.id, request.user.id,
tenant_id) tenant_id)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to fetch EC2 credentials.'), _('Unable to fetch EC2 credentials.'),
redirect=request.build_absolute_uri()) redirect=request.build_absolute_uri())
@ -88,7 +88,7 @@ def download_ec2_bundle(request):
archive.writestr('cert.pem', credentials.data) archive.writestr('cert.pem', credentials.data)
archive.writestr('cacert.pem', cacert.data) archive.writestr('cacert.pem', cacert.data)
archive.writestr('ec2rc.sh', render_to_string(template, context)) archive.writestr('ec2rc.sh', render_to_string(template, context))
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Error writing zipfile: %(exc)s'), _('Error writing zipfile: %(exc)s'),
redirect=request.build_absolute_uri()) redirect=request.build_absolute_uri())

View File

@ -44,5 +44,5 @@ class FloatingIpAllocate(forms.SelfHandlingForm):
_('Allocated Floating IP %(ip)s.') _('Allocated Floating IP %(ip)s.')
% {"ip": fip.ip}) % {"ip": fip.ip})
return fip return fip
except: except Exception:
exceptions.handle(request, _('Unable to allocate Floating IP.')) exceptions.handle(request, _('Unable to allocate Floating IP.'))

View File

@ -91,7 +91,7 @@ class DisassociateIP(tables.Action):
messages.success(request, messages.success(request,
_('Successfully disassociated Floating IP: %s') _('Successfully disassociated Floating IP: %s')
% fip.ip) % fip.ip)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to disassociate floating IP.')) _('Unable to disassociate floating IP.'))
return shortcuts.redirect('horizon:project:access_and_security:index') return shortcuts.redirect('horizon:project:access_and_security:index')

View File

@ -55,14 +55,14 @@ class AllocateView(forms.ModalFormView):
context = super(AllocateView, self).get_context_data(**kwargs) context = super(AllocateView, self).get_context_data(**kwargs)
try: try:
context['usages'] = quotas.tenant_quota_usages(self.request) context['usages'] = quotas.tenant_quota_usages(self.request)
except: except Exception:
exceptions.handle(self.request) exceptions.handle(self.request)
return context return context
def get_initial(self): def get_initial(self):
try: try:
pools = api.network.floating_ip_pools_list(self.request) pools = api.network.floating_ip_pools_list(self.request)
except: except Exception:
pools = [] pools = []
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve floating IP pools.")) _("Unable to retrieve floating IP pools."))

View File

@ -63,7 +63,7 @@ class AssociateIPAction(workflows.Action):
def populate_ip_id_choices(self, request, context): def populate_ip_id_choices(self, request, context):
try: try:
ips = api.network.tenant_floating_ip_list(self.request) ips = api.network.tenant_floating_ip_list(self.request)
except: except Exception:
redirect = reverse('horizon:project:access_and_security:index') redirect = reverse('horizon:project:access_and_security:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve floating IP addresses.'), _('Unable to retrieve floating IP addresses.'),
@ -79,7 +79,7 @@ class AssociateIPAction(workflows.Action):
def populate_instance_id_choices(self, request, context): def populate_instance_id_choices(self, request, context):
try: try:
targets = api.network.floating_ip_target_list(self.request) targets = api.network.floating_ip_target_list(self.request)
except: except Exception:
redirect = reverse('horizon:project:access_and_security:index') redirect = reverse('horizon:project:access_and_security:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve instance list.'), _('Unable to retrieve instance list.'),
@ -137,7 +137,7 @@ class IPAssociationWorkflow(workflows.Workflow):
api.network.floating_ip_associate(request, api.network.floating_ip_associate(request,
data['ip_id'], data['ip_id'],
data['instance_id']) data['instance_id'])
except: except Exception:
exceptions.handle(request) exceptions.handle(request)
return False return False
return True return True

View File

@ -60,7 +60,7 @@ class ImportKeypair(forms.SelfHandlingForm):
messages.success(request, _('Successfully imported public key: %s') messages.success(request, _('Successfully imported public key: %s')
% data['name']) % data['name'])
return keypair return keypair
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
self.api_error(_('Unable to import keypair.')) self.api_error(_('Unable to import keypair.'))
return False return False

View File

@ -74,7 +74,7 @@ class GenerateView(View):
def get(self, request, keypair_name=None): def get(self, request, keypair_name=None):
try: try:
keypair = api.nova.keypair_create(request, keypair_name) keypair = api.nova.keypair_create(request, keypair_name)
except: except Exception:
redirect = reverse('horizon:project:access_and_security:index') redirect = reverse('horizon:project:access_and_security:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to create keypair: %(exc)s'), _('Unable to create keypair: %(exc)s'),

View File

@ -60,7 +60,7 @@ class CreateGroup(forms.SelfHandlingForm):
_('Successfully created security group: %s') _('Successfully created security group: %s')
% data['name']) % data['name'])
return sg return sg
except: except Exception:
redirect = reverse("horizon:project:access_and_security:index") redirect = reverse("horizon:project:access_and_security:index")
exceptions.handle(request, exceptions.handle(request,
_('Unable to create security group.'), _('Unable to create security group.'),
@ -346,7 +346,7 @@ class AddRule(forms.SelfHandlingForm):
messages.success(request, messages.success(request,
_('Successfully added rule: %s') % unicode(rule)) _('Successfully added rule: %s') % unicode(rule))
return rule return rule
except: except Exception:
redirect = reverse("horizon:project:access_and_security:" redirect = reverse("horizon:project:access_and_security:"
"security_groups:detail", args=[data['id']]) "security_groups:detail", args=[data['id']])
exceptions.handle(request, exceptions.handle(request,

View File

@ -54,7 +54,7 @@ class DetailView(tables.DataTableView):
sg_id = get_int_or_uuid(self.kwargs['security_group_id']) sg_id = get_int_or_uuid(self.kwargs['security_group_id'])
try: try:
self._sg = api.network.security_group_get(self.request, sg_id) self._sg = api.network.security_group_get(self.request, sg_id)
except: except Exception:
redirect = reverse('horizon:project:access_and_security:index') redirect = reverse('horizon:project:access_and_security:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve security group.'), _('Unable to retrieve security group.'),
@ -92,7 +92,7 @@ class AddRuleView(forms.ModalFormView):
try: try:
groups = api.network.security_group_list(self.request) groups = api.network.security_group_list(self.request)
except: except Exception:
groups = [] groups = []
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve security groups.")) _("Unable to retrieve security groups."))

View File

@ -48,7 +48,7 @@ class SecurityGroupsTab(tabs.TableTab):
def get_security_groups_data(self): def get_security_groups_data(self):
try: try:
security_groups = network.security_group_list(self.request) security_groups = network.security_group_list(self.request)
except: except Exception:
security_groups = [] security_groups = []
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve security groups.')) _('Unable to retrieve security groups.'))
@ -64,7 +64,7 @@ class KeypairsTab(tabs.TableTab):
def get_keypairs_data(self): def get_keypairs_data(self):
try: try:
keypairs = nova.keypair_list(self.request) keypairs = nova.keypair_list(self.request)
except: except Exception:
keypairs = [] keypairs = []
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve keypair list.')) _('Unable to retrieve keypair list.'))
@ -80,14 +80,14 @@ class FloatingIPsTab(tabs.TableTab):
def get_floating_ips_data(self): def get_floating_ips_data(self):
try: try:
floating_ips = network.tenant_floating_ip_list(self.request) floating_ips = network.tenant_floating_ip_list(self.request)
except: except Exception:
floating_ips = [] floating_ips = []
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve floating IP addresses.')) _('Unable to retrieve floating IP addresses.'))
try: try:
floating_ip_pools = network.floating_ip_pools_list(self.request) floating_ip_pools = network.floating_ip_pools_list(self.request)
except: except Exception:
floating_ip_pools = [] floating_ip_pools = []
messages.warning(self.request, messages.warning(self.request,
_('Unable to retrieve floating IP pools.')) _('Unable to retrieve floating IP pools.'))
@ -96,7 +96,7 @@ class FloatingIPsTab(tabs.TableTab):
instances = [] instances = []
try: try:
instances, has_more = nova.server_list(self.request) instances, has_more = nova.server_list(self.request)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve instance list.')) _('Unable to retrieve instance list.'))

View File

@ -68,7 +68,7 @@ class CreateContainer(forms.SelfHandlingForm):
subfolder_name) subfolder_name)
messages.success(request, _("Folder created successfully.")) messages.success(request, _("Folder created successfully."))
return True return True
except: except Exception:
exceptions.handle(request, _('Unable to create container.')) exceptions.handle(request, _('Unable to create container.'))
@ -97,7 +97,7 @@ class UploadObject(forms.SelfHandlingForm):
object_file) object_file)
messages.success(request, _("Object was successfully uploaded.")) messages.success(request, _("Object was successfully uploaded."))
return obj return obj
except: except Exception:
exceptions.handle(request, _("Unable to upload object.")) exceptions.handle(request, _("Unable to upload object."))
@ -146,7 +146,7 @@ class CopyObject(forms.SelfHandlingForm):
messages.error(request, exc) messages.error(request, exc)
raise exceptions.Http302(reverse(index, raise exceptions.Http302(reverse(index,
args=[wrap_delimiter(orig_container)])) args=[wrap_delimiter(orig_container)]))
except: except Exception:
redirect = reverse(index, args=[wrap_delimiter(orig_container)]) redirect = reverse(index, args=[wrap_delimiter(orig_container)])
exceptions.handle(request, exceptions.handle(request,
_("Unable to copy object."), _("Unable to copy object."),

View File

@ -56,7 +56,7 @@ class ContainerView(browsers.ResourceBrowserView):
try: try:
containers, self._more = api.swift.swift_get_containers( containers, self._more = api.swift.swift_get_containers(
self.request, marker=marker) self.request, marker=marker)
except: except Exception:
msg = _('Unable to retrieve container list.') msg = _('Unable to retrieve container list.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return containers return containers
@ -84,7 +84,7 @@ class ContainerView(browsers.ResourceBrowserView):
container_name, container_name,
marker=marker, marker=marker,
prefix=prefix) prefix=prefix)
except: except Exception:
self._more = None self._more = None
objects = [] objects = []
msg = _('Unable to retrieve object list.') msg = _('Unable to retrieve object list.')
@ -169,7 +169,7 @@ class UploadView(forms.ModalFormView):
def object_download(request, container_name, object_path): def object_download(request, container_name, object_path):
try: try:
obj = api.swift.swift_get_object(request, container_name, object_path) obj = api.swift.swift_get_object(request, container_name, object_path)
except: except Exception:
redirect = reverse("horizon:project:containers:index") redirect = reverse("horizon:project:containers:index")
exceptions.handle(request, exceptions.handle(request,
_("Unable to retrieve object."), _("Unable to retrieve object."),
@ -204,7 +204,7 @@ class CopyView(forms.ModalFormView):
kwargs = super(CopyView, self).get_form_kwargs() kwargs = super(CopyView, self).get_form_kwargs()
try: try:
containers = api.swift.swift_get_containers(self.request) containers = api.swift.swift_get_containers(self.request)
except: except Exception:
redirect = reverse("horizon:project:containers:index") redirect = reverse("horizon:project:containers:index")
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to list containers.'), _('Unable to list containers.'),

View File

@ -157,7 +157,7 @@ class CreateImageForm(forms.SelfHandlingForm):
_('Your image %s has been queued for creation.') % _('Your image %s has been queued for creation.') %
data['name']) data['name'])
return image return image
except: except Exception:
exceptions.handle(request, _('Unable to create new image.')) exceptions.handle(request, _('Unable to create new image.'))
@ -219,5 +219,5 @@ class UpdateImageForm(forms.SelfHandlingForm):
image = api.glance.image_update(request, image_id, **meta) image = api.glance.image_update(request, image_id, **meta)
messages.success(request, _('Image was successfully updated.')) messages.success(request, _('Image was successfully updated.'))
return image return image
except: except Exception:
exceptions.handle(request, error_updating % image_id) exceptions.handle(request, error_updating % image_id)

View File

@ -32,7 +32,7 @@ class OverviewTab(tabs.Tab):
image_id = self.tab_group.kwargs['image_id'] image_id = self.tab_group.kwargs['image_id']
try: try:
image = api.glance.image_get(self.request, image_id) image = api.glance.image_get(self.request, image_id)
except: except Exception:
redirect = reverse('horizon:project:images_and_snapshots:index') redirect = reverse('horizon:project:images_and_snapshots:index')
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve image details.'), _('Unable to retrieve image details.'),

View File

@ -62,7 +62,7 @@ class UpdateView(forms.ModalFormView):
try: try:
self._object = api.glance.image_get(self.request, self._object = api.glance.image_get(self.request,
self.kwargs['image_id']) self.kwargs['image_id'])
except: except Exception:
msg = _('Unable to retrieve image.') msg = _('Unable to retrieve image.')
url = reverse('horizon:project:images_and_snapshots:index') url = reverse('horizon:project:images_and_snapshots:index')
exceptions.handle(self.request, msg, redirect=url) exceptions.handle(self.request, msg, redirect=url)

View File

@ -50,7 +50,7 @@ class CreateSnapshot(forms.SelfHandlingForm):
messages.success(request, _('Snapshot "%(name)s" created for ' messages.success(request, _('Snapshot "%(name)s" created for '
'instance "%(inst)s"') % vals) 'instance "%(inst)s"') % vals)
return snapshot return snapshot
except: except Exception:
redirect = reverse("horizon:project:instances:index") redirect = reverse("horizon:project:instances:index")
exceptions.handle(request, exceptions.handle(request,
_('Unable to create snapshot.'), _('Unable to create snapshot.'),

View File

@ -50,7 +50,7 @@ class CreateView(forms.ModalFormView):
try: try:
self._object = api.nova.server_get(self.request, self._object = api.nova.server_get(self.request,
self.kwargs["instance_id"]) self.kwargs["instance_id"])
except: except Exception:
redirect = reverse('horizon:project:instances:index') redirect = reverse('horizon:project:instances:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve instance."), _("Unable to retrieve instance."),

View File

@ -27,7 +27,7 @@ def get_available_images(request, project_id=None, images_cache=None):
request, filters=public) request, filters=public)
[public_images.append(image) for image in images] [public_images.append(image) for image in images]
images_cache['public_images'] = public_images images_cache['public_images'] = public_images
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_("Unable to retrieve public images.")) _("Unable to retrieve public images."))
@ -41,7 +41,7 @@ def get_available_images(request, project_id=None, images_cache=None):
try: try:
owned_images, _more = glance.image_list_detailed( owned_images, _more = glance.image_list_detailed(
request, filters=owner) request, filters=owner)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_("Unable to retrieve images for " _("Unable to retrieve images for "
"the current project.")) "the current project."))

View File

@ -61,7 +61,7 @@ class IndexView(tables.MultiTableView):
marker=marker) marker=marker)
images = [im for im in all_images images = [im for im in all_images
if im.container_format not in ['aki', 'ari']] if im.container_format not in ['aki', 'ari']]
except: except Exception:
images = [] images = []
exceptions.handle(self.request, _("Unable to retrieve images.")) exceptions.handle(self.request, _("Unable to retrieve images."))
return images return images
@ -70,7 +70,7 @@ class IndexView(tables.MultiTableView):
if is_service_enabled(self.request, 'volume'): if is_service_enabled(self.request, 'volume'):
try: try:
snapshots = api.cinder.volume_snapshot_list(self.request) snapshots = api.cinder.volume_snapshot_list(self.request)
except: except Exception:
snapshots = [] snapshots = []
exceptions.handle(self.request, _("Unable to retrieve " exceptions.handle(self.request, _("Unable to retrieve "
"volume snapshots.")) "volume snapshots."))

View File

@ -35,7 +35,7 @@ class OverviewTab(tabs.Tab):
snapshot = cinder.volume_snapshot_get(request, snapshot_id) snapshot = cinder.volume_snapshot_get(request, snapshot_id)
volume = cinder.volume_get(request, snapshot.volume_id) volume = cinder.volume_get(request, snapshot.volume_id)
volume.display_name = None volume.display_name = None
except: except Exception:
redirect = reverse('horizon:project:images_and_snapshots:index') redirect = reverse('horizon:project:images_and_snapshots:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve snapshot details.'), _('Unable to retrieve snapshot details.'),

View File

@ -208,7 +208,7 @@ class LaunchLink(tables.LinkAction):
self.verbose_name = _("Launch Instance") self.verbose_name = _("Launch Instance")
classes = [c for c in self.classes if c != "disabled"] classes = [c for c in self.classes if c != "disabled"]
self.classes = classes self.classes = classes
except: except Exception:
LOG.exception("Failed to retrieve quota information") LOG.exception("Failed to retrieve quota information")
# If we can't get the quota information, leave it to the # If we can't get the quota information, leave it to the
# API to check when launching # API to check when launching
@ -376,7 +376,7 @@ class SimpleAssociateIP(tables.Action):
messages.success(request, messages.success(request,
_("Successfully associated floating IP: %s") _("Successfully associated floating IP: %s")
% fip.ip) % fip.ip)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_("Unable to associate floating IP.")) _("Unable to associate floating IP."))
return shortcuts.redirect("horizon:project:instances:index") return shortcuts.redirect("horizon:project:instances:index")
@ -413,7 +413,7 @@ class SimpleDisassociateIP(tables.Action):
"floating IP: %s") % fip.ip) "floating IP: %s") % fip.ip)
else: else:
messages.info(request, _("No floating IPs to disassociate.")) messages.info(request, _("No floating IPs to disassociate."))
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_("Unable to disassociate floating IP.")) _("Unable to disassociate floating IP."))
return shortcuts.redirect("horizon:project:instances:index") return shortcuts.redirect("horizon:project:instances:index")

View File

@ -45,7 +45,7 @@ class LogTab(tabs.Tab):
data = api.nova.server_console_output(request, data = api.nova.server_console_output(request,
instance.id, instance.id,
tail_length=35) tail_length=35)
except: except Exception:
data = _('Unable to get log for instance "%s".') % instance.id data = _('Unable to get log for instance "%s".') % instance.id
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
return {"instance": instance, return {"instance": instance,
@ -70,7 +70,7 @@ class ConsoleTab(tabs.Tab):
console.url, console.url,
getattr(instance, "name", ""), getattr(instance, "name", ""),
instance.id) instance.id)
except: except Exception:
try: try:
console = api.nova.server_spice_console(request, console = api.nova.server_spice_console(request,
instance.id) instance.id)
@ -78,7 +78,7 @@ class ConsoleTab(tabs.Tab):
console.url, console.url,
getattr(instance, "name", ""), getattr(instance, "name", ""),
instance.id) instance.id)
except: except Exception:
console_url = None console_url = None
elif console_type == 'VNC': elif console_type == 'VNC':
try: try:
@ -87,7 +87,7 @@ class ConsoleTab(tabs.Tab):
console.url, console.url,
getattr(instance, "name", ""), getattr(instance, "name", ""),
instance.id) instance.id)
except: except Exception:
console_url = None console_url = None
elif console_type == 'SPICE': elif console_type == 'SPICE':
try: try:
@ -96,7 +96,7 @@ class ConsoleTab(tabs.Tab):
console.url, console.url,
getattr(instance, "name", ""), getattr(instance, "name", ""),
instance.id) instance.id)
except: except Exception:
console_url = None console_url = None
else: else:
console_url = None console_url = None

View File

@ -67,7 +67,7 @@ class IndexView(tables.DataTableView):
self.request, self.request,
search_opts={'marker': marker, search_opts={'marker': marker,
'paginate': True}) 'paginate': True})
except: except Exception:
self._more = False self._more = False
instances = [] instances = []
exceptions.handle(self.request, exceptions.handle(self.request,
@ -76,7 +76,7 @@ class IndexView(tables.DataTableView):
if instances: if instances:
try: try:
flavors = api.nova.flavor_list(self.request) flavors = api.nova.flavor_list(self.request)
except: except Exception:
flavors = [] flavors = []
exceptions.handle(self.request, ignore=True) exceptions.handle(self.request, ignore=True)
@ -93,7 +93,7 @@ class IndexView(tables.DataTableView):
# get it via nova api. # get it via nova api.
instance.full_flavor = api.nova.flavor_get( instance.full_flavor = api.nova.flavor_get(
self.request, flavor_id) self.request, flavor_id)
except: except Exception:
msg = _('Unable to retrieve instance size information.') msg = _('Unable to retrieve instance size information.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return instances return instances
@ -116,7 +116,7 @@ def console(request, instance_id):
data = api.nova.server_console_output(request, data = api.nova.server_console_output(request,
instance_id, instance_id,
tail_length=tail) tail_length=tail)
except: except Exception:
data = _('Unable to get log for instance "%s".') % instance_id data = _('Unable to get log for instance "%s".') % instance_id
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
response = http.HttpResponse(mimetype='text/plain') response = http.HttpResponse(mimetype='text/plain')
@ -131,7 +131,7 @@ def vnc(request, instance_id):
instance = api.nova.server_get(request, instance_id) instance = api.nova.server_get(request, instance_id)
return shortcuts.redirect(console.url + return shortcuts.redirect(console.url +
("&title=%s(%s)" % (instance.name, instance_id))) ("&title=%s(%s)" % (instance.name, instance_id)))
except: except Exception:
redirect = reverse("horizon:project:instances:index") redirect = reverse("horizon:project:instances:index")
msg = _('Unable to get VNC console for instance "%s".') % instance_id msg = _('Unable to get VNC console for instance "%s".') % instance_id
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)
@ -143,7 +143,7 @@ def spice(request, instance_id):
instance = api.nova.server_get(request, instance_id) instance = api.nova.server_get(request, instance_id)
return shortcuts.redirect(console.url + return shortcuts.redirect(console.url +
("&title=%s(%s)" % (instance.name, instance_id))) ("&title=%s(%s)" % (instance.name, instance_id)))
except: except Exception:
redirect = reverse("horizon:project:instances:index") redirect = reverse("horizon:project:instances:index")
msg = _('Unable to get SPICE console for instance "%s".') % instance_id msg = _('Unable to get SPICE console for instance "%s".') % instance_id
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)
@ -163,7 +163,7 @@ class UpdateView(workflows.WorkflowView):
instance_id = self.kwargs['instance_id'] instance_id = self.kwargs['instance_id']
try: try:
self._object = api.nova.server_get(self.request, instance_id) self._object = api.nova.server_get(self.request, instance_id)
except: except Exception:
redirect = reverse("horizon:project:instances:index") redirect = reverse("horizon:project:instances:index")
msg = _('Unable to retrieve instance details.') msg = _('Unable to retrieve instance details.')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -198,7 +198,7 @@ class DetailView(tabs.TabView):
self.request, instance.flavor["id"]) self.request, instance.flavor["id"])
instance.security_groups = api.network.server_security_groups( instance.security_groups = api.network.server_security_groups(
self.request, instance_id) self.request, instance_id)
except: except Exception:
redirect = reverse('horizon:project:instances:index') redirect = reverse('horizon:project:instances:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve details for ' _('Unable to retrieve details for '
@ -233,7 +233,7 @@ class ResizeView(workflows.WorkflowView):
else: else:
flavor = api.nova.flavor_get(self.request, flavor_id) flavor = api.nova.flavor_get(self.request, flavor_id)
self._object.flavor_name = flavor.name self._object.flavor_name = flavor.name
except: except Exception:
redirect = reverse("horizon:project:instances:index") redirect = reverse("horizon:project:instances:index")
msg = _('Unable to retrieve instance details.') msg = _('Unable to retrieve instance details.')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -245,7 +245,7 @@ class ResizeView(workflows.WorkflowView):
flavors = api.nova.flavor_list(self.request) flavors = api.nova.flavor_list(self.request)
self._flavors = SortedDict([(str(flavor.id), flavor) self._flavors = SortedDict([(str(flavor.id), flavor)
for flavor in flavors]) for flavor in flavors])
except: except Exception:
redirect = reverse("horizon:project:instances:index") redirect = reverse("horizon:project:instances:index")
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve flavors.'), redirect=redirect) _('Unable to retrieve flavors.'), redirect=redirect)

View File

@ -128,7 +128,7 @@ class VolumeOptionsAction(workflows.Action):
if v.status == api.cinder.VOLUME_STATE_AVAILABLE] if v.status == api.cinder.VOLUME_STATE_AVAILABLE]
volume_options.extend([self._get_volume_display_name(vol) volume_options.extend([self._get_volume_display_name(vol)
for vol in volumes]) for vol in volumes])
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve list of volumes.')) _('Unable to retrieve list of volumes.'))
return volume_options return volume_options
@ -141,7 +141,7 @@ class VolumeOptionsAction(workflows.Action):
if s.status == api.cinder.VOLUME_STATE_AVAILABLE] if s.status == api.cinder.VOLUME_STATE_AVAILABLE]
volume_options.extend([self._get_volume_display_name(snap) volume_options.extend([self._get_volume_display_name(snap)
for snap in snapshots]) for snap in snapshots])
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve list of volume ' _('Unable to retrieve list of volume '
'snapshots.')) 'snapshots.'))
@ -277,7 +277,7 @@ class SetInstanceDetailsAction(workflows.Action):
flavor_list = [(flavor.id, "%s" % flavor.name) flavor_list = [(flavor.id, "%s" % flavor.name)
for flavor in sorted(flavors, key=key, reverse=rev)] for flavor in sorted(flavors, key=key, reverse=rev)]
except: except Exception:
flavor_list = [] flavor_list = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve instance flavors.')) _('Unable to retrieve instance flavors.'))
@ -286,7 +286,7 @@ class SetInstanceDetailsAction(workflows.Action):
def populate_availability_zone_choices(self, request, context): def populate_availability_zone_choices(self, request, context):
try: try:
zones = api.nova.availability_zone_list(request) zones = api.nova.availability_zone_list(request)
except: except Exception:
zones = [] zones = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve availability zones.')) _('Unable to retrieve availability zones.'))
@ -308,7 +308,7 @@ class SetInstanceDetailsAction(workflows.Action):
flavors = json.dumps([f._info for f in flavors = json.dumps([f._info for f in
api.nova.flavor_list(self.request)]) api.nova.flavor_list(self.request)])
extra['flavors'] = flavors extra['flavors'] = flavors
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve quota information.")) _("Unable to retrieve quota information."))
return super(SetInstanceDetailsAction, self).get_help_text(extra) return super(SetInstanceDetailsAction, self).get_help_text(extra)
@ -373,7 +373,7 @@ class SetAccessControlsAction(workflows.Action):
try: try:
keypairs = api.nova.keypair_list(request) keypairs = api.nova.keypair_list(request)
keypair_list = [(kp.name, kp.name) for kp in keypairs] keypair_list = [(kp.name, kp.name) for kp in keypairs]
except: except Exception:
keypair_list = [] keypair_list = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve keypairs.')) _('Unable to retrieve keypairs.'))
@ -389,7 +389,7 @@ class SetAccessControlsAction(workflows.Action):
try: try:
groups = api.network.security_group_list(request) groups = api.network.security_group_list(request)
security_group_list = [(sg.name, sg.name) for sg in groups] security_group_list = [(sg.name, sg.name) for sg in groups]
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve list of security groups')) _('Unable to retrieve list of security groups'))
security_group_list = [] security_group_list = []
@ -465,7 +465,7 @@ class SetNetworkAction(workflows.Action):
for n in networks: for n in networks:
n.set_id_as_name_if_empty() n.set_id_as_name_if_empty()
network_list = [(network.id, network.name) for network in networks] network_list = [(network.id, network.name) for network in networks]
except: except Exception:
network_list = [] network_list = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve networks.')) _('Unable to retrieve networks.'))
@ -550,6 +550,6 @@ class LaunchInstance(workflows.Workflow):
instance_count=int(context['count']), instance_count=int(context['count']),
admin_pass=context['admin_pass']) admin_pass=context['admin_pass'])
return True return True
except: except Exception:
exceptions.handle(request) exceptions.handle(request)
return False return False

View File

@ -75,7 +75,7 @@ class SetFlavorChoiceAction(workflows.Action):
flavors = json.dumps([f._info for f in flavors = json.dumps([f._info for f in
api.nova.flavor_list(self.request)]) api.nova.flavor_list(self.request)])
extra['flavors'] = flavors extra['flavors'] = flavors
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_("Unable to retrieve quota information.")) _("Unable to retrieve quota information."))
return super(SetFlavorChoiceAction, self).get_help_text(extra) return super(SetFlavorChoiceAction, self).get_help_text(extra)
@ -106,6 +106,6 @@ class ResizeInstance(workflows.Workflow):
try: try:
api.nova.server_resize(request, instance_id, flavor) api.nova.server_resize(request, instance_id, flavor)
return True return True
except: except Exception:
exceptions.handle(request) exceptions.handle(request)
return False return False

View File

@ -51,7 +51,7 @@ class UpdateInstanceSecurityGroupsAction(workflows.MembershipAction):
all_groups = [] all_groups = []
try: try:
all_groups = api.network.security_group_list(request) all_groups = api.network.security_group_list(request)
except: except Exception:
exceptions.handle(request, err_msg) exceptions.handle(request, err_msg)
groups_list = [(group.id, group.name) for group in all_groups] groups_list = [(group.id, group.name) for group in all_groups]
@ -111,7 +111,7 @@ class UpdateInstanceInfoAction(workflows.Action):
api.nova.server_update(request, api.nova.server_update(request,
data['instance_id'], data['instance_id'],
data['name']) data['name'])
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
return False return False
return True return True

View File

@ -63,7 +63,7 @@ class UpdatePool(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return pool return pool
except: except Exception:
msg = _('Failed to update pool %s') % context['name'] msg = _('Failed to update pool %s') % context['name']
LOG.info(msg) LOG.info(msg)
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)
@ -101,7 +101,7 @@ class UpdateVip(forms.SelfHandlingForm):
pool_id_choices = [] pool_id_choices = []
try: try:
pools = api.lbaas.pools_get(request) pools = api.lbaas.pools_get(request)
except: except Exception:
pools = [] pools = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve pools list.')) _('Unable to retrieve pools list.'))
@ -144,7 +144,7 @@ class UpdateVip(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return vip return vip
except: except Exception:
msg = _('Failed to update VIP %s') % context['name'] msg = _('Failed to update VIP %s') % context['name']
LOG.info(msg) LOG.info(msg)
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)
@ -169,7 +169,7 @@ class UpdateMember(forms.SelfHandlingForm):
pool_id_choices = [] pool_id_choices = []
try: try:
pools = api.lbaas.pools_get(request) pools = api.lbaas.pools_get(request)
except: except Exception:
pools = [] pools = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve pools list.')) _('Unable to retrieve pools list.'))
@ -191,7 +191,7 @@ class UpdateMember(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return member return member
except: except Exception:
msg = _('Failed to update member %s') % context['member_id'] msg = _('Failed to update member %s') % context['member_id']
LOG.info(msg) LOG.info(msg)
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)
@ -238,7 +238,7 @@ class UpdateMonitor(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return monitor return monitor
except: except Exception:
msg = _('Failed to update health monitor %s')\ msg = _('Failed to update health monitor %s')\
% context['monitor_id'] % context['monitor_id']
LOG.info(msg) LOG.info(msg)

View File

@ -166,7 +166,7 @@ class AddPMAssociationLink(tables.LinkAction):
for m in monitors: for m in monitors:
if m.id not in datum['health_monitors']: if m.id not in datum['health_monitors']:
return True return True
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Failed to retrieve health monitors.')) _('Failed to retrieve health monitors.'))
return False return False

View File

@ -41,7 +41,7 @@ class PoolsTab(tabs.TableTab):
pools = api.lbaas.pools_get(self.tab_group.request) pools = api.lbaas.pools_get(self.tab_group.request)
poolsFormatted = [p.readable(self.tab_group.request) for poolsFormatted = [p.readable(self.tab_group.request) for
p in pools] p in pools]
except: except Exception:
poolsFormatted = [] poolsFormatted = []
exceptions.handle(self.tab_group.request, exceptions.handle(self.tab_group.request,
_('Unable to retrieve pools list.')) _('Unable to retrieve pools list.'))
@ -59,7 +59,7 @@ class MembersTab(tabs.TableTab):
members = api.lbaas.members_get(self.tab_group.request) members = api.lbaas.members_get(self.tab_group.request)
membersFormatted = [m.readable(self.tab_group.request) for membersFormatted = [m.readable(self.tab_group.request) for
m in members] m in members]
except: except Exception:
membersFormatted = [] membersFormatted = []
exceptions.handle(self.tab_group.request, exceptions.handle(self.tab_group.request,
_('Unable to retrieve member list.')) _('Unable to retrieve member list.'))
@ -76,7 +76,7 @@ class MonitorsTab(tabs.TableTab):
try: try:
monitors = api.lbaas.pool_health_monitors_get( monitors = api.lbaas.pool_health_monitors_get(
self.tab_group.request) self.tab_group.request)
except: except Exception:
monitors = [] monitors = []
exceptions.handle(self.tab_group.request, exceptions.handle(self.tab_group.request,
_('Unable to retrieve monitor list.')) _('Unable to retrieve monitor list.'))
@ -98,7 +98,7 @@ class PoolDetailsTab(tabs.Tab):
pid = self.tab_group.kwargs['pool_id'] pid = self.tab_group.kwargs['pool_id']
try: try:
pool = api.lbaas.pool_get(request, pid) pool = api.lbaas.pool_get(request, pid)
except: except Exception:
pool = [] pool = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve pool details.')) _('Unable to retrieve pool details.'))
@ -114,7 +114,7 @@ class VipDetailsTab(tabs.Tab):
vid = self.tab_group.kwargs['vip_id'] vid = self.tab_group.kwargs['vip_id']
try: try:
vip = api.lbaas.vip_get(request, vid) vip = api.lbaas.vip_get(request, vid)
except: except Exception:
vip = [] vip = []
exceptions.handle(self.tab_group.request, exceptions.handle(self.tab_group.request,
_('Unable to retrieve VIP details.')) _('Unable to retrieve VIP details.'))
@ -130,7 +130,7 @@ class MemberDetailsTab(tabs.Tab):
mid = self.tab_group.kwargs['member_id'] mid = self.tab_group.kwargs['member_id']
try: try:
member = api.lbaas.member_get(request, mid) member = api.lbaas.member_get(request, mid)
except: except Exception:
member = [] member = []
exceptions.handle(self.tab_group.request, exceptions.handle(self.tab_group.request,
_('Unable to retrieve member details.')) _('Unable to retrieve member details.'))
@ -146,7 +146,7 @@ class MonitorDetailsTab(tabs.Tab):
mid = self.tab_group.kwargs['monitor_id'] mid = self.tab_group.kwargs['monitor_id']
try: try:
monitor = api.lbaas.pool_health_monitor_get(request, mid) monitor = api.lbaas.pool_health_monitor_get(request, mid)
except: except Exception:
monitor = [] monitor = []
exceptions.handle(self.tab_group.request, exceptions.handle(self.tab_group.request,
_('Unable to retrieve monitor details.')) _('Unable to retrieve monitor details.'))

View File

@ -75,34 +75,34 @@ class IndexView(tabs.TabView):
for obj_id in obj_ids: for obj_id in obj_ids:
try: try:
api.lbaas.pool_health_monitor_delete(request, obj_id) api.lbaas.pool_health_monitor_delete(request, obj_id)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to delete monitor.')) _('Unable to delete monitor.'))
if m == 'pool': if m == 'pool':
for obj_id in obj_ids: for obj_id in obj_ids:
try: try:
api.lbaas.pool_delete(request, obj_id) api.lbaas.pool_delete(request, obj_id)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Must delete VIP first.')) _('Must delete VIP first.'))
if m == 'member': if m == 'member':
for obj_id in obj_ids: for obj_id in obj_ids:
try: try:
api.lbaas.member_delete(request, obj_id) api.lbaas.member_delete(request, obj_id)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to delete member.')) _('Unable to delete member.'))
if m == 'vip': if m == 'vip':
for obj_id in obj_ids: for obj_id in obj_ids:
try: try:
vip_id = api.lbaas.pool_get(request, obj_id).vip_id vip_id = api.lbaas.pool_get(request, obj_id).vip_id
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to locate VIP to delete.')) _('Unable to locate VIP to delete.'))
if vip_id is not None: if vip_id is not None:
try: try:
api.lbaas.vip_delete(request, vip_id) api.lbaas.vip_delete(request, vip_id)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to delete VIP.')) _('Unable to delete VIP.'))
return self.get(request, *args, **kwargs) return self.get(request, *args, **kwargs)
@ -130,7 +130,7 @@ class AddVipView(workflows.WorkflowView):
pool = api.lbaas.pool_get(self.request, initial['pool_id']) pool = api.lbaas.pool_get(self.request, initial['pool_id'])
initial['subnet'] = api.neutron.subnet_get( initial['subnet'] = api.neutron.subnet_get(
self.request, pool.subnet_id).cidr self.request, pool.subnet_id).cidr
except: except Exception:
initial['subnet'] = '' initial['subnet'] = ''
msg = _('Unable to retrieve pool subnet.') msg = _('Unable to retrieve pool subnet.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -189,7 +189,7 @@ class UpdatePoolView(forms.ModalFormView):
pool_id = self.kwargs['pool_id'] pool_id = self.kwargs['pool_id']
try: try:
self._object = api.lbaas.pool_get(self.request, pool_id) self._object = api.lbaas.pool_get(self.request, pool_id)
except: except Exception:
redirect = self.success_url redirect = self.success_url
msg = _('Unable to retrieve pool details.') msg = _('Unable to retrieve pool details.')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -220,7 +220,7 @@ class UpdateVipView(forms.ModalFormView):
vip_id = self.kwargs['vip_id'] vip_id = self.kwargs['vip_id']
try: try:
self._object = api.lbaas.vip_get(self.request, vip_id) self._object = api.lbaas.vip_get(self.request, vip_id)
except: except Exception:
redirect = self.success_url redirect = self.success_url
msg = _('Unable to retrieve vip details.') msg = _('Unable to retrieve vip details.')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -260,7 +260,7 @@ class UpdateMemberView(forms.ModalFormView):
member_id = self.kwargs['member_id'] member_id = self.kwargs['member_id']
try: try:
self._object = api.lbaas.member_get(self.request, member_id) self._object = api.lbaas.member_get(self.request, member_id)
except: except Exception:
redirect = self.success_url redirect = self.success_url
msg = _('Unable to retrieve member details.') msg = _('Unable to retrieve member details.')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -291,7 +291,7 @@ class UpdateMonitorView(forms.ModalFormView):
try: try:
self._object = api.lbaas.pool_health_monitor_get( self._object = api.lbaas.pool_health_monitor_get(
self.request, monitor_id) self.request, monitor_id)
except: except Exception:
redirect = self.success_url redirect = self.success_url
msg = _('Unable to retrieve health monitor details.') msg = _('Unable to retrieve health monitor details.')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -316,7 +316,7 @@ class AddPMAssociationView(workflows.WorkflowView):
pool = api.lbaas.pool_get(self.request, initial['pool_id']) pool = api.lbaas.pool_get(self.request, initial['pool_id'])
initial['pool_name'] = pool.name initial['pool_name'] = pool.name
initial['pool_monitors'] = pool.health_monitors initial['pool_monitors'] = pool.health_monitors
except: except Exception:
msg = _('Unable to retrieve pool.') msg = _('Unable to retrieve pool.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return initial return initial
@ -332,7 +332,7 @@ class DeletePMAssociationView(workflows.WorkflowView):
pool = api.lbaas.pool_get(self.request, initial['pool_id']) pool = api.lbaas.pool_get(self.request, initial['pool_id'])
initial['pool_name'] = pool.name initial['pool_name'] = pool.name
initial['pool_monitors'] = pool.health_monitors initial['pool_monitors'] = pool.health_monitors
except: except Exception:
msg = _('Unable to retrieve pool.') msg = _('Unable to retrieve pool.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
return initial return initial

View File

@ -49,7 +49,7 @@ class AddPoolAction(workflows.Action):
subnet_id_choices = [('', _("Select a Subnet"))] subnet_id_choices = [('', _("Select a Subnet"))]
try: try:
networks = api.neutron.network_list_for_tenant(request, tenant_id) networks = api.neutron.network_list_for_tenant(request, tenant_id)
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve networks list.')) _('Unable to retrieve networks list.'))
networks = [] networks = []
@ -109,7 +109,7 @@ class AddPool(workflows.Workflow):
try: try:
api.lbaas.pool_create(request, **context) api.lbaas.pool_create(request, **context)
return True return True
except: except Exception:
return False return False
@ -225,7 +225,7 @@ class AddVip(workflows.Workflow):
try: try:
pool = api.lbaas.pool_get(request, context['pool_id']) pool = api.lbaas.pool_get(request, context['pool_id'])
context['subnet_id'] = pool['subnet_id'] context['subnet_id'] = pool['subnet_id']
except: except Exception:
context['subnet_id'] = None context['subnet_id'] = None
self.failure_message = _('Unable to retrieve the specified pool. ' self.failure_message = _('Unable to retrieve the specified pool. '
'Unable to add VIP "%s".') 'Unable to add VIP "%s".')
@ -245,7 +245,7 @@ class AddVip(workflows.Workflow):
try: try:
api.lbaas.vip_create(request, **context) api.lbaas.vip_create(request, **context)
return True return True
except: except Exception:
return False return False
@ -275,7 +275,7 @@ class AddMemberAction(workflows.Action):
pool_id_choices = [('', _("Select a Pool"))] pool_id_choices = [('', _("Select a Pool"))]
try: try:
pools = api.lbaas.pools_get(request) pools = api.lbaas.pools_get(request)
except: except Exception:
pools = [] pools = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve pools list.')) _('Unable to retrieve pools list.'))
@ -288,7 +288,7 @@ class AddMemberAction(workflows.Action):
members_choices = [] members_choices = []
try: try:
servers, has_more = api.nova.server_list(request) servers, has_more = api.nova.server_list(request)
except: except Exception:
servers = [] servers = []
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve instances list.')) _('Unable to retrieve instances list.'))
@ -345,14 +345,14 @@ class AddMember(workflows.Workflow):
params = {'device_id': m} params = {'device_id': m}
try: try:
plist = api.neutron.port_list(request, **params) plist = api.neutron.port_list(request, **params)
except: except Exception:
return False return False
if plist: if plist:
context['address'] = plist[0].fixed_ips[0]['ip_address'] context['address'] = plist[0].fixed_ips[0]['ip_address']
try: try:
context['member_id'] = api.lbaas.member_create( context['member_id'] = api.lbaas.member_create(
request, **context).id request, **context).id
except: except Exception:
return False return False
return True return True
@ -486,7 +486,7 @@ class AddMonitor(workflows.Workflow):
context['monitor_id'] = api.lbaas.pool_health_monitor_create( context['monitor_id'] = api.lbaas.pool_health_monitor_create(
request, **context).get('id') request, **context).get('id')
return True return True
except: except Exception:
exceptions.handle(request, _("Unable to add monitor.")) exceptions.handle(request, _("Unable to add monitor."))
return False return False
@ -507,7 +507,7 @@ class AddPMAssociationAction(workflows.Action):
for m in monitors: for m in monitors:
if m.id not in context['pool_monitors']: if m.id not in context['pool_monitors']:
monitor_id_choices.append((m.id, m.id)) monitor_id_choices.append((m.id, m.id))
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve monitors list.')) _('Unable to retrieve monitors list.'))
self.fields['monitor_id'].choices = monitor_id_choices self.fields['monitor_id'].choices = monitor_id_choices
@ -545,7 +545,7 @@ class AddPMAssociation(workflows.Workflow):
context['monitor_id'] = api.lbaas.pool_monitor_association_create( context['monitor_id'] = api.lbaas.pool_monitor_association_create(
request, **context) request, **context)
return True return True
except: except Exception:
exceptions.handle(request, _("Unable to add association.")) exceptions.handle(request, _("Unable to add association."))
return False return False
@ -565,7 +565,7 @@ class DeletePMAssociationAction(workflows.Action):
try: try:
for m_id in context['pool_monitors']: for m_id in context['pool_monitors']:
monitor_id_choices.append((m_id, m_id)) monitor_id_choices.append((m_id, m_id))
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve monitors list.')) _('Unable to retrieve monitors list.'))
self.fields['monitor_id'].choices = monitor_id_choices self.fields['monitor_id'].choices = monitor_id_choices
@ -604,6 +604,6 @@ class DeletePMAssociation(workflows.Workflow):
context['monitor_id'] = api.lbaas.pool_monitor_association_delete( context['monitor_id'] = api.lbaas.pool_monitor_association_delete(
request, **context) request, **context)
return True return True
except: except Exception:
exceptions.handle(request, _("Unable to delete association.")) exceptions.handle(request, _("Unable to delete association."))
return False return False

View File

@ -53,7 +53,7 @@ class JSONView(View):
# Get nova data # Get nova data
try: try:
servers, more = api.nova.server_list(request) servers, more = api.nova.server_list(request)
except: except Exception:
servers = [] servers = []
data['servers'] = [{'name': server.name, data['servers'] = [{'name': server.name,
'status': server.status, 'status': server.status,
@ -73,7 +73,7 @@ class JSONView(View):
tenant_id=request.user.tenant_id) tenant_id=request.user.tenant_id)
neutron_routers = api.neutron.router_list(request, neutron_routers = api.neutron.router_list(request,
tenant_id=request.user.tenant_id) tenant_id=request.user.tenant_id)
except: except Exception:
neutron_public_networks = [] neutron_public_networks = []
neutron_networks = [] neutron_networks = []
neutron_subnets = [] neutron_subnets = []

View File

@ -52,7 +52,7 @@ class UpdateNetwork(forms.SelfHandlingForm):
LOG.debug(msg) LOG.debug(msg)
messages.success(request, msg) messages.success(request, msg)
return network return network
except: except Exception:
msg = _('Failed to update network %s') % data['name'] msg = _('Failed to update network %s') % data['name']
LOG.info(msg) LOG.info(msg)
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)

View File

@ -37,7 +37,7 @@ class OverviewTab(tabs.Tab):
port_id = self.tab_group.kwargs['port_id'] port_id = self.tab_group.kwargs['port_id']
try: try:
port = api.neutron.port_get(self.request, port_id) port = api.neutron.port_get(self.request, port_id)
except: except Exception:
redirect = reverse('horizon:project:networks:index') redirect = reverse('horizon:project:networks:index')
msg = _('Unable to retrieve port details.') msg = _('Unable to retrieve port details.')
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)

View File

@ -49,7 +49,7 @@ class UpdateView(forms.ModalFormView):
port_id = self.kwargs['port_id'] port_id = self.kwargs['port_id']
try: try:
self._object = api.neutron.port_get(self.request, port_id) self._object = api.neutron.port_get(self.request, port_id)
except: except Exception:
redirect = reverse("horizon:project:networks:detail", redirect = reverse("horizon:project:networks:detail",
args=(self.kwargs['network_id'],)) args=(self.kwargs['network_id'],))
msg = _('Unable to retrieve port details') msg = _('Unable to retrieve port details')

View File

@ -48,7 +48,7 @@ class DeleteSubnet(CheckNetworkEditable, tables.DeleteAction):
def delete(self, request, obj_id): def delete(self, request, obj_id):
try: try:
api.neutron.subnet_delete(request, obj_id) api.neutron.subnet_delete(request, obj_id)
except: except Exception:
msg = _('Failed to delete subnet %s') % obj_id msg = _('Failed to delete subnet %s') % obj_id
LOG.info(msg) LOG.info(msg)
network_id = self.table.kwargs['network_id'] network_id = self.table.kwargs['network_id']
@ -93,7 +93,7 @@ class SubnetsTable(tables.DataTable):
network_id = self.kwargs['network_id'] network_id = self.kwargs['network_id']
network = api.neutron.network_get(self.request, network_id) network = api.neutron.network_get(self.request, network_id)
network.set_id_as_name_if_empty(length=0) network.set_id_as_name_if_empty(length=0)
except: except Exception:
msg = _('Unable to retrieve details for network "%s".') \ msg = _('Unable to retrieve details for network "%s".') \
% (network_id) % (network_id)
exceptions.handle(self.request, msg, redirect=self.failure_url) exceptions.handle(self.request, msg, redirect=self.failure_url)

View File

@ -37,7 +37,7 @@ class OverviewTab(tabs.Tab):
subnet_id = self.tab_group.kwargs['subnet_id'] subnet_id = self.tab_group.kwargs['subnet_id']
try: try:
subnet = api.neutron.subnet_get(self.request, subnet_id) subnet = api.neutron.subnet_get(self.request, subnet_id)
except: except Exception:
redirect = reverse('horizon:project:networks:index') redirect = reverse('horizon:project:networks:index')
msg = _('Unable to retrieve subnet details.') msg = _('Unable to retrieve subnet details.')
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)

View File

@ -49,7 +49,7 @@ class CreateView(workflows.WorkflowView):
self._object = api.neutron.network_get(self.request, self._object = api.neutron.network_get(self.request,
network_id) network_id)
self._object.set_id_as_name_if_empty() self._object.set_id_as_name_if_empty()
except: except Exception:
redirect = reverse('horizon:project:networks:index') redirect = reverse('horizon:project:networks:index')
msg = _("Unable to retrieve network.") msg = _("Unable to retrieve network.")
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -69,7 +69,7 @@ class UpdateView(workflows.WorkflowView):
subnet_id = self.kwargs['subnet_id'] subnet_id = self.kwargs['subnet_id']
try: try:
self._object = api.neutron.subnet_get(self.request, subnet_id) self._object = api.neutron.subnet_get(self.request, subnet_id)
except: except Exception:
redirect = reverse("horizon:project:networks:index") redirect = reverse("horizon:project:networks:index")
msg = _('Unable to retrieve subnet details') msg = _('Unable to retrieve subnet details')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)

View File

@ -55,7 +55,7 @@ class DeleteNetwork(CheckNetworkEditable, tables.DeleteAction):
api.neutron.network_delete(request, network_id) api.neutron.network_delete(request, network_id)
LOG.debug('Deleted network %s successfully' % network_id) LOG.debug('Deleted network %s successfully' % network_id)
except: except Exception:
msg = _('Failed to delete network %s') % network_id msg = _('Failed to delete network %s') % network_id
LOG.info(msg) LOG.info(msg)
redirect = reverse("horizon:project:networks:index") redirect = reverse("horizon:project:networks:index")

View File

@ -52,7 +52,7 @@ class IndexView(tables.DataTableView):
tenant_id = self.request.user.tenant_id tenant_id = self.request.user.tenant_id
networks = api.neutron.network_list_for_tenant(self.request, networks = api.neutron.network_list_for_tenant(self.request,
tenant_id) tenant_id)
except: except Exception:
networks = [] networks = []
msg = _('Network list can not be retrieved.') msg = _('Network list can not be retrieved.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -85,7 +85,7 @@ class UpdateView(forms.ModalFormView):
try: try:
self._object = api.neutron.network_get(self.request, self._object = api.neutron.network_get(self.request,
network_id) network_id)
except: except Exception:
redirect = self.success_url redirect = self.success_url
msg = _('Unable to retrieve network details.') msg = _('Unable to retrieve network details.')
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -109,7 +109,7 @@ class DetailView(tables.MultiTableView):
network = self._get_data() network = self._get_data()
subnets = api.neutron.subnet_list(self.request, subnets = api.neutron.subnet_list(self.request,
network_id=network.id) network_id=network.id)
except: except Exception:
subnets = [] subnets = []
msg = _('Subnet list can not be retrieved.') msg = _('Subnet list can not be retrieved.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -121,7 +121,7 @@ class DetailView(tables.MultiTableView):
try: try:
network_id = self.kwargs['network_id'] network_id = self.kwargs['network_id']
ports = api.neutron.port_list(self.request, network_id=network_id) ports = api.neutron.port_list(self.request, network_id=network_id)
except: except Exception:
ports = [] ports = []
msg = _('Port list can not be retrieved.') msg = _('Port list can not be retrieved.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)
@ -135,7 +135,7 @@ class DetailView(tables.MultiTableView):
network_id = self.kwargs['network_id'] network_id = self.kwargs['network_id']
network = api.neutron.network_get(self.request, network_id) network = api.neutron.network_get(self.request, network_id)
network.set_id_as_name_if_empty(length=0) network.set_id_as_name_if_empty(length=0)
except: except Exception:
msg = _('Unable to retrieve details for network "%s".') \ msg = _('Unable to retrieve details for network "%s".') \
% (network_id) % (network_id)
exceptions.handle(self.request, msg, redirect=self.failure_url) exceptions.handle(self.request, msg, redirect=self.failure_url)

View File

@ -351,7 +351,7 @@ class CreateNetwork(workflows.Workflow):
messages.info(request, msg) messages.info(request, msg)
raise exceptions.Http302(redirect) raise exceptions.Http302(redirect)
#return exceptions.RecoverableError #return exceptions.RecoverableError
except: except Exception:
msg = _('Failed to delete network "%s"') % network.name msg = _('Failed to delete network "%s"') % network.name
LOG.info(msg) LOG.info(msg)
redirect = self.get_failure_url() redirect = self.get_failure_url()

View File

@ -33,7 +33,7 @@ class CreateForm(forms.SelfHandlingForm):
message = _('Router %s was successfully created.') % data['name'] message = _('Router %s was successfully created.') % data['name']
messages.success(request, message) messages.success(request, message)
return router return router
except: except Exception:
msg = _('Failed to create router "%s".') % data['name'] msg = _('Failed to create router "%s".') % data['name']
LOG.info(msg) LOG.info(msg)
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)

View File

@ -96,7 +96,7 @@ class AddInterface(forms.SelfHandlingForm):
self._handle_error(request, router_id, e) self._handle_error(request, router_id, e)
try: try:
port = api.neutron.port_get(request, router_inf['port_id']) port = api.neutron.port_get(request, router_inf['port_id'])
except: except Exception:
# Ignore an error when port_get() since it is just # Ignore an error when port_get() since it is just
# to get an IP address for the interface. # to get an IP address for the interface.
port = None port = None
@ -107,7 +107,7 @@ class AddInterface(forms.SelfHandlingForm):
subnet_id = data['subnet_id'] subnet_id = data['subnet_id']
try: try:
subnet = api.neutron.subnet_get(request, subnet_id) subnet = api.neutron.subnet_get(request, subnet_id)
except: except Exception:
msg = _('Unable to get subnet "%s"') % subnet_id msg = _('Unable to get subnet "%s"') % subnet_id
self._handle_error(request, router_id, msg) self._handle_error(request, router_id, msg)
try: try:
@ -135,7 +135,7 @@ class AddInterface(forms.SelfHandlingForm):
def _delete_port(self, request, port): def _delete_port(self, request, port):
try: try:
api.neutron.port_delete(request, port.id) api.neutron.port_delete(request, port.id)
except: except Exception:
msg = _('Failed to delete port %s') % port.id msg = _('Failed to delete port %s') % port.id
LOG.info(msg) LOG.info(msg)
exceptions.handle(request, msg) exceptions.handle(request, msg)

View File

@ -63,7 +63,7 @@ class RemoveInterface(tables.DeleteAction):
api.neutron.router_remove_interface(request, api.neutron.router_remove_interface(request,
router_id, router_id,
port_id=obj_id) port_id=obj_id)
except: except Exception:
msg = _('Failed to delete interface %s') % obj_id msg = _('Failed to delete interface %s') % obj_id
LOG.info(msg) LOG.info(msg)
router_id = self.table.kwargs['router_id'] router_id = self.table.kwargs['router_id']

View File

@ -35,7 +35,7 @@ class OverviewTab(tabs.Tab):
port_id = self.tab_group.kwargs['port_id'] port_id = self.tab_group.kwargs['port_id']
try: try:
port = api.neutron.port_get(self.request, port_id) port = api.neutron.port_get(self.request, port_id)
except: except Exception:
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)
msg = _('Unable to retrieve port details.') msg = _('Unable to retrieve port details.')
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)

View File

@ -51,7 +51,7 @@ class AddInterfaceView(forms.ModalFormView):
router_id = self.kwargs["router_id"] router_id = self.kwargs["router_id"]
self._object = api.neutron.router_get(self.request, self._object = api.neutron.router_get(self.request,
router_id) router_id)
except: except Exception:
redirect = reverse(self.failure_url, args=[router_id]) redirect = reverse(self.failure_url, args=[router_id])
msg = _("Unable to retrieve router.") msg = _("Unable to retrieve router.")
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)
@ -83,7 +83,7 @@ class SetGatewayView(forms.ModalFormView):
router_id = self.kwargs["router_id"] router_id = self.kwargs["router_id"]
self._object = api.neutron.router_get(self.request, self._object = api.neutron.router_get(self.request,
router_id) router_id)
except: except Exception:
redirect = reverse(self.failure_url) redirect = reverse(self.failure_url)
msg = _("Unable to set gateway.") msg = _("Unable to set gateway.")
exceptions.handle(self.request, msg, redirect=redirect) exceptions.handle(self.request, msg, redirect=redirect)

View File

@ -32,7 +32,7 @@ class OverviewTab(tabs.Tab):
router_id = self.tab_group.kwargs['router_id'] router_id = self.tab_group.kwargs['router_id']
try: try:
router = api.neutron.router_get(request, router_id) router = api.neutron.router_get(request, router_id)
except: except Exception:
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve router details.'), _('Unable to retrieve router details.'),
redirect=reverse(self.redirect_url)) redirect=reverse(self.redirect_url))

View File

@ -48,7 +48,7 @@ class IndexView(tables.DataTableView):
routers = api.neutron.router_list(self.request, routers = api.neutron.router_list(self.request,
tenant_id=tenant_id, tenant_id=tenant_id,
search_opts=search_opts) search_opts=search_opts)
except: except Exception:
routers = [] routers = []
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve router list.')) _('Unable to retrieve router list.'))
@ -100,7 +100,7 @@ class DetailView(tables.MultiTableView):
router_id = self.kwargs['router_id'] router_id = self.kwargs['router_id']
router = api.neutron.router_get(self.request, router_id) router = api.neutron.router_get(self.request, router_id)
router.set_id_as_name_if_empty(length=0) router.set_id_as_name_if_empty(length=0)
except: except Exception:
msg = _('Unable to retrieve details for router "%s".') \ msg = _('Unable to retrieve details for router "%s".') \
% (router_id) % (router_id)
exceptions.handle(self.request, msg, redirect=self.failure_url) exceptions.handle(self.request, msg, redirect=self.failure_url)
@ -131,7 +131,7 @@ class DetailView(tables.MultiTableView):
device_id = self.kwargs['router_id'] device_id = self.kwargs['router_id']
ports = api.neutron.port_list(self.request, ports = api.neutron.port_list(self.request,
device_id=device_id) device_id=device_id)
except: except Exception:
ports = [] ports = []
msg = _('Port list can not be retrieved.') msg = _('Port list can not be retrieved.')
exceptions.handle(self.request, msg) exceptions.handle(self.request, msg)

View File

@ -22,7 +22,7 @@ class Stack(object):
def d3_data(request, stack_id=''): def d3_data(request, stack_id=''):
try: try:
stack = stack_get(request, stack_id) stack = stack_get(request, stack_id)
except: except Exception:
stack = Stack() stack = Stack()
stack.id = stack_id stack.id = stack_id
stack.stack_name = request.session.get('stack_name', '') stack.stack_name = request.session.get('stack_name', '')
@ -31,7 +31,7 @@ def d3_data(request, stack_id=''):
try: try:
resources = resources_list(request, stack.stack_name) resources = resources_list(request, stack.stack_name)
except: except Exception:
resources = [] resources = []
d3_data = {"nodes": [], "stack": {}} d3_data = {"nodes": [], "stack": {}}

View File

@ -74,7 +74,7 @@ class StackEventsTab(tabs.Tab):
stack_identifier = '%s/%s' % (stack.stack_name, stack.id) stack_identifier = '%s/%s' % (stack.stack_name, stack.id)
events = api.heat.events_list(self.request, stack_identifier) events = api.heat.events_list(self.request, stack_identifier)
LOG.debug('got events %s' % events) LOG.debug('got events %s' % events)
except: except Exception:
events = [] events = []
messages.error(request, _( messages.error(request, _(
'Unable to get events for stack "%s".') % stack.stack_name) 'Unable to get events for stack "%s".') % stack.stack_name)
@ -94,7 +94,7 @@ class StackResourcesTab(tabs.Tab):
stack_identifier = '%s/%s' % (stack.stack_name, stack.id) stack_identifier = '%s/%s' % (stack.stack_name, stack.id)
resources = api.heat.resources_list(self.request, stack_identifier) resources = api.heat.resources_list(self.request, stack_identifier)
LOG.debug('got resources %s' % resources) LOG.debug('got resources %s' % resources)
except: except Exception:
resources = [] resources = []
messages.error(request, _( messages.error(request, _(
'Unable to get resources for stack "%s".') % stack.stack_name) 'Unable to get resources for stack "%s".') % stack.stack_name)

View File

@ -48,7 +48,7 @@ class IndexView(tables.DataTableView):
request = self.request request = self.request
try: try:
stacks = api.heat.stacks_list(self.request) stacks = api.heat.stacks_list(self.request)
except: except Exception:
exceptions.handle(request, _('Unable to retrieve stack list.')) exceptions.handle(request, _('Unable to retrieve stack list.'))
stacks = [] stacks = []
return stacks return stacks
@ -107,7 +107,7 @@ class DetailView(tabs.TabView):
self._stack = stack self._stack = stack
request.session['stack_id'] = stack.id request.session['stack_id'] = stack.id
request.session['stack_name'] = stack.stack_name request.session['stack_name'] = stack.stack_name
except: except Exception:
msg = _("Unable to retrieve stack.") msg = _("Unable to retrieve stack.")
redirect = reverse('horizon:project:stacks:index') redirect = reverse('horizon:project:stacks:index')
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)
@ -136,7 +136,7 @@ class ResourceView(tabs.TabView):
kwargs['stack_id'], kwargs['stack_id'],
kwargs['resource_name']) kwargs['resource_name'])
self._resource = resource self._resource = resource
except: except Exception:
msg = _("Unable to retrieve resource.") msg = _("Unable to retrieve resource.")
redirect = reverse('horizon:project:stacks:index') redirect = reverse('horizon:project:stacks:index')
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)
@ -150,7 +150,7 @@ class ResourceView(tabs.TabView):
kwargs['stack_id'], kwargs['stack_id'],
kwargs['resource_name']) kwargs['resource_name'])
self._metadata = json.dumps(metadata, indent=2) self._metadata = json.dumps(metadata, indent=2)
except: except Exception:
msg = _("Unable to retrieve metadata.") msg = _("Unable to retrieve metadata.")
redirect = reverse('horizon:project:stacks:index') redirect = reverse('horizon:project:stacks:index')
exceptions.handle(request, msg, redirect=redirect) exceptions.handle(request, msg, redirect=redirect)

View File

@ -95,14 +95,14 @@ class CreateForm(forms.SelfHandlingForm):
orig_volume = cinder.volume_get(request, orig_volume = cinder.volume_get(request,
snapshot.volume_id) snapshot.volume_id)
self.fields['type'].initial = orig_volume.volume_type self.fields['type'].initial = orig_volume.volume_type
except: except Exception:
pass pass
self.fields['size'].help_text = _('Volume size must be equal ' self.fields['size'].help_text = _('Volume size must be equal '
'to or greater than the snapshot size (%sGB)' 'to or greater than the snapshot size (%sGB)'
% snapshot.size) % snapshot.size)
del self.fields['image_source'] del self.fields['image_source']
del self.fields['volume_source_type'] del self.fields['volume_source_type']
except: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to load the specified snapshot.')) _('Unable to load the specified snapshot.'))
elif ('image_id' in request.GET): elif ('image_id' in request.GET):
@ -118,7 +118,7 @@ class CreateForm(forms.SelfHandlingForm):
% filesizeformat(image.size)) % filesizeformat(image.size))
del self.fields['snapshot_source'] del self.fields['snapshot_source']
del self.fields['volume_source_type'] del self.fields['volume_source_type']
except: except Exception:
msg = _('Unable to load the specified image. %s') msg = _('Unable to load the specified image. %s')
exceptions.handle(request, msg % request.GET['image_id']) exceptions.handle(request, msg % request.GET['image_id'])
else: else:
@ -134,7 +134,7 @@ class CreateForm(forms.SelfHandlingForm):
self.fields['snapshot_source'].choices = choices self.fields['snapshot_source'].choices = choices
else: else:
del self.fields['snapshot_source'] del self.fields['snapshot_source']
except: except Exception:
exceptions.handle(request, _("Unable to retrieve " exceptions.handle(request, _("Unable to retrieve "
"volume snapshots.")) "volume snapshots."))
@ -236,7 +236,7 @@ class CreateForm(forms.SelfHandlingForm):
except ValidationError as e: except ValidationError as e:
self.api_error(e.messages[0]) self.api_error(e.messages[0])
return False return False
except: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
self.api_error(_("Unable to create volume.")) self.api_error(_("Unable to create volume."))
return False return False
@ -316,7 +316,7 @@ class AttachForm(forms.SelfHandlingForm):
"dev": attach.device} "dev": attach.device}
messages.info(request, message) messages.info(request, message)
return True return True
except: except Exception:
redirect = reverse("horizon:project:volumes:index") redirect = reverse("horizon:project:volumes:index")
exceptions.handle(request, exceptions.handle(request,
_('Unable to attach volume.'), _('Unable to attach volume.'),
@ -346,7 +346,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm):
message = _('Creating volume snapshot "%s"') % data['name'] message = _('Creating volume snapshot "%s"') % data['name']
messages.info(request, message) messages.info(request, message)
return snapshot return snapshot
except: except Exception:
redirect = reverse("horizon:project:images_and_snapshots:index") redirect = reverse("horizon:project:images_and_snapshots:index")
exceptions.handle(request, exceptions.handle(request,
_('Unable to create volume snapshot.'), _('Unable to create volume snapshot.'),

View File

@ -45,7 +45,7 @@ class DeleteVolume(tables.DeleteAction):
name = self.table.get_object_display(obj) name = self.table.get_object_display(obj)
try: try:
cinder.volume_delete(request, obj_id) cinder.volume_delete(request, obj_id)
except: except Exception:
msg = _('Unable to delete volume "%s". One or more snapshots ' msg = _('Unable to delete volume "%s". One or more snapshots '
'depend on it.') 'depend on it.')
exceptions.check_message(["snapshots", "dependent"], msg % name) exceptions.check_message(["snapshots", "dependent"], msg % name)
@ -106,7 +106,7 @@ def get_attachment_name(request, attachment):
try: try:
server = api.nova.server_get(request, server_id) server = api.nova.server_get(request, server_id)
name = server.name name = server.name
except: except Exception:
name = None name = None
exceptions.handle(request, _("Unable to retrieve " exceptions.handle(request, _("Unable to retrieve "
"attachment information.")) "attachment information."))

View File

@ -36,7 +36,7 @@ class OverviewTab(tabs.Tab):
volume = cinder.volume_get(request, volume_id) volume = cinder.volume_get(request, volume_id)
for att in volume.attachments: for att in volume.attachments:
att['instance'] = nova.server_get(request, att['server_id']) att['instance'] = nova.server_get(request, att['server_id'])
except: except Exception:
redirect = reverse('horizon:project:volumes:index') redirect = reverse('horizon:project:volumes:index')
exceptions.handle(self.request, exceptions.handle(self.request,
_('Unable to retrieve volume details.'), _('Unable to retrieve volume details.'),

Some files were not shown because too many files have changed in this diff Show More