Handle log message interpolation by the logger

According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I51f50935f1eeffe4960562d6309dfdf05814e595
Closes-Bug: #1596829
This commit is contained in:
Gábor Antal 2017-03-28 16:47:28 +02:00 committed by Akihiro Motoki
parent a3e28c1b6c
commit 34a3aa0ba8
34 changed files with 127 additions and 110 deletions

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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":

View File

@ -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'] = ''

View File

@ -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})

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -339,9 +339,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

View File

@ -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)

View File

@ -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'

View File

@ -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')

View File

@ -156,7 +156,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:

View File

@ -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,

View File

@ -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'],

View File

@ -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(

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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'])

View File

@ -223,7 +223,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'] = \

View File

@ -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": '

View File

@ -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:

View File

@ -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('{'):

View File

@ -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

View File

@ -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)

View File

@ -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})

View File

@ -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

View File

@ -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(

View File

@ -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)