diff --git a/horizon/base.py b/horizon/base.py index f9f9d85237..0a4ec13efd 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -309,7 +309,8 @@ class Panel(HorizonComponent): except Exception as exc: # Logging here since this will often be called in a template # where the exception would be hidden. - LOG.info("Error reversing absolute URL for %s: %s" % (self, exc)) + LOG.info("Error reversing absolute URL for %(self)s: %(exc)s", + {'self': self, 'exc': exc}) raise @property @@ -524,7 +525,7 @@ class Dashboard(Registry, HorizonComponent): except Exception: # Logging here since this will often be called in a template # where the exception would be hidden. - LOG.exception("Error reversing absolute URL for %s." % self) + LOG.exception("Error reversing absolute URL for %s.", self) raise @property diff --git a/horizon/middleware/base.py b/horizon/middleware/base.py index f8a8eee3a9..7ae8f9abc3 100644 --- a/horizon/middleware/base.py +++ b/horizon/middleware/base.py @@ -97,8 +97,8 @@ class HorizonMiddleware(object): 'You need to configure file-based or database-backed ' 'sessions instead of cookie-based sessions: ' 'http://docs.openstack.org/developer/horizon/topics/' - 'deployment.html#session-storage' - % { + 'deployment.html#session-storage', + { 'user_id': request.session.get( 'user_id', 'Unknown'), 'cookie_size': cookie_size, diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py index 201532f44f..47e9acd80c 100644 --- a/horizon/tables/actions.py +++ b/horizon/tables/actions.py @@ -405,7 +405,8 @@ class LinkAction(BaseAction): else: return urlresolvers.reverse(self.url) except urlresolvers.NoReverseMatch as ex: - LOG.info('No reverse found for "%s": %s' % (self.url, ex)) + LOG.info('No reverse found for "%(url)s": %(exception)s', + {'url': self.url, 'exception': ex}) return self.url @@ -846,8 +847,9 @@ class BatchAction(Action): self.update(request, datum) action_success.append(datum_display) self.success_ids.append(datum_id) - LOG.info(u'%s: "%s"' % - (self._get_action_name(past=True), datum_display)) + LOG.info(u'%(action)s: "%(datum_display)s"', + {'action': self._get_action_name(past=True), + 'datum_display': datum_display}) except Exception as ex: # Handle the exception but silence it since we'll display # an aggregate error message later. Otherwise we'd get @@ -972,14 +974,15 @@ class Deprecated(type): # oslo_log.versionutils when it's finally added in 11.0 def __new__(meta, name, bases, kwargs): cls = super(Deprecated, meta).__new__(meta, name, bases, kwargs) - message = ("WARNING:The UpdateAction class defined in module '%s'" - " is deprecated as of Newton and may be removed in " - "Horizon P (12.0). Class '%s' defined at module '%s' " - "shall no longer subclass it.") if name != 'UpdateAction': - LOG.warning(message % (UpdateAction.__module__, - name, - kwargs['__module__'])) + LOG.warning( + "WARNING:The UpdateAction class defined in module '%(mod)s' " + "is deprecated as of Newton and may be removed in " + "Horizon P (12.0). Class '%(name)s' defined at " + "module '%(module)s' shall no longer subclass it.", + {'mod': UpdateAction.__module__, + 'name': name, + 'module': kwargs['__module__']}) return cls diff --git a/horizon/tables/base.py b/horizon/tables/base.py index 8f0c9cd4b7..8ac441488a 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -1673,8 +1673,8 @@ class DataTable(object): # If not allowed, neither edit mod or updating is allowed. if not cell.update_allowed: datum_display = (self.get_object_display(datum) or "N/A") - LOG.info('Permission denied to %s: "%s"' % - ("Update Action", datum_display)) + LOG.info('Permission denied to Update Action: "%s"', + datum_display) return HttpResponse(status=401) # If it is post request, we are updating the cell. if request.method == "POST": diff --git a/horizon/test/helpers.py b/horizon/test/helpers.py index 82f4c85917..b3b0dd4e1a 100644 --- a/horizon/test/helpers.py +++ b/horizon/test/helpers.py @@ -52,7 +52,7 @@ try: from horizon.test.webdriver import WebDriver except ImportError as e: - LOG.warning("{0}, force WITH_SELENIUM=False".format(str(e))) + LOG.warning("%s, force WITH_SELENIUM=False", e) os.environ['WITH_SELENIUM'] = '' diff --git a/horizon/utils/file_discovery.py b/horizon/utils/file_discovery.py index b5784b5d1e..03227030ce 100644 --- a/horizon/utils/file_discovery.py +++ b/horizon/utils/file_discovery.py @@ -108,5 +108,7 @@ def _log(file_list, list_name, in_path): """Logs result at debug level """ file_names = '\n'.join(file_list) - LOG.debug("\nDiscovered {0} {1} file(s) in {2}:\n{3}\n" - .format(len(file_list), list_name, in_path, file_names)) + LOG.debug("\nDiscovered %(size)d %(name)s file(s) in %(path)s:\n" + "%(files)s\n", + {'size': len(file_list), 'name': list_name, 'path': in_path, + 'files': file_names}) diff --git a/openstack_dashboard/api/glance.py b/openstack_dashboard/api/glance.py index 86d4971daf..d0f31f8146 100644 --- a/openstack_dashboard/api/glance.py +++ b/openstack_dashboard/api/glance.py @@ -351,10 +351,9 @@ def image_update(request, image_id, **kwargs): filename = str(image_data.file) if hasattr(image_data.file, 'name'): filename = image_data.file.name - msg = (('Failed to remove temporary image file ' - '%(file)s (%(e)s)') % - dict(file=filename, e=str(e))) - LOG.warning(msg) + LOG.warning('Failed to remove temporary image file ' + '%(file)s (%(e)s)', + {'file': filename, 'e': e}) def get_image_upload_mode(): @@ -363,7 +362,7 @@ def get_image_upload_mode(): mode = getattr(settings, 'HORIZON_IMAGES_UPLOAD_MODE', 'legacy') if mode not in ('off', 'legacy', 'direct'): LOG.warning('HORIZON_IMAGES_UPLOAD_MODE has an unrecognized value of ' - '"%s", reverting to default "legacy" value' % mode) + '"%s", reverting to default "legacy" value', mode) mode = 'legacy' return mode diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py index eb80da7cec..e6ca1d2aa8 100644 --- a/openstack_dashboard/api/keystone.py +++ b/openstack_dashboard/api/keystone.py @@ -186,7 +186,7 @@ def keystoneclient(request, admin=False): endpoint = _get_endpoint_url(request, endpoint_type) insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False) cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None) - LOG.debug("Creating a new keystoneclient connection to %s." % endpoint) + LOG.debug("Creating a new keystoneclient connection to %s.", endpoint) remote_addr = request.environ.get('REMOTE_ADDR', '') conn = api_version['client'].Client(token=token_id, endpoint=endpoint, @@ -247,7 +247,7 @@ def domain_update(request, domain_id, name=None, description=None, response = manager.update(domain_id, name=name, description=description, enabled=enabled) except Exception: - LOG.exception("Unable to update Domain: %s" % domain_id) + LOG.exception("Unable to update Domain: %s", domain_id) raise return response @@ -299,11 +299,12 @@ def get_default_domain(request, get_name=True): # we recognize this condition and return the user's # domain information instead. LOG.debug("Cannot retrieve domain information for " - "user (%s) that does not have an admin role " - "on project (%s)" % - (request.user.username, request.user.project_name)) + "user (%(user)s) that does not have an admin role " + "on project (%(project)s)", + {'user': request.user.username, + 'project': request.user.project_name}) except Exception: - LOG.warning("Unable to retrieve Domain: %s" % domain_id) + LOG.warning("Unable to retrieve Domain: %s", domain_id) domain = base.APIDictWrapper({"id": domain_id, "name": domain_name}) return domain diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index d13d64ea5e..5c44d237de 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -645,8 +645,8 @@ def network_list_for_tenant(request, tenant_id, include_external=False, The list contains networks owned by the tenant and public networks. If requested_networks specified, it searches requested_networks only. """ - LOG.debug("network_list_for_tenant(): tenant_id=%s, params=%s" - % (tenant_id, params)) + LOG.debug("network_list_for_tenant(): tenant_id=%(tenant_id)s, " + "params=%(params)s", {'tenant_id': tenant_id, 'params': params}) networks = [] shared = params.get('shared') @@ -682,7 +682,8 @@ def network_list_for_tenant(request, tenant_id, include_external=False, @profiler.trace def network_get(request, network_id, expand_subnet=True, **params): - LOG.debug("network_get(): netid=%s, params=%s" % (network_id, params)) + LOG.debug("network_get(): netid=%(network_id)s, params=%(params)s", + {'network_id': network_id, 'params': params}) network = neutronclient(request).show_network(network_id, **params).get('network') if expand_subnet: @@ -704,7 +705,7 @@ def network_create(request, **kwargs): :param name: (optional) name of the network created :returns: Network object """ - LOG.debug("network_create(): kwargs = %s" % kwargs) + LOG.debug("network_create(): kwargs = %s", kwargs) if 'tenant_id' not in kwargs: kwargs['tenant_id'] = request.user.project_id body = {'network': kwargs} @@ -714,7 +715,8 @@ def network_create(request, **kwargs): @profiler.trace def network_update(request, network_id, **kwargs): - LOG.debug("network_update(): netid=%s, params=%s" % (network_id, kwargs)) + LOG.debug("network_update(): netid=%(network_id)s, params=%(params)s", + {'network_id': network_id, 'params': kwargs}) body = {'network': kwargs} network = neutronclient(request).update_network(network_id, body=body).get('network') @@ -723,20 +725,21 @@ def network_update(request, network_id, **kwargs): @profiler.trace def network_delete(request, network_id): - LOG.debug("network_delete(): netid=%s" % network_id) + LOG.debug("network_delete(): netid=%s", network_id) neutronclient(request).delete_network(network_id) @profiler.trace def subnet_list(request, **params): - LOG.debug("subnet_list(): params=%s" % (params)) + LOG.debug("subnet_list(): params=%s", params) subnets = neutronclient(request).list_subnets(**params).get('subnets') return [Subnet(s) for s in subnets] @profiler.trace def subnet_get(request, subnet_id, **params): - LOG.debug("subnet_get(): subnetid=%s, params=%s" % (subnet_id, params)) + LOG.debug("subnet_get(): subnetid=%(subnet_id)s, params=%(params)s", + {'subnet_id': subnet_id, 'params': params}) subnet = neutronclient(request).show_subnet(subnet_id, **params).get('subnet') return Subnet(subnet) @@ -761,8 +764,8 @@ def subnet_create(request, network_id, **kwargs): optional you MUST pass along one of the combinations to get a successful result. """ - LOG.debug("subnet_create(): netid=%s, kwargs=%s" - % (network_id, kwargs)) + LOG.debug("subnet_create(): netid=%(network_id)s, kwargs=%(kwargs)s", + {'network_id': network_id, 'kwargs': kwargs}) body = {'subnet': {'network_id': network_id}} if 'tenant_id' not in kwargs: kwargs['tenant_id'] = request.user.project_id @@ -773,7 +776,8 @@ def subnet_create(request, network_id, **kwargs): @profiler.trace def subnet_update(request, subnet_id, **kwargs): - LOG.debug("subnet_update(): subnetid=%s, kwargs=%s" % (subnet_id, kwargs)) + LOG.debug("subnet_update(): subnetid=%(subnet_id)s, kwargs=%(kwargs)s", + {'subnet_id': subnet_id, 'kwargs': kwargs}) body = {'subnet': kwargs} subnet = neutronclient(request).update_subnet(subnet_id, body=body).get('subnet') @@ -782,13 +786,13 @@ def subnet_update(request, subnet_id, **kwargs): @profiler.trace def subnet_delete(request, subnet_id): - LOG.debug("subnet_delete(): subnetid=%s" % subnet_id) + LOG.debug("subnet_delete(): subnetid=%s", subnet_id) neutronclient(request).delete_subnet(subnet_id) @profiler.trace def subnetpool_list(request, **params): - LOG.debug("subnetpool_list(): params=%s" % (params)) + LOG.debug("subnetpool_list(): params=%s", params) subnetpools = \ neutronclient(request).list_subnetpools(**params).get('subnetpools') return [SubnetPool(s) for s in subnetpools] @@ -796,8 +800,9 @@ def subnetpool_list(request, **params): @profiler.trace def subnetpool_get(request, subnetpool_id, **params): - LOG.debug("subnetpool_get(): subnetpoolid=%s, params=%s" % - (subnetpool_id, params)) + LOG.debug("subnetpool_get(): subnetpoolid=%(subnetpool_id)s, " + "params=%(params)s", {'subnetpool_id': subnetpool_id, + 'params': params}) subnetpool = \ neutronclient(request).show_subnetpool(subnetpool_id, **params).get('subnetpool') @@ -826,8 +831,9 @@ def subnetpool_create(request, name, prefixes, **kwargs): Returns: SubnetPool object """ - LOG.debug("subnetpool_create(): name=%s, prefixes=%s, kwargs=%s" - % (name, prefixes, kwargs)) + LOG.debug("subnetpool_create(): name=%(name)s, prefixes=%(prefixes)s, " + "kwargs=%(kwargs)s", {'name': name, 'prefixes': prefixes, + 'kwargs': kwargs}) body = {'subnetpool': {'name': name, 'prefixes': prefixes, @@ -843,8 +849,9 @@ def subnetpool_create(request, name, prefixes, **kwargs): @profiler.trace def subnetpool_update(request, subnetpool_id, **kwargs): - LOG.debug("subnetpool_update(): subnetpoolid=%s, kwargs=%s" % - (subnetpool_id, kwargs)) + LOG.debug("subnetpool_update(): subnetpoolid=%(subnetpool_id)s, " + "kwargs=%(kwargs)s", {'subnetpool_id': subnetpool_id, + 'kwargs': kwargs}) body = {'subnetpool': kwargs} subnetpool = \ neutronclient(request).update_subnetpool(subnetpool_id, @@ -854,20 +861,21 @@ def subnetpool_update(request, subnetpool_id, **kwargs): @profiler.trace def subnetpool_delete(request, subnetpool_id): - LOG.debug("subnetpool_delete(): subnetpoolid=%s" % subnetpool_id) + LOG.debug("subnetpool_delete(): subnetpoolid=%s", subnetpool_id) return neutronclient(request).delete_subnetpool(subnetpool_id) @profiler.trace def port_list(request, **params): - LOG.debug("port_list(): params=%s" % (params)) + LOG.debug("port_list(): params=%s", params) ports = neutronclient(request).list_ports(**params).get('ports') return [Port(p) for p in ports] @profiler.trace def port_get(request, port_id, **params): - LOG.debug("port_get(): portid=%s, params=%s" % (port_id, params)) + LOG.debug("port_get(): portid=%(port_id)s, params=%(params)s", + {'port_id': port_id, 'params': params}) port = neutronclient(request).show_port(port_id, **params).get('port') return Port(port) @@ -890,7 +898,8 @@ def port_create(request, network_id, **kwargs): :param name: (optional) name of the port created :returns: Port object """ - LOG.debug("port_create(): netid=%s, kwargs=%s" % (network_id, kwargs)) + LOG.debug("port_create(): netid=%(network_id)s, kwargs=%(kwargs)s", + {'network_id': network_id, 'kwargs': kwargs}) kwargs = unescape_port_kwargs(**kwargs) body = {'port': {'network_id': network_id}} if 'tenant_id' not in kwargs: @@ -902,13 +911,14 @@ def port_create(request, network_id, **kwargs): @profiler.trace def port_delete(request, port_id): - LOG.debug("port_delete(): portid=%s" % port_id) + LOG.debug("port_delete(): portid=%s", port_id) neutronclient(request).delete_port(port_id) @profiler.trace def port_update(request, port_id, **kwargs): - LOG.debug("port_update(): portid=%s, kwargs=%s" % (port_id, kwargs)) + LOG.debug("port_update(): portid=%(port_id)s, kwargs=%(kwargs)s", + {'port_id': port_id, 'kwargs': kwargs}) kwargs = unescape_port_kwargs(**kwargs) body = {'port': kwargs} port = neutronclient(request).update_port(port_id, body=body).get('port') @@ -917,7 +927,7 @@ def port_update(request, port_id, **kwargs): @profiler.trace def router_create(request, **kwargs): - LOG.debug("router_create():, kwargs=%s" % kwargs) + LOG.debug("router_create():, kwargs=%s", kwargs) body = {'router': {}} if 'tenant_id' not in kwargs: kwargs['tenant_id'] = request.user.project_id @@ -928,7 +938,8 @@ def router_create(request, **kwargs): @profiler.trace def router_update(request, r_id, **kwargs): - LOG.debug("router_update(): router_id=%s, kwargs=%s" % (r_id, kwargs)) + LOG.debug("router_update(): router_id=%(r_id)s, kwargs=%(kwargs)s", + {'r_id': r_id, 'kwargs': kwargs}) body = {'router': {}} body['router'].update(kwargs) router = neutronclient(request).update_router(r_id, body=body) diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py index bcbfa1c829..3fddf6d3b0 100644 --- a/openstack_dashboard/api/nova.py +++ b/openstack_dashboard/api/nova.py @@ -350,9 +350,9 @@ class SecurityGroupManager(network_base.SecurityGroupManager): num_groups_to_modify -= 1 except nova_exceptions.ClientException as err: LOG.error(_("Failed to modify %(num_groups_to_modify)d instance " - "security groups: %(err)s") % - dict(num_groups_to_modify=num_groups_to_modify, - err=err)) + "security groups: %(err)s"), + {'num_groups_to_modify': num_groups_to_modify, + 'err': err}) # reraise novaclient.exceptions.ClientException, but with # a sanitized error message so we don't risk exposing # sensitive information to the end user. This has to be diff --git a/openstack_dashboard/dashboards/admin/floating_ips/tables.py b/openstack_dashboard/dashboards/admin/floating_ips/tables.py index e9007d61da..9d7c9ce5e4 100644 --- a/openstack_dashboard/dashboards/admin/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/admin/floating_ips/tables.py @@ -62,7 +62,7 @@ class AdminSimpleDisassociateIP(project_tables.DisassociateIP): try: fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id)) api.network.floating_ip_disassociate(request, fip.id) - LOG.info('Disassociating Floating IP "%s".' % obj_id) + LOG.info('Disassociating Floating IP "%s".', obj_id) messages.success(request, _('Successfully disassociated Floating IP: %s') % fip.ip) diff --git a/openstack_dashboard/dashboards/admin/images/views.py b/openstack_dashboard/dashboards/admin/images/views.py index 7bc4dcdcec..478a0a3fe7 100644 --- a/openstack_dashboard/dashboards/admin/images/views.py +++ b/openstack_dashboard/dashboards/admin/images/views.py @@ -120,16 +120,20 @@ class IndexView(tables.DataTableView): if filter_field and filter_string and ( filter_action.is_api_filter(filter_field)): if filter_field in ['size_min', 'size_max']: - invalid_msg = ('API query is not valid and is ignored: %s=%s' - % (filter_field, filter_string)) + invalid_msg = ('API query is not valid and is ignored: ' + '%(field)s=%(string)s') try: filter_string = long(float(filter_string) * (units.Mi)) if filter_string >= 0: filters[filter_field] = filter_string else: - LOG.warning(invalid_msg) + LOG.warning(invalid_msg, + {'field': filter_field, + 'string': filter_string}) except ValueError: - LOG.warning(invalid_msg) + LOG.warning(invalid_msg, + {'field': filter_field, + 'string': filter_string}) elif (filter_field == 'disk_format' and filter_string.lower() == 'docker'): filters['disk_format'] = 'raw' diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py index c9d9e614f5..3eec873898 100644 --- a/openstack_dashboard/dashboards/admin/networks/forms.py +++ b/openstack_dashboard/dashboards/admin/networks/forms.py @@ -263,8 +263,7 @@ class CreateNetwork(forms.SelfHandlingForm): params['provider:segmentation_id'] = ( data['segmentation_id']) network = api.neutron.network_create(request, **params) - msg = _('Network %s was successfully created.') % data['name'] - LOG.debug(msg) + LOG.debug(_('Network %s was successfully created.'), data['name']) return network except Exception: redirect = reverse('horizon:admin:networks:index') diff --git a/openstack_dashboard/dashboards/admin/networks/ports/forms.py b/openstack_dashboard/dashboards/admin/networks/ports/forms.py index 3aeb19916c..5db8f4566a 100644 --- a/openstack_dashboard/dashboards/admin/networks/ports/forms.py +++ b/openstack_dashboard/dashboards/admin/networks/ports/forms.py @@ -160,7 +160,7 @@ class UpdatePort(project_forms.UpdatePort): def handle(self, request, data): try: - LOG.debug('params = %s' % data) + LOG.debug('params = %s', data) extension_kwargs = {} data['admin_state'] = (data['admin_state'] == 'True') if 'binding__vnic_type' in data: diff --git a/openstack_dashboard/dashboards/identity/domains/tables.py b/openstack_dashboard/dashboards/identity/domains/tables.py index f86af9860d..6afc63b113 100644 --- a/openstack_dashboard/dashboards/identity/domains/tables.py +++ b/openstack_dashboard/dashboards/identity/domains/tables.py @@ -118,7 +118,7 @@ class DeleteDomainsAction(tables.DeleteAction): messages.error(request, msg) raise exceptions.ClientException(409, msg) else: - LOG.info('Deleting domain "%s".' % obj_id) + LOG.info('Deleting domain "%s".', obj_id) api.keystone.domain_delete(request, obj_id) @@ -150,7 +150,7 @@ class DisableDomainsAction(tables.BatchAction): def action(self, request, obj_id): domain = self.table.get_object_by_id(obj_id) if domain.enabled: - LOG.info('Disabling domain "%s".' % obj_id) + LOG.info('Disabling domain "%s".', obj_id) try: api.keystone.domain_update(request, domain_id=domain.id, @@ -190,7 +190,7 @@ class EnableDomainsAction(tables.BatchAction): def action(self, request, obj_id): domain = self.table.get_object_by_id(obj_id) if not domain.enabled: - LOG.info('Enabling domain "%s".' % obj_id) + LOG.info('Enabling domain "%s".', obj_id) try: api.keystone.domain_update(request, domain_id=domain.id, diff --git a/openstack_dashboard/dashboards/identity/domains/workflows.py b/openstack_dashboard/dashboards/identity/domains/workflows.py index d3f3e3453b..2f68452904 100644 --- a/openstack_dashboard/dashboards/identity/domains/workflows.py +++ b/openstack_dashboard/dashboards/identity/domains/workflows.py @@ -265,7 +265,7 @@ class CreateDomain(workflows.Workflow): def handle(self, request, data): # create the domain try: - LOG.info('Creating domain with name "%s"' % data['name']) + LOG.info('Creating domain with name "%s"', data['name']) desc = data['description'] api.keystone.domain_create(request, name=data['name'], @@ -491,7 +491,7 @@ class UpdateDomain(workflows.Workflow): domain_id = data.pop('domain_id') try: - LOG.info('Updating domain with name "%s"' % data['name']) + LOG.info('Updating domain with name "%s"', data['name']) api.keystone.domain_update(request, domain_id, name=data['name'], diff --git a/openstack_dashboard/dashboards/identity/groups/forms.py b/openstack_dashboard/dashboards/identity/groups/forms.py index 379d83ff87..342e218a92 100644 --- a/openstack_dashboard/dashboards/identity/groups/forms.py +++ b/openstack_dashboard/dashboards/identity/groups/forms.py @@ -36,7 +36,7 @@ class CreateGroupForm(forms.SelfHandlingForm): def handle(self, request, data): try: - LOG.info('Creating group with name "%s"' % data['name']) + LOG.info('Creating group with name "%s"', data['name']) api.keystone.group_create( request, domain_id=identity_utils.get_domain_id_for_operation( diff --git a/openstack_dashboard/dashboards/identity/groups/tables.py b/openstack_dashboard/dashboards/identity/groups/tables.py index 9797517106..86148f044f 100644 --- a/openstack_dashboard/dashboards/identity/groups/tables.py +++ b/openstack_dashboard/dashboards/identity/groups/tables.py @@ -83,7 +83,7 @@ class DeleteGroupsAction(policy.PolicyTargetMixin, tables.DeleteAction): return api.keystone.keystone_can_edit_group() def delete(self, request, obj_id): - LOG.info('Deleting group "%s".' % obj_id) + LOG.info('Deleting group "%s".', obj_id) api.keystone.group_delete(request, obj_id) @@ -154,8 +154,8 @@ class RemoveMembers(tables.DeleteAction): def action(self, request, obj_id): user_obj = self.table.get_object_by_id(obj_id) group_id = self.table.kwargs['group_id'] - LOG.info('Removing user %s from group %s.' % (user_obj.id, - group_id)) + LOG.info('Removing user %(user)s from group %(group)s.', + {'user': user_obj.id, 'group': group_id}) api.keystone.remove_group_user(request, group_id=group_id, user_id=user_obj.id) @@ -233,8 +233,8 @@ class AddMembers(tables.BatchAction): def action(self, request, obj_id): user_obj = self.table.get_object_by_id(obj_id) group_id = self.table.kwargs['group_id'] - LOG.info('Adding user %s to group %s.' % (user_obj.id, - group_id)) + LOG.info('Adding user %(user)s to group %(group)s.', + {'user': user_obj.id, 'group': group_id}) api.keystone.add_group_user(request, group_id=group_id, user_id=user_obj.id) diff --git a/openstack_dashboard/dashboards/identity/projects/workflows.py b/openstack_dashboard/dashboards/identity/projects/workflows.py index 0150f0d935..76eda7b020 100644 --- a/openstack_dashboard/dashboards/identity/projects/workflows.py +++ b/openstack_dashboard/dashboards/identity/projects/workflows.py @@ -705,7 +705,7 @@ class UpdateProject(CommonQuotaWorkflow): self.failure_message = msg return except Exception as e: - LOG.debug('Project update failed: %s' % e) + LOG.debug('Project update failed: %s', e) exceptions.handle(request, ignore=True) return diff --git a/openstack_dashboard/dashboards/identity/users/forms.py b/openstack_dashboard/dashboards/identity/users/forms.py index 74bfa2564d..e34cfdcf91 100644 --- a/openstack_dashboard/dashboards/identity/users/forms.py +++ b/openstack_dashboard/dashboards/identity/users/forms.py @@ -90,7 +90,7 @@ class BaseUserForm(forms.SelfHandlingForm): self.fields['project'].choices = project_choices except Exception: - LOG.debug("User: %s has no projects" % user_id) + LOG.debug("User: %s has no projects", user_id) class AddExtraColumnMixIn(object): @@ -162,7 +162,7 @@ class CreateUserForm(PasswordMixin, BaseUserForm, AddExtraColumnMixIn): def handle(self, request, data): domain = api.keystone.get_default_domain(self.request, False) try: - LOG.info('Creating user with name "%s"' % data['name']) + LOG.info('Creating user with name "%s"', data['name']) desc = data["description"] if "email" in data: data['email'] = data['email'] or None diff --git a/openstack_dashboard/dashboards/identity/users/views.py b/openstack_dashboard/dashboards/identity/users/views.py index 3061668376..32ce48b263 100644 --- a/openstack_dashboard/dashboards/identity/users/views.py +++ b/openstack_dashboard/dashboards/identity/users/views.py @@ -241,9 +241,8 @@ class DetailView(views.HorizonTemplateView): try: tenant = api.keystone.tenant_get(self.request, project_id) except Exception as e: - msg = ('Failed to get tenant %(project_id)s: %(reason)s' % - {'project_id': project_id, 'reason': e}) - LOG.error(msg) + LOG.error('Failed to get tenant %(project_id)s: %(reason)s', + {'project_id': project_id, 'reason': e}) return tenant @memoized.memoized_method diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py index 88ab925f45..21cc9536ba 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tables.py @@ -145,7 +145,7 @@ class DisassociateIP(tables.Action): try: fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id)) api.network.floating_ip_disassociate(request, fip.id) - LOG.info('Disassociating Floating IP "%s".' % obj_id) + LOG.info('Disassociating Floating IP "%s".', obj_id) messages.success(request, _('Successfully disassociated Floating IP: %s') % fip.ip) diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py index e2a49625a2..bc59c1976d 100644 --- a/openstack_dashboard/dashboards/project/instances/views.py +++ b/openstack_dashboard/dashboards/project/instances/views.py @@ -141,9 +141,9 @@ class IndexView(tables.DataTableView): instance.full_flavor = api.nova.flavor_get( self.request, flavor_id) except Exception: - msg = ('Unable to retrieve flavor "%s" for instance "%s".' - % (flavor_id, instance.id)) - LOG.info(msg) + LOG.info('Unable to retrieve flavor "%(flavor)s" for ' + 'instance "%(id)s".', + {'flavor': flavor_id, 'id': instance.id}) return instances diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py index 931be79167..c4e8053b7a 100644 --- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py +++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py @@ -677,7 +677,7 @@ class CustomizeAction(workflows.Action): if has_upload: upload_file = files[upload_str] log_script_name = upload_file.name - LOG.info('got upload %s' % log_script_name) + LOG.info('got upload %s', log_script_name) if upload_file._size > 16 * units.Ki: # 16kb msg = _('File exceeds maximum size (16kb)') @@ -975,7 +975,7 @@ def _cleanup_ports_on_failed_vm_launch(request, nics): LOG.debug('Cleaning up stale VM ports.') for nic in nics: try: - LOG.debug('Deleting port with id: %s' % nic['port-id']) + LOG.debug('Deleting port with id: %s', nic['port-id']) api.neutron.port_delete(request, nic['port-id']) except Exception: ports_failing_deletes.append(nic['port-id']) diff --git a/openstack_dashboard/dashboards/project/networks/ports/forms.py b/openstack_dashboard/dashboards/project/networks/ports/forms.py index c94e0ca60b..1ab9f6999e 100644 --- a/openstack_dashboard/dashboards/project/networks/ports/forms.py +++ b/openstack_dashboard/dashboards/project/networks/ports/forms.py @@ -231,7 +231,7 @@ class UpdatePort(forms.SelfHandlingForm): def handle(self, request, data): data['admin_state'] = (data['admin_state'] == 'True') try: - LOG.debug('params = %s' % data) + LOG.debug('params = %s', data) extension_kwargs = {} if 'binding__vnic_type' in data: extension_kwargs['binding__vnic_type'] = \ diff --git a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py index c0e8b836f0..1202dcc3be 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py @@ -188,8 +188,7 @@ class UpdateSubnet(network_workflows.CreateNetwork): self._setup_subnet_parameters(params, data, is_create=False) subnet = api.neutron.subnet_update(request, subnet_id, **params) - msg = _('Subnet "%s" was successfully updated.') % data['cidr'] - LOG.debug(msg) + LOG.debug('Subnet "%s" was successfully updated.', data['cidr']) return subnet except Exception as e: msg = (_('Failed to update subnet "%(sub)s": ' diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py index d745429af4..15a0c3d4c1 100644 --- a/openstack_dashboard/dashboards/project/networks/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/workflows.py @@ -467,9 +467,8 @@ class CreateNetwork(workflows.Workflow): 'shared': data['shared']} network = api.neutron.network_create(request, **params) self.context['net_id'] = network.id - msg = (_('Network "%s" was successfully created.') % - network.name_or_id) - LOG.debug(msg) + LOG.debug('Network "%s" was successfully created.', + network.name_or_id) return network except Exception as e: msg = (_('Failed to create network "%(network)s": %(reason)s') % @@ -541,8 +540,7 @@ class CreateNetwork(workflows.Workflow): subnet = api.neutron.subnet_create(request, **params) self.context['subnet_id'] = subnet.id - msg = _('Subnet "%s" was successfully created.') % data['cidr'] - LOG.debug(msg) + LOG.debug('Subnet "%s" was successfully created.', data['cidr']) return subnet except Exception as e: if network_name: diff --git a/openstack_dashboard/dashboards/project/stacks/forms.py b/openstack_dashboard/dashboards/project/stacks/forms.py index 42692a1cb9..e8b970299f 100644 --- a/openstack_dashboard/dashboards/project/stacks/forms.py +++ b/openstack_dashboard/dashboards/project/stacks/forms.py @@ -191,7 +191,7 @@ class TemplateForm(forms.SelfHandlingForm): # Uploaded file handler if has_upload and not url: log_template_name = files[upload_str].name - LOG.info('got upload %s' % log_template_name) + LOG.info('got upload %s', log_template_name) tpl = files[upload_str].read() if tpl.startswith('{'): diff --git a/openstack_dashboard/dashboards/project/stacks/tabs.py b/openstack_dashboard/dashboards/project/stacks/tabs.py index 6ab4b1ab0b..1e6c92be1f 100644 --- a/openstack_dashboard/dashboards/project/stacks/tabs.py +++ b/openstack_dashboard/dashboards/project/stacks/tabs.py @@ -100,7 +100,7 @@ class StackEventsTab(tabs.Tab): try: stack_identifier = '%s/%s' % (stack.stack_name, stack.id) events = api.heat.events_list(self.request, stack_identifier) - LOG.debug('got events %s' % events) + LOG.debug('got events %s', events) # The stack id is needed to generate the resource URL. for event in events: event.stack_id = stack.id @@ -131,7 +131,7 @@ class StackResourcesTab(tabs.Tab): try: stack_identifier = '%s/%s' % (stack.stack_name, stack.id) resources = api.heat.resources_list(self.request, stack_identifier) - LOG.debug('got resources %s' % resources) + LOG.debug('got resources %s', resources) # The stack id is needed to generate the resource URL. for r in resources: r.stack_id = stack.id diff --git a/openstack_dashboard/dashboards/project/vpn/forms.py b/openstack_dashboard/dashboards/project/vpn/forms.py index 2f4bf76a07..1ada5d8c9c 100644 --- a/openstack_dashboard/dashboards/project/vpn/forms.py +++ b/openstack_dashboard/dashboards/project/vpn/forms.py @@ -57,7 +57,7 @@ class UpdateVPNService(forms.SelfHandlingForm): return vpnservice except Exception as e: msg = _('Failed to update VPN Service %s') % context['name'] - LOG.info('%s: %s' % (msg, e)) + LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e}) redirect = reverse(self.failure_url) exceptions.handle(request, msg, redirect=redirect) @@ -136,7 +136,7 @@ class UpdateIKEPolicy(forms.SelfHandlingForm): return ikepolicy except Exception as e: msg = _('Failed to update IKE Policy %s') % context['name'] - LOG.info('%s: %s' % (msg, e)) + LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e}) redirect = reverse(self.failure_url) exceptions.handle(request, msg, redirect=redirect) @@ -214,7 +214,7 @@ class UpdateIPSecPolicy(forms.SelfHandlingForm): return ipsecpolicy except Exception as e: msg = _('Failed to update IPSec Policy %s') % context['name'] - LOG.info('%s: %s' % (msg, e)) + LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e}) redirect = reverse(self.failure_url) exceptions.handle(request, msg, redirect=redirect) @@ -324,6 +324,6 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm): except Exception as e: msg = (_('Failed to update IPSec Site Connection %s') % context['name']) - LOG.info('%s: %s' % (msg, e)) + LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e}) redirect = reverse(self.failure_url) exceptions.handle(request, msg, redirect=redirect) diff --git a/openstack_dashboard/django_pyscss_fix/__init__.py b/openstack_dashboard/django_pyscss_fix/__init__.py index 9dae4fd021..f53f10df3f 100644 --- a/openstack_dashboard/django_pyscss_fix/__init__.py +++ b/openstack_dashboard/django_pyscss_fix/__init__.py @@ -33,4 +33,5 @@ try: if not os.path.exists(scss_asset_root): os.makedirs(scss_asset_root) except Exception as e: - LOG.info("Error precreating path %s, %s" % (scss_asset_root, e)) + LOG.info("Error precreating path %(root)s, %(exc)s", + {'root': scss_asset_root, 'exc': e}) diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 71d3af3505..3fd2419ecd 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -360,7 +360,7 @@ if os.path.exists(LOCAL_SETTINGS_DIR_PATH): exec(f.read()) except Exception as e: logging.exception( - "Can not exec settings snippet %s" % filename) + "Can not exec settings snippet %s", filename) # The purpose of OPENSTACK_IMAGE_FORMATS is to provide a simple object # that does not contain the lazy-loaded translations, so the list can diff --git a/openstack_dashboard/theme_settings.py b/openstack_dashboard/theme_settings.py index f73c07bc94..ff7cdec9e8 100644 --- a/openstack_dashboard/theme_settings.py +++ b/openstack_dashboard/theme_settings.py @@ -77,7 +77,7 @@ def get_available_themes(available_themes, custom_path, default_path, default_theme = available_themes[custom_ndx][0] logging.warning("Your AVAILABLE_THEMES already contains your " "CUSTOM_THEME_PATH, therefore using configuration in " - "AVAILABLE_THEMES for %s." % custom_path) + "AVAILABLE_THEMES for %s.", custom_path) elif custom_path is not None: new_theme_list.append( diff --git a/openstack_dashboard/utils/settings.py b/openstack_dashboard/utils/settings.py index 26a054d4ce..2ac65a2061 100644 --- a/openstack_dashboard/utils/settings.py +++ b/openstack_dashboard/utils/settings.py @@ -29,7 +29,7 @@ def import_submodules(module): submodule = import_module(name) except ImportError as e: # FIXME: Make the errors non-fatal (do we want that?). - logging.warning("Error importing %s" % name) + logging.warning("Error importing %s", name) logging.exception(e) else: parent, child = name.rsplit('.', 1)