diff options
Diffstat (limited to 'openstack_dashboard/dashboards')
90 files changed, 238 insertions, 238 deletions
diff --git a/openstack_dashboard/dashboards/admin/aggregates/views.py b/openstack_dashboard/dashboards/admin/aggregates/views.py index 31cf3767a..2d1a48a87 100644 --- a/openstack_dashboard/dashboards/admin/aggregates/views.py +++ b/openstack_dashboard/dashboards/admin/aggregates/views.py @@ -35,7 +35,7 @@ class AdminIndexView(tables.DataTableView): aggregates = [] try: aggregates = api.nova.aggregate_list(self.request) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve aggregate list.')) diff --git a/openstack_dashboard/dashboards/admin/domains/tables.py b/openstack_dashboard/dashboards/admin/domains/tables.py index 702cefe73..66972c35f 100644 --- a/openstack_dashboard/dashboards/admin/domains/tables.py +++ b/openstack_dashboard/dashboards/admin/domains/tables.py @@ -111,7 +111,7 @@ class SetDomainContext(tables.Action): messages.success(request, _('Domain Context updated to Domain %s.') % domain.name) - except: + except Exception: messages.error(request, _('Unable to set Domain Context.')) diff --git a/openstack_dashboard/dashboards/admin/domains/views.py b/openstack_dashboard/dashboards/admin/domains/views.py index dedec4e8f..2a3b3d78a 100644 --- a/openstack_dashboard/dashboards/admin/domains/views.py +++ b/openstack_dashboard/dashboards/admin/domains/views.py @@ -50,7 +50,7 @@ class IndexView(tables.DataTableView): domains.append(domain) else: domains = api.keystone.domain_list(self.request) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve domain list.')) return domains @@ -75,7 +75,7 @@ class UpdateDomainView(workflows.WorkflowView): domain_id) for field in DOMAIN_INFO_FIELDS: initial[field] = getattr(domain_info, field, None) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve domain details.'), redirect=reverse(DOMAINS_INDEX_URL)) diff --git a/openstack_dashboard/dashboards/admin/domains/workflows.py b/openstack_dashboard/dashboards/admin/domains/workflows.py index d810553e6..7b01300e4 100644 --- a/openstack_dashboard/dashboards/admin/domains/workflows.py +++ b/openstack_dashboard/dashboards/admin/domains/workflows.py @@ -76,7 +76,7 @@ class CreateDomain(workflows.Workflow): name=data['name'], description=desc, enabled=data['enabled']) - except: + except Exception: exceptions.handle(request, ignore=True) return False @@ -121,7 +121,7 @@ class UpdateDomain(workflows.Workflow): name=data['name'], description=data['description'], enabled=data['enabled']) - except: + except Exception: exceptions.handle(request, ignore=True) return False return True diff --git a/openstack_dashboard/dashboards/admin/flavors/extras/forms.py b/openstack_dashboard/dashboards/admin/flavors/extras/forms.py index 3cdbf2290..11241087c 100644 --- a/openstack_dashboard/dashboards/admin/flavors/extras/forms.py +++ b/openstack_dashboard/dashboards/admin/flavors/extras/forms.py @@ -44,7 +44,7 @@ class CreateExtraSpec(forms.SelfHandlingForm): msg = _('Created extra spec "%s".') % data['key'] messages.success(request, msg) return True - except: + except Exception: exceptions.handle(request, _("Unable to create flavor extra spec.")) @@ -63,5 +63,5 @@ class EditExtraSpec(forms.SelfHandlingForm): msg = _('Saved extra spec "%s".') % data['key'] messages.success(request, msg) return True - except: + except Exception: exceptions.handle(request, _("Unable to edit extra spec.")) diff --git a/openstack_dashboard/dashboards/admin/flavors/extras/views.py b/openstack_dashboard/dashboards/admin/flavors/extras/views.py index ffb074c6a..9255ee45b 100644 --- a/openstack_dashboard/dashboards/admin/flavors/extras/views.py +++ b/openstack_dashboard/dashboards/admin/flavors/extras/views.py @@ -45,7 +45,7 @@ class ExtraSpecMixin(object): try: context['flavor'] = api.nova.flavor_get(self.request, self.kwargs['id']) - except: + except Exception: exceptions.handle(self.request, _("Unable to retrieve flavor data.")) return context @@ -60,7 +60,7 @@ class IndexView(ExtraSpecMixin, forms.ModalFormMixin, tables.DataTableView): flavor_id = self.kwargs['id'] extras_list = api.nova.flavor_get_extras(self.request, flavor_id) extras_list.sort(key=lambda es: (es.key,)) - except: + except Exception: extras_list = [] exceptions.handle(self.request, _('Unable to retrieve extra spec list.')) @@ -89,7 +89,7 @@ class EditView(ExtraSpecMixin, forms.ModalFormView): extra_specs = api.nova.flavor_get_extras(self.request, flavor_id, raw=True) - except: + except Exception: extra_specs = {} exceptions.handle(self.request, _("Unable to retrieve flavor extra spec data.")) diff --git a/openstack_dashboard/dashboards/admin/flavors/forms.py b/openstack_dashboard/dashboards/admin/flavors/forms.py index 4f17e8a6f..6ea421881 100644 --- a/openstack_dashboard/dashboards/admin/flavors/forms.py +++ b/openstack_dashboard/dashboards/admin/flavors/forms.py @@ -59,7 +59,7 @@ class CreateFlavor(forms.SelfHandlingForm): name = self.cleaned_data.get('name') try: flavors = api.nova.flavor_list(self.request) - except: + except Exception: flavors = [] msg = _('Unable to get flavor list') exceptions.check_message(["Connection", "refused"], msg) @@ -77,7 +77,7 @@ class CreateFlavor(forms.SelfHandlingForm): flavor_id = self.data.get('flavor_id') try: flavors = api.nova.flavor_list(self.request) - except: + except Exception: flavors = [] msg = _('Unable to get flavor list') exceptions.check_message(["Connection", "refused"], msg) @@ -104,7 +104,7 @@ class CreateFlavor(forms.SelfHandlingForm): msg = _('Created flavor "%s".') % data['name'] messages.success(request, msg) return flavor - except: + except Exception: exceptions.handle(request, _("Unable to create flavor.")) @@ -140,5 +140,5 @@ class EditFlavor(CreateFlavor): msg = _('Updated flavor "%s".') % data['name'] messages.success(request, msg) return flavor - except: + except Exception: exceptions.handle(request, _("Unable to update flavor.")) diff --git a/openstack_dashboard/dashboards/admin/flavors/views.py b/openstack_dashboard/dashboards/admin/flavors/views.py index 91fbe5b0c..968d71d39 100644 --- a/openstack_dashboard/dashboards/admin/flavors/views.py +++ b/openstack_dashboard/dashboards/admin/flavors/views.py @@ -46,7 +46,7 @@ class IndexView(tables.DataTableView): flavors = [] try: flavors = api.nova.flavor_list(request) - except: + except Exception: exceptions.handle(request, _('Unable to retrieve flavor list.')) # Sort flavors by size @@ -73,7 +73,7 @@ class EditView(forms.ModalFormView): def get_initial(self): try: flavor = api.nova.flavor_get(self.request, self.kwargs['id']) - except: + except Exception: exceptions.handle(self.request, _("Unable to retrieve flavor data.")) return {'flavor_id': flavor.id, diff --git a/openstack_dashboard/dashboards/admin/groups/forms.py b/openstack_dashboard/dashboards/admin/groups/forms.py index cdbdadedd..bbc36d921 100644 --- a/openstack_dashboard/dashboards/admin/groups/forms.py +++ b/openstack_dashboard/dashboards/admin/groups/forms.py @@ -47,7 +47,7 @@ class CreateGroupForm(forms.SelfHandlingForm): messages.success(request, _('Group "%s" was successfully created.') % data['name']) - except: + except Exception: exceptions.handle(request, _('Unable to create group.')) return False return True @@ -71,7 +71,7 @@ class UpdateGroupForm(forms.SelfHandlingForm): description=data['description']) messages.success(request, _('Group has been updated successfully.')) - except: + except Exception: exceptions.handle(request, _('Unable to update the group.')) return False return True diff --git a/openstack_dashboard/dashboards/admin/groups/views.py b/openstack_dashboard/dashboards/admin/groups/views.py index db2ad7e97..4c78223ab 100644 --- a/openstack_dashboard/dashboards/admin/groups/views.py +++ b/openstack_dashboard/dashboards/admin/groups/views.py @@ -64,7 +64,7 @@ class IndexView(tables.DataTableView): if group.domain_id == domain_context: domain_groups.append(group) groups = domain_groups - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve group list.')) return groups @@ -86,7 +86,7 @@ class UpdateView(forms.ModalFormView): try: self._object = api.keystone.group_get(self.request, self.kwargs['group_id']) - except: + except Exception: redirect = reverse(GROUPS_INDEX_URL) exceptions.handle(self.request, _('Unable to update group.'), @@ -144,7 +144,7 @@ class ManageMembersView(GroupManageMixin, tables.DataTableView): group_members = [] try: group_members = self._get_group_members() - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve group users.')) return group_members @@ -165,7 +165,7 @@ class NonMembersView(GroupManageMixin, forms.ModalFormMixin, group_non_members = [] try: group_non_members = self._get_group_non_members() - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve users.')) return group_non_members diff --git a/openstack_dashboard/dashboards/admin/hypervisors/views.py b/openstack_dashboard/dashboards/admin/hypervisors/views.py index ad3cc6f73..10fa7ba20 100644 --- a/openstack_dashboard/dashboards/admin/hypervisors/views.py +++ b/openstack_dashboard/dashboards/admin/hypervisors/views.py @@ -35,7 +35,7 @@ class AdminIndexView(tables.DataTableView): hypervisors = [] try: hypervisors = api.nova.hypervisor_list(self.request) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve hypervisor list.')) diff --git a/openstack_dashboard/dashboards/admin/images/views.py b/openstack_dashboard/dashboards/admin/images/views.py index 5c3b4c566..c273d8de7 100644 --- a/openstack_dashboard/dashboards/admin/images/views.py +++ b/openstack_dashboard/dashboards/admin/images/views.py @@ -56,7 +56,7 @@ class IndexView(tables.DataTableView): images, self._more = api.glance.image_list_detailed(self.request, marker=marker, paginate=True) - except: + except Exception: self._more = False msg = _('Unable to retrieve image list.') exceptions.handle(self.request, msg) diff --git a/openstack_dashboard/dashboards/admin/info/tabs.py b/openstack_dashboard/dashboards/admin/info/tabs.py index 0c9649be3..8524d739e 100644 --- a/openstack_dashboard/dashboards/admin/info/tabs.py +++ b/openstack_dashboard/dashboards/admin/info/tabs.py @@ -39,7 +39,7 @@ class DefaultQuotasTab(tabs.TableTab): try: quota_set = quotas.get_default_quota_data(request) data = quota_set.items - except: + except Exception: data = [] exceptions.handle(self.request, _('Unable to get quota info.')) return data diff --git a/openstack_dashboard/dashboards/admin/instances/views.py b/openstack_dashboard/dashboards/admin/instances/views.py index 253f35a06..03c0e73ca 100644 --- a/openstack_dashboard/dashboards/admin/instances/views.py +++ b/openstack_dashboard/dashboards/admin/instances/views.py @@ -80,7 +80,7 @@ class AdminIndexView(tables.DataTableView): search_opts={'marker': marker, 'paginate': True}, all_tenants=True) - except: + except Exception: self._more = False exceptions.handle(self.request, _('Unable to retrieve instance list.')) @@ -88,14 +88,14 @@ class AdminIndexView(tables.DataTableView): # Gather our flavors to correlate against IDs try: flavors = api.nova.flavor_list(self.request) - except: + except Exception: # If fails to retrieve flavor list, creates an empty list. flavors = [] # Gather our tenants to correlate against IDs try: tenants, has_more = api.keystone.tenant_list(self.request) - except: + except Exception: tenants = [] msg = _('Unable to retrieve instance project information.') exceptions.handle(self.request, msg) @@ -113,7 +113,7 @@ class AdminIndexView(tables.DataTableView): # gets it via nova api. inst.full_flavor = api.nova.flavor_get( self.request, flavor_id) - except: + except Exception: msg = _('Unable to retrieve instance size information.') exceptions.handle(self.request, msg) tenant = tenant_dict.get(inst.tenant_id, None) diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py index 318f5688a..e1d5321a0 100644 --- a/openstack_dashboard/dashboards/admin/networks/forms.py +++ b/openstack_dashboard/dashboards/admin/networks/forms.py @@ -66,7 +66,7 @@ class CreateNetwork(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return network - except: + except Exception: redirect = reverse('horizon:admin:networks:index') msg = _('Failed to create network %s') % data['name'] exceptions.handle(request, msg, redirect=redirect) @@ -95,7 +95,7 @@ class UpdateNetwork(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return network - except: + except Exception: msg = _('Failed to update network %s') % data['name'] LOG.info(msg) redirect = reverse(self.failure_url) diff --git a/openstack_dashboard/dashboards/admin/networks/ports/forms.py b/openstack_dashboard/dashboards/admin/networks/ports/forms.py index bebe6464a..1b0f32d39 100644 --- a/openstack_dashboard/dashboards/admin/networks/ports/forms.py +++ b/openstack_dashboard/dashboards/admin/networks/ports/forms.py @@ -65,7 +65,7 @@ class CreatePort(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return port - except: + except Exception: msg = _('Failed to create a port for network %s') \ % data['network_id'] LOG.info(msg) diff --git a/openstack_dashboard/dashboards/admin/networks/ports/tables.py b/openstack_dashboard/dashboards/admin/networks/ports/tables.py index 7d5db7809..2ed8f658a 100644 --- a/openstack_dashboard/dashboards/admin/networks/ports/tables.py +++ b/openstack_dashboard/dashboards/admin/networks/ports/tables.py @@ -39,7 +39,7 @@ class DeletePort(tables.DeleteAction): def delete(self, request, obj_id): try: api.neutron.port_delete(request, obj_id) - except: + except Exception: msg = _('Failed to delete subnet %s') % obj_id LOG.info(msg) network_id = self.table.kwargs['network_id'] diff --git a/openstack_dashboard/dashboards/admin/networks/ports/tabs.py b/openstack_dashboard/dashboards/admin/networks/ports/tabs.py index d9825809b..297d3574d 100644 --- a/openstack_dashboard/dashboards/admin/networks/ports/tabs.py +++ b/openstack_dashboard/dashboards/admin/networks/ports/tabs.py @@ -37,7 +37,7 @@ class OverviewTab(tabs.Tab): port_id = self.tab_group.kwargs['port_id'] try: port = api.neutron.port_get(self.request, port_id) - except: + except Exception: redirect = reverse('horizon:admin:networks:index') msg = _('Unable to retrieve port details.') exceptions.handle(request, msg, redirect=redirect) diff --git a/openstack_dashboard/dashboards/admin/networks/ports/views.py b/openstack_dashboard/dashboards/admin/networks/ports/views.py index 60284d10d..0db4a4a37 100644 --- a/openstack_dashboard/dashboards/admin/networks/ports/views.py +++ b/openstack_dashboard/dashboards/admin/networks/ports/views.py @@ -50,7 +50,7 @@ class CreateView(forms.ModalFormView): network_id = self.kwargs["network_id"] self._object = api.neutron.network_get(self.request, network_id) - except: + except Exception: redirect = reverse(self.failure_url, args=(self.kwargs['network_id'],)) msg = _("Unable to retrieve network.") diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/tables.py b/openstack_dashboard/dashboards/admin/networks/subnets/tables.py index be9aec0c1..099d667ed 100644 --- a/openstack_dashboard/dashboards/admin/networks/subnets/tables.py +++ b/openstack_dashboard/dashboards/admin/networks/subnets/tables.py @@ -35,7 +35,7 @@ class DeleteSubnet(tables.DeleteAction): def delete(self, request, obj_id): try: api.neutron.subnet_delete(request, obj_id) - except: + except Exception: msg = _('Failed to delete subnet %s') % obj_id LOG.info(msg) network_id = self.table.kwargs['network_id'] diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py b/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py index 2fab7b1ed..4775fde50 100644 --- a/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py +++ b/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py @@ -44,7 +44,7 @@ class CreateSubnet(project_workflows.CreateSubnet): # created for if admin user does not belong to the tenant. network = api.neutron.network_get(request, self.context['network_id']) - except: + except Exception: msg = (_('Failed to retrieve network %s for a subnet') % data['network_id']) LOG.info(msg) diff --git a/openstack_dashboard/dashboards/admin/networks/tables.py b/openstack_dashboard/dashboards/admin/networks/tables.py index 8b29c1c17..49193aeb8 100644 --- a/openstack_dashboard/dashboards/admin/networks/tables.py +++ b/openstack_dashboard/dashboards/admin/networks/tables.py @@ -37,7 +37,7 @@ class DeleteNetwork(tables.DeleteAction): def delete(self, request, obj_id): try: api.neutron.network_delete(request, obj_id) - except: + except Exception: msg = _('Failed to delete network %s') % obj_id LOG.info(msg) redirect = reverse('horizon:admin:networks:index') diff --git a/openstack_dashboard/dashboards/admin/networks/views.py b/openstack_dashboard/dashboards/admin/networks/views.py index 0cee09fa0..02ab19c11 100644 --- a/openstack_dashboard/dashboards/admin/networks/views.py +++ b/openstack_dashboard/dashboards/admin/networks/views.py @@ -47,7 +47,7 @@ class IndexView(tables.DataTableView): if not hasattr(self, "_tenants"): try: tenants, has_more = api.keystone.tenant_list(self.request) - except: + except Exception: tenants = [] msg = _('Unable to retrieve instance project information.') exceptions.handle(self.request, msg) @@ -59,7 +59,7 @@ class IndexView(tables.DataTableView): def get_data(self): try: networks = api.neutron.network_list(self.request) - except: + except Exception: networks = [] msg = _('Network list can not be retrieved.') exceptions.handle(self.request, msg) @@ -90,7 +90,7 @@ class DetailView(tables.MultiTableView): network_id = self.kwargs['network_id'] subnets = api.neutron.subnet_list(self.request, network_id=network_id) - except: + except Exception: subnets = [] msg = _('Subnet list can not be retrieved.') exceptions.handle(self.request, msg) @@ -102,7 +102,7 @@ class DetailView(tables.MultiTableView): try: network_id = self.kwargs['network_id'] ports = api.neutron.port_list(self.request, network_id=network_id) - except: + except Exception: ports = [] msg = _('Port list can not be retrieved.') exceptions.handle(self.request, msg) @@ -116,7 +116,7 @@ class DetailView(tables.MultiTableView): network_id = self.kwargs['network_id'] network = api.neutron.network_get(self.request, network_id) network.set_id_as_name_if_empty(length=0) - except: + except Exception: redirect = self.failure_url exceptions.handle(self.request, _('Unable to retrieve details for ' diff --git a/openstack_dashboard/dashboards/admin/overview/views.py b/openstack_dashboard/dashboards/admin/overview/views.py index 600ab2f17..f26c3cd71 100644 --- a/openstack_dashboard/dashboards/admin/overview/views.py +++ b/openstack_dashboard/dashboards/admin/overview/views.py @@ -60,7 +60,7 @@ class GlobalOverview(usage.UsageView): # Pre-fill project names try: projects, has_more = api.keystone.tenant_list(self.request) - except: + except Exception: projects = [] exceptions.handle(self.request, _('Unable to retrieve project list.')) diff --git a/openstack_dashboard/dashboards/admin/projects/views.py b/openstack_dashboard/dashboards/admin/projects/views.py index 19fc65876..8fdb30b03 100644 --- a/openstack_dashboard/dashboards/admin/projects/views.py +++ b/openstack_dashboard/dashboards/admin/projects/views.py @@ -54,7 +54,7 @@ class TenantContextMixin(object): self._object = api.keystone.tenant_get(self.request, tenant_id, admin=True) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve project information.'), redirect=reverse(INDEX_URL)) @@ -84,7 +84,7 @@ class IndexView(tables.DataTableView): domain=domain_context, paginate=True, marker=marker) - except: + except Exception: self._more = False exceptions.handle(self.request, _("Unable to retrieve project list.")) @@ -113,7 +113,7 @@ class CreateProjectView(workflows.WorkflowView): for field in quotas.QUOTA_FIELDS: initial[field] = quota_defaults.get(field).limit - except: + except Exception: error_msg = _('Unable to retrieve default quota values.') self.add_error_to_step(error_msg, 'update_quotas') @@ -141,7 +141,7 @@ class UpdateProjectView(workflows.WorkflowView): tenant_id=project_id) for field in quotas.QUOTA_FIELDS: initial[field] = quota_data.get(field).limit - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve project details.'), redirect=reverse(INDEX_URL)) diff --git a/openstack_dashboard/dashboards/admin/projects/workflows.py b/openstack_dashboard/dashboards/admin/projects/workflows.py index 47e0e3d64..5ee4fc1db 100644 --- a/openstack_dashboard/dashboards/admin/projects/workflows.py +++ b/openstack_dashboard/dashboards/admin/projects/workflows.py @@ -129,7 +129,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction): msg = _('Could not find default role "%s" in Keystone') % \ default raise exceptions.NotFound(msg) - except: + except Exception: exceptions.handle(self.request, err_msg, redirect=reverse(INDEX_URL)) @@ -143,7 +143,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction): try: all_users = api.keystone.user_list(request, domain=domain_context) - except: + except Exception: exceptions.handle(request, err_msg) users_list = [(user.id, user.name) for user in all_users] @@ -151,7 +151,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction): role_list = [] try: role_list = api.keystone.role_list(request) - except: + except Exception: exceptions.handle(request, err_msg, redirect=reverse(INDEX_URL)) @@ -170,7 +170,7 @@ class UpdateProjectMembersAction(workflows.MembershipAction): roles = api.keystone.roles_for_user(self.request, user.id, project_id) - except: + except Exception: exceptions.handle(request, err_msg, redirect=reverse(INDEX_URL)) @@ -194,7 +194,7 @@ class UpdateProjectMembers(workflows.UpdateMembersStep): if data: try: roles = api.keystone.role_list(self.workflow.request) - except: + except Exception: exceptions.handle(self.workflow.request, _('Unable to retrieve user list.')) @@ -237,7 +237,7 @@ class CreateProject(workflows.Workflow): description=desc, enabled=data['enabled'], domain=domain_context) - except: + except Exception: exceptions.handle(request, ignore=True) return False @@ -265,7 +265,7 @@ class CreateProject(workflows.Workflow): role=role.id) users_added += 1 users_to_add -= users_added - except: + except Exception: exceptions.handle(request, _('Failed to add %s project members ' 'and set project quotas.') % users_to_add) @@ -281,7 +281,7 @@ class CreateProject(workflows.Workflow): cinder.tenant_quota_update(request, project_id, **cinder_data) - except: + except Exception: exceptions.handle(request, _('Unable to set project quotas.')) return True @@ -338,7 +338,7 @@ class UpdateProject(workflows.Workflow): name=data['name'], description=data['description'], enabled=data['enabled']) - except: + except Exception: exceptions.handle(request, ignore=True) return False @@ -427,7 +427,7 @@ class UpdateProject(workflows.Workflow): role=role.id) users_added += 1 users_to_modify -= users_added - except: + except Exception: exceptions.handle(request, _('Failed to modify %s project members ' 'and update project quotas.') % users_to_modify) @@ -447,7 +447,7 @@ class UpdateProject(workflows.Workflow): project_id, **cinder_data) return True - except: + except Exception: exceptions.handle(request, _('Modified project information and ' 'members, but unable to modify ' 'project quotas.')) diff --git a/openstack_dashboard/dashboards/admin/roles/forms.py b/openstack_dashboard/dashboards/admin/roles/forms.py index 03ad1f06b..9827e01d0 100644 --- a/openstack_dashboard/dashboards/admin/roles/forms.py +++ b/openstack_dashboard/dashboards/admin/roles/forms.py @@ -31,7 +31,7 @@ class CreateRoleForm(forms.SelfHandlingForm): new_user = api.keystone.role_create(request, data["name"]) messages.success(request, _("Role created successfully.")) return new_user - except: + except Exception: exceptions.handle(request, _('Unable to create role.')) @@ -44,5 +44,5 @@ class UpdateRoleForm(forms.SelfHandlingForm): api.keystone.role_update(request, data['id'], data["name"]) messages.success(request, _("Role updated successfully.")) return True - except: + except Exception: exceptions.handle(request, _('Unable to update role.')) diff --git a/openstack_dashboard/dashboards/admin/roles/views.py b/openstack_dashboard/dashboards/admin/roles/views.py index 87c7d46cf..b232e052e 100644 --- a/openstack_dashboard/dashboards/admin/roles/views.py +++ b/openstack_dashboard/dashboards/admin/roles/views.py @@ -37,7 +37,7 @@ class IndexView(tables.DataTableView): roles = [] try: roles = api.keystone.role_list(self.request) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve roles list.')) return roles @@ -53,7 +53,7 @@ class UpdateView(forms.ModalFormView): try: self._object = api.keystone.role_get(self.request, self.kwargs['role_id']) - except: + except Exception: redirect = reverse("horizon:admin:roles:index") exceptions.handle(self.request, _('Unable to update role.'), diff --git a/openstack_dashboard/dashboards/admin/routers/views.py b/openstack_dashboard/dashboards/admin/routers/views.py index e13d41158..6199da6a1 100644 --- a/openstack_dashboard/dashboards/admin/routers/views.py +++ b/openstack_dashboard/dashboards/admin/routers/views.py @@ -44,7 +44,7 @@ class IndexView(r_views.IndexView, n_views.IndexView): try: routers = api.neutron.router_list(self.request, search_opts=search_opts) - except: + except Exception: routers = [] exceptions.handle(self.request, _('Unable to retrieve router list.')) diff --git a/openstack_dashboard/dashboards/admin/users/forms.py b/openstack_dashboard/dashboards/admin/users/forms.py index c0039a3c9..9b44f22b1 100644 --- a/openstack_dashboard/dashboards/admin/users/forms.py +++ b/openstack_dashboard/dashboards/admin/users/forms.py @@ -115,12 +115,12 @@ class CreateUserForm(BaseUserForm): data['project'], new_user.id, data['role_id']) - except: + except Exception: exceptions.handle(request, _('Unable to add user ' 'to primary project.')) return new_user - except: + except Exception: exceptions.handle(request, _('Unable to create user.')) @@ -162,7 +162,7 @@ class UpdateUserForm(BaseUserForm): api.keystone.user_update(request, user, **data) messages.success(request, _('User has been updated successfully.')) - except: + except Exception: exceptions.handle(request, ignore=True) messages.error(request, _('Unable to update the user.')) return True diff --git a/openstack_dashboard/dashboards/admin/users/views.py b/openstack_dashboard/dashboards/admin/users/views.py index a0c325962..4223ff45d 100644 --- a/openstack_dashboard/dashboards/admin/users/views.py +++ b/openstack_dashboard/dashboards/admin/users/views.py @@ -47,7 +47,7 @@ class IndexView(tables.DataTableView): try: users = api.keystone.user_list(self.request, domain=domain_context) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve user list.')) return users @@ -69,7 +69,7 @@ class UpdateView(forms.ModalFormView): self._object = api.keystone.user_get(self.request, self.kwargs['user_id'], admin=True) - except: + except Exception: redirect = reverse("horizon:admin:users:index") exceptions.handle(self.request, _('Unable to update user.'), @@ -103,7 +103,7 @@ class CreateView(forms.ModalFormView): kwargs = super(CreateView, self).get_form_kwargs() try: roles = api.keystone.role_list(self.request) - except: + except Exception: redirect = reverse("horizon:admin:users:index") exceptions.handle(self.request, _("Unable to retrieve user roles."), diff --git a/openstack_dashboard/dashboards/admin/volumes/forms.py b/openstack_dashboard/dashboards/admin/volumes/forms.py index 9d0886fc3..5b6b7c437 100644 --- a/openstack_dashboard/dashboards/admin/volumes/forms.py +++ b/openstack_dashboard/dashboards/admin/volumes/forms.py @@ -38,7 +38,7 @@ class CreateVolumeType(forms.SelfHandlingForm): messages.success(request, _('Successfully created volume type: %s') % data['name']) return volume_type - except: + except Exception: exceptions.handle(request, _('Unable to create volume type.')) return False diff --git a/openstack_dashboard/dashboards/admin/volumes/views.py b/openstack_dashboard/dashboards/admin/volumes/views.py index 7029b3ad2..05d099808 100644 --- a/openstack_dashboard/dashboards/admin/volumes/views.py +++ b/openstack_dashboard/dashboards/admin/volumes/views.py @@ -53,7 +53,7 @@ class IndexView(tables.MultiTableView, VolumeTableMixIn): # Gather our tenants to correlate against IDs try: tenants, has_more = keystone.tenant_list(self.request) - except: + except Exception: tenants = [] msg = _('Unable to retrieve volume project information.') exceptions.handle(self.request, msg) @@ -69,7 +69,7 @@ class IndexView(tables.MultiTableView, VolumeTableMixIn): def get_volume_types_data(self): try: volume_types = cinder.volume_type_list(self.request) - except: + except Exception: volume_types = [] exceptions.handle(self.request, _("Unable to retrieve volume types")) diff --git a/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py b/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py index 9fc330083..cd9b068c3 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py +++ b/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py @@ -52,7 +52,7 @@ def download_ec2_bundle(request): keys = api.keystone.create_ec2_credentials(request, request.user.id, tenant_id) - except: + except Exception: exceptions.handle(request, _('Unable to fetch EC2 credentials.'), redirect=request.build_absolute_uri()) @@ -88,7 +88,7 @@ def download_ec2_bundle(request): archive.writestr('cert.pem', credentials.data) archive.writestr('cacert.pem', cacert.data) archive.writestr('ec2rc.sh', render_to_string(template, context)) - except: + except Exception: exceptions.handle(request, _('Error writing zipfile: %(exc)s'), redirect=request.build_absolute_uri()) diff --git a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/forms.py b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/forms.py index 40918f787..292154060 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/forms.py +++ b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/forms.py @@ -44,5 +44,5 @@ class FloatingIpAllocate(forms.SelfHandlingForm): _('Allocated Floating IP %(ip)s.') % {"ip": fip.ip}) return fip - except: + except Exception: exceptions.handle(request, _('Unable to allocate Floating IP.')) diff --git a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/tables.py b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/tables.py index 751ce6810..d33c23701 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/tables.py @@ -91,7 +91,7 @@ class DisassociateIP(tables.Action): messages.success(request, _('Successfully disassociated Floating IP: %s') % fip.ip) - except: + except Exception: exceptions.handle(request, _('Unable to disassociate floating IP.')) return shortcuts.redirect('horizon:project:access_and_security:index') diff --git a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/views.py b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/views.py index abaf04f60..aa30c6090 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/views.py +++ b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/views.py @@ -55,14 +55,14 @@ class AllocateView(forms.ModalFormView): context = super(AllocateView, self).get_context_data(**kwargs) try: context['usages'] = quotas.tenant_quota_usages(self.request) - except: + except Exception: exceptions.handle(self.request) return context def get_initial(self): try: pools = api.network.floating_ip_pools_list(self.request) - except: + except Exception: pools = [] exceptions.handle(self.request, _("Unable to retrieve floating IP pools.")) diff --git a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/workflows.py b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/workflows.py index 77fb9545e..f7198a94d 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/floating_ips/workflows.py +++ b/openstack_dashboard/dashboards/project/access_and_security/floating_ips/workflows.py @@ -63,7 +63,7 @@ class AssociateIPAction(workflows.Action): def populate_ip_id_choices(self, request, context): try: ips = api.network.tenant_floating_ip_list(self.request) - except: + except Exception: redirect = reverse('horizon:project:access_and_security:index') exceptions.handle(self.request, _('Unable to retrieve floating IP addresses.'), @@ -79,7 +79,7 @@ class AssociateIPAction(workflows.Action): def populate_instance_id_choices(self, request, context): try: targets = api.network.floating_ip_target_list(self.request) - except: + except Exception: redirect = reverse('horizon:project:access_and_security:index') exceptions.handle(self.request, _('Unable to retrieve instance list.'), @@ -137,7 +137,7 @@ class IPAssociationWorkflow(workflows.Workflow): api.network.floating_ip_associate(request, data['ip_id'], data['instance_id']) - except: + except Exception: exceptions.handle(request) return False return True diff --git a/openstack_dashboard/dashboards/project/access_and_security/keypairs/forms.py b/openstack_dashboard/dashboards/project/access_and_security/keypairs/forms.py index dfab3f6c0..3177406b5 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/keypairs/forms.py +++ b/openstack_dashboard/dashboards/project/access_and_security/keypairs/forms.py @@ -60,7 +60,7 @@ class ImportKeypair(forms.SelfHandlingForm): messages.success(request, _('Successfully imported public key: %s') % data['name']) return keypair - except: + except Exception: exceptions.handle(request, ignore=True) self.api_error(_('Unable to import keypair.')) return False diff --git a/openstack_dashboard/dashboards/project/access_and_security/keypairs/views.py b/openstack_dashboard/dashboards/project/access_and_security/keypairs/views.py index df5767f6f..f519752c5 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/keypairs/views.py +++ b/openstack_dashboard/dashboards/project/access_and_security/keypairs/views.py @@ -74,7 +74,7 @@ class GenerateView(View): def get(self, request, keypair_name=None): try: keypair = api.nova.keypair_create(request, keypair_name) - except: + except Exception: redirect = reverse('horizon:project:access_and_security:index') exceptions.handle(self.request, _('Unable to create keypair: %(exc)s'), diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py index 971d872f8..cd00ee9c2 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py @@ -60,7 +60,7 @@ class CreateGroup(forms.SelfHandlingForm): _('Successfully created security group: %s') % data['name']) return sg - except: + except Exception: redirect = reverse("horizon:project:access_and_security:index") exceptions.handle(request, _('Unable to create security group.'), @@ -346,7 +346,7 @@ class AddRule(forms.SelfHandlingForm): messages.success(request, _('Successfully added rule: %s') % unicode(rule)) return rule - except: + except Exception: redirect = reverse("horizon:project:access_and_security:" "security_groups:detail", args=[data['id']]) exceptions.handle(request, diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py index ca834bcc8..c14d72450 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py @@ -54,7 +54,7 @@ class DetailView(tables.DataTableView): sg_id = get_int_or_uuid(self.kwargs['security_group_id']) try: self._sg = api.network.security_group_get(self.request, sg_id) - except: + except Exception: redirect = reverse('horizon:project:access_and_security:index') exceptions.handle(self.request, _('Unable to retrieve security group.'), @@ -92,7 +92,7 @@ class AddRuleView(forms.ModalFormView): try: groups = api.network.security_group_list(self.request) - except: + except Exception: groups = [] exceptions.handle(self.request, _("Unable to retrieve security groups.")) diff --git a/openstack_dashboard/dashboards/project/access_and_security/tabs.py b/openstack_dashboard/dashboards/project/access_and_security/tabs.py index 077df9349..25ce80e9b 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/tabs.py +++ b/openstack_dashboard/dashboards/project/access_and_security/tabs.py @@ -48,7 +48,7 @@ class SecurityGroupsTab(tabs.TableTab): def get_security_groups_data(self): try: security_groups = network.security_group_list(self.request) - except: + except Exception: security_groups = [] exceptions.handle(self.request, _('Unable to retrieve security groups.')) @@ -64,7 +64,7 @@ class KeypairsTab(tabs.TableTab): def get_keypairs_data(self): try: keypairs = nova.keypair_list(self.request) - except: + except Exception: keypairs = [] exceptions.handle(self.request, _('Unable to retrieve keypair list.')) @@ -80,14 +80,14 @@ class FloatingIPsTab(tabs.TableTab): def get_floating_ips_data(self): try: floating_ips = network.tenant_floating_ip_list(self.request) - except: + except Exception: floating_ips = [] exceptions.handle(self.request, _('Unable to retrieve floating IP addresses.')) try: floating_ip_pools = network.floating_ip_pools_list(self.request) - except: + except Exception: floating_ip_pools = [] messages.warning(self.request, _('Unable to retrieve floating IP pools.')) @@ -96,7 +96,7 @@ class FloatingIPsTab(tabs.TableTab): instances = [] try: instances, has_more = nova.server_list(self.request) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve instance list.')) diff --git a/openstack_dashboard/dashboards/project/containers/forms.py b/openstack_dashboard/dashboards/project/containers/forms.py index ba5d2c87d..1a6378353 100644 --- a/openstack_dashboard/dashboards/project/containers/forms.py +++ b/openstack_dashboard/dashboards/project/containers/forms.py @@ -68,7 +68,7 @@ class CreateContainer(forms.SelfHandlingForm): subfolder_name) messages.success(request, _("Folder created successfully.")) return True - except: + except Exception: exceptions.handle(request, _('Unable to create container.')) @@ -97,7 +97,7 @@ class UploadObject(forms.SelfHandlingForm): object_file) messages.success(request, _("Object was successfully uploaded.")) return obj - except: + except Exception: exceptions.handle(request, _("Unable to upload object.")) @@ -146,7 +146,7 @@ class CopyObject(forms.SelfHandlingForm): messages.error(request, exc) raise exceptions.Http302(reverse(index, args=[wrap_delimiter(orig_container)])) - except: + except Exception: redirect = reverse(index, args=[wrap_delimiter(orig_container)]) exceptions.handle(request, _("Unable to copy object."), diff --git a/openstack_dashboard/dashboards/project/containers/views.py b/openstack_dashboard/dashboards/project/containers/views.py index 287774683..674eaf699 100644 --- a/openstack_dashboard/dashboards/project/containers/views.py +++ b/openstack_dashboard/dashboards/project/containers/views.py @@ -56,7 +56,7 @@ class ContainerView(browsers.ResourceBrowserView): try: containers, self._more = api.swift.swift_get_containers( self.request, marker=marker) - except: + except Exception: msg = _('Unable to retrieve container list.') exceptions.handle(self.request, msg) return containers @@ -84,7 +84,7 @@ class ContainerView(browsers.ResourceBrowserView): container_name, marker=marker, prefix=prefix) - except: + except Exception: self._more = None objects = [] msg = _('Unable to retrieve object list.') @@ -169,7 +169,7 @@ class UploadView(forms.ModalFormView): def object_download(request, container_name, object_path): try: obj = api.swift.swift_get_object(request, container_name, object_path) - except: + except Exception: redirect = reverse("horizon:project:containers:index") exceptions.handle(request, _("Unable to retrieve object."), @@ -204,7 +204,7 @@ class CopyView(forms.ModalFormView): kwargs = super(CopyView, self).get_form_kwargs() try: containers = api.swift.swift_get_containers(self.request) - except: + except Exception: redirect = reverse("horizon:project:containers:index") exceptions.handle(self.request, _('Unable to list containers.'), diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py index 2f0f3f7db..1f64982db 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py @@ -157,7 +157,7 @@ class CreateImageForm(forms.SelfHandlingForm): _('Your image %s has been queued for creation.') % data['name']) return image - except: + except Exception: 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) messages.success(request, _('Image was successfully updated.')) return image - except: + except Exception: exceptions.handle(request, error_updating % image_id) diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tabs.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tabs.py index fefc6816b..2355ebdad 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tabs.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tabs.py @@ -32,7 +32,7 @@ class OverviewTab(tabs.Tab): image_id = self.tab_group.kwargs['image_id'] try: image = api.glance.image_get(self.request, image_id) - except: + except Exception: redirect = reverse('horizon:project:images_and_snapshots:index') exceptions.handle(request, _('Unable to retrieve image details.'), diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/views.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/views.py index 0ac395a4d..066c5751c 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/views.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/views.py @@ -62,7 +62,7 @@ class UpdateView(forms.ModalFormView): try: self._object = api.glance.image_get(self.request, self.kwargs['image_id']) - except: + except Exception: msg = _('Unable to retrieve image.') url = reverse('horizon:project:images_and_snapshots:index') exceptions.handle(self.request, msg, redirect=url) diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/forms.py b/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/forms.py index 80166e6ca..bab32a5d7 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/forms.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/forms.py @@ -50,7 +50,7 @@ class CreateSnapshot(forms.SelfHandlingForm): messages.success(request, _('Snapshot "%(name)s" created for ' 'instance "%(inst)s"') % vals) return snapshot - except: + except Exception: redirect = reverse("horizon:project:instances:index") exceptions.handle(request, _('Unable to create snapshot.'), diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/views.py b/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/views.py index 2130dcda0..464f8eb05 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/views.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/snapshots/views.py @@ -50,7 +50,7 @@ class CreateView(forms.ModalFormView): try: self._object = api.nova.server_get(self.request, self.kwargs["instance_id"]) - except: + except Exception: redirect = reverse('horizon:project:instances:index') exceptions.handle(self.request, _("Unable to retrieve instance."), diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/utils.py b/openstack_dashboard/dashboards/project/images_and_snapshots/utils.py index 534005a46..4e476917a 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/utils.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/utils.py @@ -27,7 +27,7 @@ def get_available_images(request, project_id=None, images_cache=None): request, filters=public) [public_images.append(image) for image in images] images_cache['public_images'] = public_images - except: + except Exception: exceptions.handle(request, _("Unable to retrieve public images.")) @@ -41,7 +41,7 @@ def get_available_images(request, project_id=None, images_cache=None): try: owned_images, _more = glance.image_list_detailed( request, filters=owner) - except: + except Exception: exceptions.handle(request, _("Unable to retrieve images for " "the current project.")) diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/views.py b/openstack_dashboard/dashboards/project/images_and_snapshots/views.py index b146a90c4..22d18b08d 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/views.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/views.py @@ -61,7 +61,7 @@ class IndexView(tables.MultiTableView): marker=marker) images = [im for im in all_images if im.container_format not in ['aki', 'ari']] - except: + except Exception: images = [] exceptions.handle(self.request, _("Unable to retrieve images.")) return images @@ -70,7 +70,7 @@ class IndexView(tables.MultiTableView): if is_service_enabled(self.request, 'volume'): try: snapshots = api.cinder.volume_snapshot_list(self.request) - except: + except Exception: snapshots = [] exceptions.handle(self.request, _("Unable to retrieve " "volume snapshots.")) diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tabs.py b/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tabs.py index f756c55dc..41967bc01 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tabs.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tabs.py @@ -35,7 +35,7 @@ class OverviewTab(tabs.Tab): snapshot = cinder.volume_snapshot_get(request, snapshot_id) volume = cinder.volume_get(request, snapshot.volume_id) volume.display_name = None - except: + except Exception: redirect = reverse('horizon:project:images_and_snapshots:index') exceptions.handle(self.request, _('Unable to retrieve snapshot details.'), diff --git a/openstack_dashboard/dashboards/project/instances/tables.py b/openstack_dashboard/dashboards/project/instances/tables.py index b3e932a6c..7eb39fc1d 100644 --- a/openstack_dashboard/dashboards/project/instances/tables.py +++ b/openstack_dashboard/dashboards/project/instances/tables.py @@ -208,7 +208,7 @@ class LaunchLink(tables.LinkAction): self.verbose_name = _("Launch Instance") classes = [c for c in self.classes if c != "disabled"] self.classes = classes - except: + except Exception: LOG.exception("Failed to retrieve quota information") # If we can't get the quota information, leave it to the # API to check when launching @@ -376,7 +376,7 @@ class SimpleAssociateIP(tables.Action): messages.success(request, _("Successfully associated floating IP: %s") % fip.ip) - except: + except Exception: exceptions.handle(request, _("Unable to associate floating IP.")) return shortcuts.redirect("horizon:project:instances:index") @@ -413,7 +413,7 @@ class SimpleDisassociateIP(tables.Action): "floating IP: %s") % fip.ip) else: messages.info(request, _("No floating IPs to disassociate.")) - except: + except Exception: exceptions.handle(request, _("Unable to disassociate floating IP.")) return shortcuts.redirect("horizon:project:instances:index") diff --git a/openstack_dashboard/dashboards/project/instances/tabs.py b/openstack_dashboard/dashboards/project/instances/tabs.py index 8f4172d94..4caa7d4be 100644 --- a/openstack_dashboard/dashboards/project/instances/tabs.py +++ b/openstack_dashboard/dashboards/project/instances/tabs.py @@ -45,7 +45,7 @@ class LogTab(tabs.Tab): data = api.nova.server_console_output(request, instance.id, tail_length=35) - except: + except Exception: data = _('Unable to get log for instance "%s".') % instance.id exceptions.handle(request, ignore=True) return {"instance": instance, @@ -70,7 +70,7 @@ class ConsoleTab(tabs.Tab): console.url, getattr(instance, "name", ""), instance.id) - except: + except Exception: try: console = api.nova.server_spice_console(request, instance.id) @@ -78,7 +78,7 @@ class ConsoleTab(tabs.Tab): console.url, getattr(instance, "name", ""), instance.id) - except: + except Exception: console_url = None elif console_type == 'VNC': try: @@ -87,7 +87,7 @@ class ConsoleTab(tabs.Tab): console.url, getattr(instance, "name", ""), instance.id) - except: + except Exception: console_url = None elif console_type == 'SPICE': try: @@ -96,7 +96,7 @@ class ConsoleTab(tabs.Tab): console.url, getattr(instance, "name", ""), instance.id) - except: + except Exception: console_url = None else: console_url = None diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py index 0d39e5631..2bc3b280e 100644 --- a/openstack_dashboard/dashboards/project/instances/views.py +++ b/openstack_dashboard/dashboards/project/instances/views.py @@ -67,7 +67,7 @@ class IndexView(tables.DataTableView): self.request, search_opts={'marker': marker, 'paginate': True}) - except: + except Exception: self._more = False instances = [] exceptions.handle(self.request, @@ -76,7 +76,7 @@ class IndexView(tables.DataTableView): if instances: try: flavors = api.nova.flavor_list(self.request) - except: + except Exception: flavors = [] exceptions.handle(self.request, ignore=True) @@ -93,7 +93,7 @@ class IndexView(tables.DataTableView): # get it via nova api. instance.full_flavor = api.nova.flavor_get( self.request, flavor_id) - except: + except Exception: msg = _('Unable to retrieve instance size information.') exceptions.handle(self.request, msg) return instances @@ -116,7 +116,7 @@ def console(request, instance_id): data = api.nova.server_console_output(request, instance_id, tail_length=tail) - except: + except Exception: data = _('Unable to get log for instance "%s".') % instance_id exceptions.handle(request, ignore=True) response = http.HttpResponse(mimetype='text/plain') @@ -131,7 +131,7 @@ def vnc(request, instance_id): instance = api.nova.server_get(request, instance_id) return shortcuts.redirect(console.url + ("&title=%s(%s)" % (instance.name, instance_id))) - except: + except Exception: redirect = reverse("horizon:project:instances:index") msg = _('Unable to get VNC console for instance "%s".') % instance_id exceptions.handle(request, msg, redirect=redirect) @@ -143,7 +143,7 @@ def spice(request, instance_id): instance = api.nova.server_get(request, instance_id) return shortcuts.redirect(console.url + ("&title=%s(%s)" % (instance.name, instance_id))) - except: + except Exception: redirect = reverse("horizon:project:instances:index") msg = _('Unable to get SPICE console for instance "%s".') % instance_id exceptions.handle(request, msg, redirect=redirect) @@ -163,7 +163,7 @@ class UpdateView(workflows.WorkflowView): instance_id = self.kwargs['instance_id'] try: self._object = api.nova.server_get(self.request, instance_id) - except: + except Exception: redirect = reverse("horizon:project:instances:index") msg = _('Unable to retrieve instance details.') exceptions.handle(self.request, msg, redirect=redirect) @@ -198,7 +198,7 @@ class DetailView(tabs.TabView): self.request, instance.flavor["id"]) instance.security_groups = api.network.server_security_groups( self.request, instance_id) - except: + except Exception: redirect = reverse('horizon:project:instances:index') exceptions.handle(self.request, _('Unable to retrieve details for ' @@ -233,7 +233,7 @@ class ResizeView(workflows.WorkflowView): else: flavor = api.nova.flavor_get(self.request, flavor_id) self._object.flavor_name = flavor.name - except: + except Exception: redirect = reverse("horizon:project:instances:index") msg = _('Unable to retrieve instance details.') exceptions.handle(self.request, msg, redirect=redirect) @@ -245,7 +245,7 @@ class ResizeView(workflows.WorkflowView): flavors = api.nova.flavor_list(self.request) self._flavors = SortedDict([(str(flavor.id), flavor) for flavor in flavors]) - except: + except Exception: redirect = reverse("horizon:project:instances:index") exceptions.handle(self.request, _('Unable to retrieve flavors.'), redirect=redirect) diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py index d95c0391a..b8c1618ea 100644 --- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py +++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py @@ -128,7 +128,7 @@ class VolumeOptionsAction(workflows.Action): if v.status == api.cinder.VOLUME_STATE_AVAILABLE] volume_options.extend([self._get_volume_display_name(vol) for vol in volumes]) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve list of volumes.')) return volume_options @@ -141,7 +141,7 @@ class VolumeOptionsAction(workflows.Action): if s.status == api.cinder.VOLUME_STATE_AVAILABLE] volume_options.extend([self._get_volume_display_name(snap) for snap in snapshots]) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve list of volume ' 'snapshots.')) @@ -277,7 +277,7 @@ class SetInstanceDetailsAction(workflows.Action): flavor_list = [(flavor.id, "%s" % flavor.name) for flavor in sorted(flavors, key=key, reverse=rev)] - except: + except Exception: flavor_list = [] exceptions.handle(request, _('Unable to retrieve instance flavors.')) @@ -286,7 +286,7 @@ class SetInstanceDetailsAction(workflows.Action): def populate_availability_zone_choices(self, request, context): try: zones = api.nova.availability_zone_list(request) - except: + except Exception: zones = [] exceptions.handle(request, _('Unable to retrieve availability zones.')) @@ -308,7 +308,7 @@ class SetInstanceDetailsAction(workflows.Action): flavors = json.dumps([f._info for f in api.nova.flavor_list(self.request)]) extra['flavors'] = flavors - except: + except Exception: exceptions.handle(self.request, _("Unable to retrieve quota information.")) return super(SetInstanceDetailsAction, self).get_help_text(extra) @@ -373,7 +373,7 @@ class SetAccessControlsAction(workflows.Action): try: keypairs = api.nova.keypair_list(request) keypair_list = [(kp.name, kp.name) for kp in keypairs] - except: + except Exception: keypair_list = [] exceptions.handle(request, _('Unable to retrieve keypairs.')) @@ -389,7 +389,7 @@ class SetAccessControlsAction(workflows.Action): try: groups = api.network.security_group_list(request) security_group_list = [(sg.name, sg.name) for sg in groups] - except: + except Exception: exceptions.handle(request, _('Unable to retrieve list of security groups')) security_group_list = [] @@ -465,7 +465,7 @@ class SetNetworkAction(workflows.Action): for n in networks: n.set_id_as_name_if_empty() network_list = [(network.id, network.name) for network in networks] - except: + except Exception: network_list = [] exceptions.handle(request, _('Unable to retrieve networks.')) @@ -550,6 +550,6 @@ class LaunchInstance(workflows.Workflow): instance_count=int(context['count']), admin_pass=context['admin_pass']) return True - except: + except Exception: exceptions.handle(request) return False diff --git a/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py index c0802d54a..8d7ce9600 100644 --- a/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py +++ b/openstack_dashboard/dashboards/project/instances/workflows/resize_instance.py @@ -75,7 +75,7 @@ class SetFlavorChoiceAction(workflows.Action): flavors = json.dumps([f._info for f in api.nova.flavor_list(self.request)]) extra['flavors'] = flavors - except: + except Exception: exceptions.handle(self.request, _("Unable to retrieve quota information.")) return super(SetFlavorChoiceAction, self).get_help_text(extra) @@ -106,6 +106,6 @@ class ResizeInstance(workflows.Workflow): try: api.nova.server_resize(request, instance_id, flavor) return True - except: + except Exception: exceptions.handle(request) return False diff --git a/openstack_dashboard/dashboards/project/instances/workflows/update_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/update_instance.py index 3ee74752f..fbb6420c8 100644 --- a/openstack_dashboard/dashboards/project/instances/workflows/update_instance.py +++ b/openstack_dashboard/dashboards/project/instances/workflows/update_instance.py @@ -51,7 +51,7 @@ class UpdateInstanceSecurityGroupsAction(workflows.MembershipAction): all_groups = [] try: all_groups = api.network.security_group_list(request) - except: + except Exception: exceptions.handle(request, err_msg) groups_list = [(group.id, group.name) for group in all_groups] @@ -111,7 +111,7 @@ class UpdateInstanceInfoAction(workflows.Action): api.nova.server_update(request, data['instance_id'], data['name']) - except: + except Exception: exceptions.handle(request, ignore=True) return False return True diff --git a/openstack_dashboard/dashboards/project/loadbalancers/forms.py b/openstack_dashboard/dashboards/project/loadbalancers/forms.py index 326560ddc..5f9d5ffb5 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/forms.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/forms.py @@ -63,7 +63,7 @@ class UpdatePool(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return pool - except: + except Exception: msg = _('Failed to update pool %s') % context['name'] LOG.info(msg) redirect = reverse(self.failure_url) @@ -101,7 +101,7 @@ class UpdateVip(forms.SelfHandlingForm): pool_id_choices = [] try: pools = api.lbaas.pools_get(request) - except: + except Exception: pools = [] exceptions.handle(request, _('Unable to retrieve pools list.')) @@ -144,7 +144,7 @@ class UpdateVip(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return vip - except: + except Exception: msg = _('Failed to update VIP %s') % context['name'] LOG.info(msg) redirect = reverse(self.failure_url) @@ -169,7 +169,7 @@ class UpdateMember(forms.SelfHandlingForm): pool_id_choices = [] try: pools = api.lbaas.pools_get(request) - except: + except Exception: pools = [] exceptions.handle(request, _('Unable to retrieve pools list.')) @@ -191,7 +191,7 @@ class UpdateMember(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return member - except: + except Exception: msg = _('Failed to update member %s') % context['member_id'] LOG.info(msg) redirect = reverse(self.failure_url) @@ -238,7 +238,7 @@ class UpdateMonitor(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return monitor - except: + except Exception: msg = _('Failed to update health monitor %s')\ % context['monitor_id'] LOG.info(msg) diff --git a/openstack_dashboard/dashboards/project/loadbalancers/tables.py b/openstack_dashboard/dashboards/project/loadbalancers/tables.py index 79e7865e9..f53cbf351 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/tables.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/tables.py @@ -166,7 +166,7 @@ class AddPMAssociationLink(tables.LinkAction): for m in monitors: if m.id not in datum['health_monitors']: return True - except: + except Exception: exceptions.handle(request, _('Failed to retrieve health monitors.')) return False diff --git a/openstack_dashboard/dashboards/project/loadbalancers/tabs.py b/openstack_dashboard/dashboards/project/loadbalancers/tabs.py index 0b8164474..0abf27e7b 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/tabs.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/tabs.py @@ -41,7 +41,7 @@ class PoolsTab(tabs.TableTab): pools = api.lbaas.pools_get(self.tab_group.request) poolsFormatted = [p.readable(self.tab_group.request) for p in pools] - except: + except Exception: poolsFormatted = [] exceptions.handle(self.tab_group.request, _('Unable to retrieve pools list.')) @@ -59,7 +59,7 @@ class MembersTab(tabs.TableTab): members = api.lbaas.members_get(self.tab_group.request) membersFormatted = [m.readable(self.tab_group.request) for m in members] - except: + except Exception: membersFormatted = [] exceptions.handle(self.tab_group.request, _('Unable to retrieve member list.')) @@ -76,7 +76,7 @@ class MonitorsTab(tabs.TableTab): try: monitors = api.lbaas.pool_health_monitors_get( self.tab_group.request) - except: + except Exception: monitors = [] exceptions.handle(self.tab_group.request, _('Unable to retrieve monitor list.')) @@ -98,7 +98,7 @@ class PoolDetailsTab(tabs.Tab): pid = self.tab_group.kwargs['pool_id'] try: pool = api.lbaas.pool_get(request, pid) - except: + except Exception: pool = [] exceptions.handle(request, _('Unable to retrieve pool details.')) @@ -114,7 +114,7 @@ class VipDetailsTab(tabs.Tab): vid = self.tab_group.kwargs['vip_id'] try: vip = api.lbaas.vip_get(request, vid) - except: + except Exception: vip = [] exceptions.handle(self.tab_group.request, _('Unable to retrieve VIP details.')) @@ -130,7 +130,7 @@ class MemberDetailsTab(tabs.Tab): mid = self.tab_group.kwargs['member_id'] try: member = api.lbaas.member_get(request, mid) - except: + except Exception: member = [] exceptions.handle(self.tab_group.request, _('Unable to retrieve member details.')) @@ -146,7 +146,7 @@ class MonitorDetailsTab(tabs.Tab): mid = self.tab_group.kwargs['monitor_id'] try: monitor = api.lbaas.pool_health_monitor_get(request, mid) - except: + except Exception: monitor = [] exceptions.handle(self.tab_group.request, _('Unable to retrieve monitor details.')) diff --git a/openstack_dashboard/dashboards/project/loadbalancers/views.py b/openstack_dashboard/dashboards/project/loadbalancers/views.py index 580cbf51e..a0ef149c7 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/views.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/views.py @@ -75,34 +75,34 @@ class IndexView(tabs.TabView): for obj_id in obj_ids: try: api.lbaas.pool_health_monitor_delete(request, obj_id) - except: + except Exception: exceptions.handle(request, _('Unable to delete monitor.')) if m == 'pool': for obj_id in obj_ids: try: api.lbaas.pool_delete(request, obj_id) - except: + except Exception: exceptions.handle(request, _('Must delete VIP first.')) if m == 'member': for obj_id in obj_ids: try: api.lbaas.member_delete(request, obj_id) - except: + except Exception: exceptions.handle(request, _('Unable to delete member.')) if m == 'vip': for obj_id in obj_ids: try: vip_id = api.lbaas.pool_get(request, obj_id).vip_id - except: + except Exception: exceptions.handle(request, _('Unable to locate VIP to delete.')) if vip_id is not None: try: api.lbaas.vip_delete(request, vip_id) - except: + except Exception: exceptions.handle(request, _('Unable to delete VIP.')) return self.get(request, *args, **kwargs) @@ -130,7 +130,7 @@ class AddVipView(workflows.WorkflowView): pool = api.lbaas.pool_get(self.request, initial['pool_id']) initial['subnet'] = api.neutron.subnet_get( self.request, pool.subnet_id).cidr - except: + except Exception: initial['subnet'] = '' msg = _('Unable to retrieve pool subnet.') exceptions.handle(self.request, msg) @@ -189,7 +189,7 @@ class UpdatePoolView(forms.ModalFormView): pool_id = self.kwargs['pool_id'] try: self._object = api.lbaas.pool_get(self.request, pool_id) - except: + except Exception: redirect = self.success_url msg = _('Unable to retrieve pool details.') exceptions.handle(self.request, msg, redirect=redirect) @@ -220,7 +220,7 @@ class UpdateVipView(forms.ModalFormView): vip_id = self.kwargs['vip_id'] try: self._object = api.lbaas.vip_get(self.request, vip_id) - except: + except Exception: redirect = self.success_url msg = _('Unable to retrieve vip details.') exceptions.handle(self.request, msg, redirect=redirect) @@ -260,7 +260,7 @@ class UpdateMemberView(forms.ModalFormView): member_id = self.kwargs['member_id'] try: self._object = api.lbaas.member_get(self.request, member_id) - except: + except Exception: redirect = self.success_url msg = _('Unable to retrieve member details.') exceptions.handle(self.request, msg, redirect=redirect) @@ -291,7 +291,7 @@ class UpdateMonitorView(forms.ModalFormView): try: self._object = api.lbaas.pool_health_monitor_get( self.request, monitor_id) - except: + except Exception: redirect = self.success_url msg = _('Unable to retrieve health monitor details.') 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']) initial['pool_name'] = pool.name initial['pool_monitors'] = pool.health_monitors - except: + except Exception: msg = _('Unable to retrieve pool.') exceptions.handle(self.request, msg) return initial @@ -332,7 +332,7 @@ class DeletePMAssociationView(workflows.WorkflowView): pool = api.lbaas.pool_get(self.request, initial['pool_id']) initial['pool_name'] = pool.name initial['pool_monitors'] = pool.health_monitors - except: + except Exception: msg = _('Unable to retrieve pool.') exceptions.handle(self.request, msg) return initial diff --git a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py index 5667d6773..db95b2df0 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py @@ -49,7 +49,7 @@ class AddPoolAction(workflows.Action): subnet_id_choices = [('', _("Select a Subnet"))] try: networks = api.neutron.network_list_for_tenant(request, tenant_id) - except: + except Exception: exceptions.handle(request, _('Unable to retrieve networks list.')) networks = [] @@ -109,7 +109,7 @@ class AddPool(workflows.Workflow): try: api.lbaas.pool_create(request, **context) return True - except: + except Exception: return False @@ -225,7 +225,7 @@ class AddVip(workflows.Workflow): try: pool = api.lbaas.pool_get(request, context['pool_id']) context['subnet_id'] = pool['subnet_id'] - except: + except Exception: context['subnet_id'] = None self.failure_message = _('Unable to retrieve the specified pool. ' 'Unable to add VIP "%s".') @@ -245,7 +245,7 @@ class AddVip(workflows.Workflow): try: api.lbaas.vip_create(request, **context) return True - except: + except Exception: return False @@ -275,7 +275,7 @@ class AddMemberAction(workflows.Action): pool_id_choices = [('', _("Select a Pool"))] try: pools = api.lbaas.pools_get(request) - except: + except Exception: pools = [] exceptions.handle(request, _('Unable to retrieve pools list.')) @@ -288,7 +288,7 @@ class AddMemberAction(workflows.Action): members_choices = [] try: servers, has_more = api.nova.server_list(request) - except: + except Exception: servers = [] exceptions.handle(request, _('Unable to retrieve instances list.')) @@ -345,14 +345,14 @@ class AddMember(workflows.Workflow): params = {'device_id': m} try: plist = api.neutron.port_list(request, **params) - except: + except Exception: return False if plist: context['address'] = plist[0].fixed_ips[0]['ip_address'] try: context['member_id'] = api.lbaas.member_create( request, **context).id - except: + except Exception: return False return True @@ -486,7 +486,7 @@ class AddMonitor(workflows.Workflow): context['monitor_id'] = api.lbaas.pool_health_monitor_create( request, **context).get('id') return True - except: + except Exception: exceptions.handle(request, _("Unable to add monitor.")) return False @@ -507,7 +507,7 @@ class AddPMAssociationAction(workflows.Action): for m in monitors: if m.id not in context['pool_monitors']: monitor_id_choices.append((m.id, m.id)) - except: + except Exception: exceptions.handle(request, _('Unable to retrieve monitors list.')) 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( request, **context) return True - except: + except Exception: exceptions.handle(request, _("Unable to add association.")) return False @@ -565,7 +565,7 @@ class DeletePMAssociationAction(workflows.Action): try: for m_id in context['pool_monitors']: monitor_id_choices.append((m_id, m_id)) - except: + except Exception: exceptions.handle(request, _('Unable to retrieve monitors list.')) 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( request, **context) return True - except: + except Exception: exceptions.handle(request, _("Unable to delete association.")) return False diff --git a/openstack_dashboard/dashboards/project/network_topology/views.py b/openstack_dashboard/dashboards/project/network_topology/views.py index fd621c0a4..377c1a283 100644 --- a/openstack_dashboard/dashboards/project/network_topology/views.py +++ b/openstack_dashboard/dashboards/project/network_topology/views.py @@ -53,7 +53,7 @@ class JSONView(View): # Get nova data try: servers, more = api.nova.server_list(request) - except: + except Exception: servers = [] data['servers'] = [{'name': server.name, 'status': server.status, @@ -73,7 +73,7 @@ class JSONView(View): tenant_id=request.user.tenant_id) neutron_routers = api.neutron.router_list(request, tenant_id=request.user.tenant_id) - except: + except Exception: neutron_public_networks = [] neutron_networks = [] neutron_subnets = [] diff --git a/openstack_dashboard/dashboards/project/networks/forms.py b/openstack_dashboard/dashboards/project/networks/forms.py index 9f30482bf..f46f593fc 100644 --- a/openstack_dashboard/dashboards/project/networks/forms.py +++ b/openstack_dashboard/dashboards/project/networks/forms.py @@ -52,7 +52,7 @@ class UpdateNetwork(forms.SelfHandlingForm): LOG.debug(msg) messages.success(request, msg) return network - except: + except Exception: msg = _('Failed to update network %s') % data['name'] LOG.info(msg) redirect = reverse(self.failure_url) diff --git a/openstack_dashboard/dashboards/project/networks/ports/tabs.py b/openstack_dashboard/dashboards/project/networks/ports/tabs.py index 77a356ba2..f5ff3e90a 100644 --- a/openstack_dashboard/dashboards/project/networks/ports/tabs.py +++ b/openstack_dashboard/dashboards/project/networks/ports/tabs.py @@ -37,7 +37,7 @@ class OverviewTab(tabs.Tab): port_id = self.tab_group.kwargs['port_id'] try: port = api.neutron.port_get(self.request, port_id) - except: + except Exception: redirect = reverse('horizon:project:networks:index') msg = _('Unable to retrieve port details.') exceptions.handle(request, msg, redirect=redirect) diff --git a/openstack_dashboard/dashboards/project/networks/ports/views.py b/openstack_dashboard/dashboards/project/networks/ports/views.py index 1a4f395ff..e3fba4cb7 100644 --- a/openstack_dashboard/dashboards/project/networks/ports/views.py +++ b/openstack_dashboard/dashboards/project/networks/ports/views.py @@ -49,7 +49,7 @@ class UpdateView(forms.ModalFormView): port_id = self.kwargs['port_id'] try: self._object = api.neutron.port_get(self.request, port_id) - except: + except Exception: redirect = reverse("horizon:project:networks:detail", args=(self.kwargs['network_id'],)) msg = _('Unable to retrieve port details') diff --git a/openstack_dashboard/dashboards/project/networks/subnets/tables.py b/openstack_dashboard/dashboards/project/networks/subnets/tables.py index 5483ca435..72141ef82 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/tables.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/tables.py @@ -48,7 +48,7 @@ class DeleteSubnet(CheckNetworkEditable, tables.DeleteAction): def delete(self, request, obj_id): try: api.neutron.subnet_delete(request, obj_id) - except: + except Exception: msg = _('Failed to delete subnet %s') % obj_id LOG.info(msg) network_id = self.table.kwargs['network_id'] @@ -93,7 +93,7 @@ class SubnetsTable(tables.DataTable): network_id = self.kwargs['network_id'] network = api.neutron.network_get(self.request, network_id) network.set_id_as_name_if_empty(length=0) - except: + except Exception: msg = _('Unable to retrieve details for network "%s".') \ % (network_id) exceptions.handle(self.request, msg, redirect=self.failure_url) diff --git a/openstack_dashboard/dashboards/project/networks/subnets/tabs.py b/openstack_dashboard/dashboards/project/networks/subnets/tabs.py index e603cedd4..3a745bcbd 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/tabs.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/tabs.py @@ -37,7 +37,7 @@ class OverviewTab(tabs.Tab): subnet_id = self.tab_group.kwargs['subnet_id'] try: subnet = api.neutron.subnet_get(self.request, subnet_id) - except: + except Exception: redirect = reverse('horizon:project:networks:index') msg = _('Unable to retrieve subnet details.') exceptions.handle(request, msg, redirect=redirect) diff --git a/openstack_dashboard/dashboards/project/networks/subnets/views.py b/openstack_dashboard/dashboards/project/networks/subnets/views.py index 1aa55d23a..5ee487b7a 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/views.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/views.py @@ -49,7 +49,7 @@ class CreateView(workflows.WorkflowView): self._object = api.neutron.network_get(self.request, network_id) self._object.set_id_as_name_if_empty() - except: + except Exception: redirect = reverse('horizon:project:networks:index') msg = _("Unable to retrieve network.") exceptions.handle(self.request, msg, redirect=redirect) @@ -69,7 +69,7 @@ class UpdateView(workflows.WorkflowView): subnet_id = self.kwargs['subnet_id'] try: self._object = api.neutron.subnet_get(self.request, subnet_id) - except: + except Exception: redirect = reverse("horizon:project:networks:index") msg = _('Unable to retrieve subnet details') exceptions.handle(self.request, msg, redirect=redirect) diff --git a/openstack_dashboard/dashboards/project/networks/tables.py b/openstack_dashboard/dashboards/project/networks/tables.py index b5f9dc502..880906588 100644 --- a/openstack_dashboard/dashboards/project/networks/tables.py +++ b/openstack_dashboard/dashboards/project/networks/tables.py @@ -55,7 +55,7 @@ class DeleteNetwork(CheckNetworkEditable, tables.DeleteAction): api.neutron.network_delete(request, network_id) LOG.debug('Deleted network %s successfully' % network_id) - except: + except Exception: msg = _('Failed to delete network %s') % network_id LOG.info(msg) redirect = reverse("horizon:project:networks:index") diff --git a/openstack_dashboard/dashboards/project/networks/views.py b/openstack_dashboard/dashboards/project/networks/views.py index 1df1cf7b9..bd3a72b85 100644 --- a/openstack_dashboard/dashboards/project/networks/views.py +++ b/openstack_dashboard/dashboards/project/networks/views.py @@ -52,7 +52,7 @@ class IndexView(tables.DataTableView): tenant_id = self.request.user.tenant_id networks = api.neutron.network_list_for_tenant(self.request, tenant_id) - except: + except Exception: networks = [] msg = _('Network list can not be retrieved.') exceptions.handle(self.request, msg) @@ -85,7 +85,7 @@ class UpdateView(forms.ModalFormView): try: self._object = api.neutron.network_get(self.request, network_id) - except: + except Exception: redirect = self.success_url msg = _('Unable to retrieve network details.') exceptions.handle(self.request, msg, redirect=redirect) @@ -109,7 +109,7 @@ class DetailView(tables.MultiTableView): network = self._get_data() subnets = api.neutron.subnet_list(self.request, network_id=network.id) - except: + except Exception: subnets = [] msg = _('Subnet list can not be retrieved.') exceptions.handle(self.request, msg) @@ -121,7 +121,7 @@ class DetailView(tables.MultiTableView): try: network_id = self.kwargs['network_id'] ports = api.neutron.port_list(self.request, network_id=network_id) - except: + except Exception: ports = [] msg = _('Port list can not be retrieved.') exceptions.handle(self.request, msg) @@ -135,7 +135,7 @@ class DetailView(tables.MultiTableView): network_id = self.kwargs['network_id'] network = api.neutron.network_get(self.request, network_id) network.set_id_as_name_if_empty(length=0) - except: + except Exception: msg = _('Unable to retrieve details for network "%s".') \ % (network_id) exceptions.handle(self.request, msg, redirect=self.failure_url) diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py index c94a3a530..8dfeed6ff 100644 --- a/openstack_dashboard/dashboards/project/networks/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/workflows.py @@ -351,7 +351,7 @@ class CreateNetwork(workflows.Workflow): messages.info(request, msg) raise exceptions.Http302(redirect) #return exceptions.RecoverableError - except: + except Exception: msg = _('Failed to delete network "%s"') % network.name LOG.info(msg) redirect = self.get_failure_url() diff --git a/openstack_dashboard/dashboards/project/routers/forms.py b/openstack_dashboard/dashboards/project/routers/forms.py index 77e53a0c0..36830017e 100644 --- a/openstack_dashboard/dashboards/project/routers/forms.py +++ b/openstack_dashboard/dashboards/project/routers/forms.py @@ -33,7 +33,7 @@ class CreateForm(forms.SelfHandlingForm): message = _('Router %s was successfully created.') % data['name'] messages.success(request, message) return router - except: + except Exception: msg = _('Failed to create router "%s".') % data['name'] LOG.info(msg) redirect = reverse(self.failure_url) diff --git a/openstack_dashboard/dashboards/project/routers/ports/forms.py b/openstack_dashboard/dashboards/project/routers/ports/forms.py index 513027035..545dbba1f 100644 --- a/openstack_dashboard/dashboards/project/routers/ports/forms.py +++ b/openstack_dashboard/dashboards/project/routers/ports/forms.py @@ -96,7 +96,7 @@ class AddInterface(forms.SelfHandlingForm): self._handle_error(request, router_id, e) try: port = api.neutron.port_get(request, router_inf['port_id']) - except: + except Exception: # Ignore an error when port_get() since it is just # to get an IP address for the interface. port = None @@ -107,7 +107,7 @@ class AddInterface(forms.SelfHandlingForm): subnet_id = data['subnet_id'] try: subnet = api.neutron.subnet_get(request, subnet_id) - except: + except Exception: msg = _('Unable to get subnet "%s"') % subnet_id self._handle_error(request, router_id, msg) try: @@ -135,7 +135,7 @@ class AddInterface(forms.SelfHandlingForm): def _delete_port(self, request, port): try: api.neutron.port_delete(request, port.id) - except: + except Exception: msg = _('Failed to delete port %s') % port.id LOG.info(msg) exceptions.handle(request, msg) diff --git a/openstack_dashboard/dashboards/project/routers/ports/tables.py b/openstack_dashboard/dashboards/project/routers/ports/tables.py index 01576373c..0b8d9df12 100644 --- a/openstack_dashboard/dashboards/project/routers/ports/tables.py +++ b/openstack_dashboard/dashboards/project/routers/ports/tables.py @@ -63,7 +63,7 @@ class RemoveInterface(tables.DeleteAction): api.neutron.router_remove_interface(request, router_id, port_id=obj_id) - except: + except Exception: msg = _('Failed to delete interface %s') % obj_id LOG.info(msg) router_id = self.table.kwargs['router_id'] diff --git a/openstack_dashboard/dashboards/project/routers/ports/tabs.py b/openstack_dashboard/dashboards/project/routers/ports/tabs.py index 476ab5d2f..f3ef2c908 100644 --- a/openstack_dashboard/dashboards/project/routers/ports/tabs.py +++ b/openstack_dashboard/dashboards/project/routers/ports/tabs.py @@ -35,7 +35,7 @@ class OverviewTab(tabs.Tab): port_id = self.tab_group.kwargs['port_id'] try: port = api.neutron.port_get(self.request, port_id) - except: + except Exception: redirect = reverse(self.failure_url) msg = _('Unable to retrieve port details.') exceptions.handle(request, msg, redirect=redirect) diff --git a/openstack_dashboard/dashboards/project/routers/ports/views.py b/openstack_dashboard/dashboards/project/routers/ports/views.py index ea08080f7..d64b43e4a 100644 --- a/openstack_dashboard/dashboards/project/routers/ports/views.py +++ b/openstack_dashboard/dashboards/project/routers/ports/views.py @@ -51,7 +51,7 @@ class AddInterfaceView(forms.ModalFormView): router_id = self.kwargs["router_id"] self._object = api.neutron.router_get(self.request, router_id) - except: + except Exception: redirect = reverse(self.failure_url, args=[router_id]) msg = _("Unable to retrieve router.") exceptions.handle(self.request, msg, redirect=redirect) @@ -83,7 +83,7 @@ class SetGatewayView(forms.ModalFormView): router_id = self.kwargs["router_id"] self._object = api.neutron.router_get(self.request, router_id) - except: + except Exception: redirect = reverse(self.failure_url) msg = _("Unable to set gateway.") exceptions.handle(self.request, msg, redirect=redirect) diff --git a/openstack_dashboard/dashboards/project/routers/tabs.py b/openstack_dashboard/dashboards/project/routers/tabs.py index dceb5a26c..b390b6c59 100644 --- a/openstack_dashboard/dashboards/project/routers/tabs.py +++ b/openstack_dashboard/dashboards/project/routers/tabs.py @@ -32,7 +32,7 @@ class OverviewTab(tabs.Tab): router_id = self.tab_group.kwargs['router_id'] try: router = api.neutron.router_get(request, router_id) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve router details.'), redirect=reverse(self.redirect_url)) diff --git a/openstack_dashboard/dashboards/project/routers/views.py b/openstack_dashboard/dashboards/project/routers/views.py index a4c06f955..26936d42d 100644 --- a/openstack_dashboard/dashboards/project/routers/views.py +++ b/openstack_dashboard/dashboards/project/routers/views.py @@ -48,7 +48,7 @@ class IndexView(tables.DataTableView): routers = api.neutron.router_list(self.request, tenant_id=tenant_id, search_opts=search_opts) - except: + except Exception: routers = [] exceptions.handle(self.request, _('Unable to retrieve router list.')) @@ -100,7 +100,7 @@ class DetailView(tables.MultiTableView): router_id = self.kwargs['router_id'] router = api.neutron.router_get(self.request, router_id) router.set_id_as_name_if_empty(length=0) - except: + except Exception: msg = _('Unable to retrieve details for router "%s".') \ % (router_id) exceptions.handle(self.request, msg, redirect=self.failure_url) @@ -131,7 +131,7 @@ class DetailView(tables.MultiTableView): device_id = self.kwargs['router_id'] ports = api.neutron.port_list(self.request, device_id=device_id) - except: + except Exception: ports = [] msg = _('Port list can not be retrieved.') exceptions.handle(self.request, msg) diff --git a/openstack_dashboard/dashboards/project/stacks/api.py b/openstack_dashboard/dashboards/project/stacks/api.py index 9f01e8477..00c10bac8 100644 --- a/openstack_dashboard/dashboards/project/stacks/api.py +++ b/openstack_dashboard/dashboards/project/stacks/api.py @@ -22,7 +22,7 @@ class Stack(object): def d3_data(request, stack_id=''): try: stack = stack_get(request, stack_id) - except: + except Exception: stack = Stack() stack.id = stack_id stack.stack_name = request.session.get('stack_name', '') @@ -31,7 +31,7 @@ def d3_data(request, stack_id=''): try: resources = resources_list(request, stack.stack_name) - except: + except Exception: resources = [] d3_data = {"nodes": [], "stack": {}} diff --git a/openstack_dashboard/dashboards/project/stacks/tabs.py b/openstack_dashboard/dashboards/project/stacks/tabs.py index 9a736bb21..ac667c9a4 100644 --- a/openstack_dashboard/dashboards/project/stacks/tabs.py +++ b/openstack_dashboard/dashboards/project/stacks/tabs.py @@ -74,7 +74,7 @@ class StackEventsTab(tabs.Tab): stack_identifier = '%s/%s' % (stack.stack_name, stack.id) events = api.heat.events_list(self.request, stack_identifier) LOG.debug('got events %s' % events) - except: + except Exception: events = [] messages.error(request, _( '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) resources = api.heat.resources_list(self.request, stack_identifier) LOG.debug('got resources %s' % resources) - except: + except Exception: resources = [] messages.error(request, _( 'Unable to get resources for stack "%s".') % stack.stack_name) diff --git a/openstack_dashboard/dashboards/project/stacks/views.py b/openstack_dashboard/dashboards/project/stacks/views.py index 3dfb2906a..aef8d1e40 100644 --- a/openstack_dashboard/dashboards/project/stacks/views.py +++ b/openstack_dashboard/dashboards/project/stacks/views.py @@ -48,7 +48,7 @@ class IndexView(tables.DataTableView): request = self.request try: stacks = api.heat.stacks_list(self.request) - except: + except Exception: exceptions.handle(request, _('Unable to retrieve stack list.')) stacks = [] return stacks @@ -107,7 +107,7 @@ class DetailView(tabs.TabView): self._stack = stack request.session['stack_id'] = stack.id request.session['stack_name'] = stack.stack_name - except: + except Exception: msg = _("Unable to retrieve stack.") redirect = reverse('horizon:project:stacks:index') exceptions.handle(request, msg, redirect=redirect) @@ -136,7 +136,7 @@ class ResourceView(tabs.TabView): kwargs['stack_id'], kwargs['resource_name']) self._resource = resource - except: + except Exception: msg = _("Unable to retrieve resource.") redirect = reverse('horizon:project:stacks:index') exceptions.handle(request, msg, redirect=redirect) @@ -150,7 +150,7 @@ class ResourceView(tabs.TabView): kwargs['stack_id'], kwargs['resource_name']) self._metadata = json.dumps(metadata, indent=2) - except: + except Exception: msg = _("Unable to retrieve metadata.") redirect = reverse('horizon:project:stacks:index') exceptions.handle(request, msg, redirect=redirect) diff --git a/openstack_dashboard/dashboards/project/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/forms.py index 5a5c0d764..df01b01d8 100644 --- a/openstack_dashboard/dashboards/project/volumes/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/forms.py @@ -95,14 +95,14 @@ class CreateForm(forms.SelfHandlingForm): orig_volume = cinder.volume_get(request, snapshot.volume_id) self.fields['type'].initial = orig_volume.volume_type - except: + except Exception: pass self.fields['size'].help_text = _('Volume size must be equal ' 'to or greater than the snapshot size (%sGB)' % snapshot.size) del self.fields['image_source'] del self.fields['volume_source_type'] - except: + except Exception: exceptions.handle(request, _('Unable to load the specified snapshot.')) elif ('image_id' in request.GET): @@ -118,7 +118,7 @@ class CreateForm(forms.SelfHandlingForm): % filesizeformat(image.size)) del self.fields['snapshot_source'] del self.fields['volume_source_type'] - except: + except Exception: msg = _('Unable to load the specified image. %s') exceptions.handle(request, msg % request.GET['image_id']) else: @@ -134,7 +134,7 @@ class CreateForm(forms.SelfHandlingForm): self.fields['snapshot_source'].choices = choices else: del self.fields['snapshot_source'] - except: + except Exception: exceptions.handle(request, _("Unable to retrieve " "volume snapshots.")) @@ -236,7 +236,7 @@ class CreateForm(forms.SelfHandlingForm): except ValidationError as e: self.api_error(e.messages[0]) return False - except: + except Exception: exceptions.handle(request, ignore=True) self.api_error(_("Unable to create volume.")) return False @@ -316,7 +316,7 @@ class AttachForm(forms.SelfHandlingForm): "dev": attach.device} messages.info(request, message) return True - except: + except Exception: redirect = reverse("horizon:project:volumes:index") exceptions.handle(request, _('Unable to attach volume.'), @@ -346,7 +346,7 @@ class CreateSnapshotForm(forms.SelfHandlingForm): message = _('Creating volume snapshot "%s"') % data['name'] messages.info(request, message) return snapshot - except: + except Exception: redirect = reverse("horizon:project:images_and_snapshots:index") exceptions.handle(request, _('Unable to create volume snapshot.'), diff --git a/openstack_dashboard/dashboards/project/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/tables.py index 7a61ed0c6..e78cd7767 100644 --- a/openstack_dashboard/dashboards/project/volumes/tables.py +++ b/openstack_dashboard/dashboards/project/volumes/tables.py @@ -45,7 +45,7 @@ class DeleteVolume(tables.DeleteAction): name = self.table.get_object_display(obj) try: cinder.volume_delete(request, obj_id) - except: + except Exception: msg = _('Unable to delete volume "%s". One or more snapshots ' 'depend on it.') exceptions.check_message(["snapshots", "dependent"], msg % name) @@ -106,7 +106,7 @@ def get_attachment_name(request, attachment): try: server = api.nova.server_get(request, server_id) name = server.name - except: + except Exception: name = None exceptions.handle(request, _("Unable to retrieve " "attachment information.")) diff --git a/openstack_dashboard/dashboards/project/volumes/tabs.py b/openstack_dashboard/dashboards/project/volumes/tabs.py index b266342bc..77cd778ee 100644 --- a/openstack_dashboard/dashboards/project/volumes/tabs.py +++ b/openstack_dashboard/dashboards/project/volumes/tabs.py @@ -36,7 +36,7 @@ class OverviewTab(tabs.Tab): volume = cinder.volume_get(request, volume_id) for att in volume.attachments: att['instance'] = nova.server_get(request, att['server_id']) - except: + except Exception: redirect = reverse('horizon:project:volumes:index') exceptions.handle(self.request, _('Unable to retrieve volume details.'), diff --git a/openstack_dashboard/dashboards/project/volumes/views.py b/openstack_dashboard/dashboards/project/volumes/views.py index cf3fbd95c..a98b8d6c1 100644 --- a/openstack_dashboard/dashboards/project/volumes/views.py +++ b/openstack_dashboard/dashboards/project/volumes/views.py @@ -52,7 +52,7 @@ class VolumeTableMixIn(object): def _get_volumes(self, search_opts=None): try: return cinder.volume_list(self.request, search_opts=search_opts) - except: + except Exception: exceptions.handle(self.request, _('Unable to retrieve volume list.')) return [] @@ -62,7 +62,7 @@ class VolumeTableMixIn(object): instances, has_more = api.nova.server_list(self.request, search_opts=search_opts) return instances - except: + except Exception: exceptions.handle(self.request, _("Unable to retrieve volume/instance " "attachment information")) @@ -115,7 +115,7 @@ class CreateView(forms.ModalFormView): context['usages']['gigabytesUsed'] = total_size context['usages']['volumesUsed'] = len(volumes) - except: + except Exception: exceptions.handle(self.request) return context @@ -130,7 +130,7 @@ class CreateSnapshotView(forms.ModalFormView): context['volume_id'] = self.kwargs['volume_id'] try: context['usages'] = quotas.tenant_quota_usages(self.request) - except: + except Exception: exceptions.handle(self.request) return context @@ -149,7 +149,7 @@ class EditAttachmentsView(tables.DataTableView, forms.ModalFormView): volume_id = self.kwargs['volume_id'] try: self._object = cinder.volume_get(self.request, volume_id) - except: + except Exception: self._object = None exceptions.handle(self.request, _('Unable to retrieve volume information.')) @@ -159,7 +159,7 @@ class EditAttachmentsView(tables.DataTableView, forms.ModalFormView): try: volumes = self.get_object() attachments = [att for att in volumes.attachments if att] - except: + except Exception: attachments = [] exceptions.handle(self.request, _('Unable to retrieve volume information.')) @@ -168,7 +168,7 @@ class EditAttachmentsView(tables.DataTableView, forms.ModalFormView): def get_initial(self): try: instances, has_more = api.nova.server_list(self.request) - except: + except Exception: instances = [] exceptions.handle(self.request, _("Unable to retrieve attachment information.")) diff --git a/openstack_dashboard/dashboards/settings/password/forms.py b/openstack_dashboard/dashboards/settings/password/forms.py index 36963d494..7428df03c 100644 --- a/openstack_dashboard/dashboards/settings/password/forms.py +++ b/openstack_dashboard/dashboards/settings/password/forms.py @@ -57,7 +57,7 @@ class PasswordForm(forms.SelfHandlingForm): data['current_password'], data['new_password']) messages.success(request, _('Password changed.')) - except: + except Exception: exceptions.handle(request, _('Unable to change password.')) return False diff --git a/openstack_dashboard/dashboards/settings/user/forms.py b/openstack_dashboard/dashboards/settings/user/forms.py index 67cdb7d08..f2c3c230b 100644 --- a/openstack_dashboard/dashboards/settings/user/forms.py +++ b/openstack_dashboard/dashboards/settings/user/forms.py @@ -53,7 +53,7 @@ class UserSettingsForm(forms.SelfHandlingForm): try: utc_offset = pytz.timezone(tz).localize(d).strftime('%z') utc_offset = " (UTC %s:%s)" % (utc_offset[:3], utc_offset[3:]) - except: + except Exception: utc_offset = "" if tz != "UTC": |