Merge "Remove translation of log messages"

This commit is contained in:
Jenkins 2017-08-10 11:39:03 +00:00 committed by Gerrit Code Review
commit 0db7e440b4
21 changed files with 121 additions and 151 deletions

View File

@ -20,7 +20,6 @@ import oslo_messaging as messaging
from nova import baserpc
from nova.conductor import rpcapi
import nova.conf
from nova.i18n import _LI, _LW
CONF = nova.conf.CONF
@ -67,16 +66,16 @@ class API(object):
self.base_rpcapi.ping(context, '1.21 GigaWatts',
timeout=timeout)
if has_timedout:
LOG.info(_LI('nova-conductor connection '
'established successfully'))
LOG.info('nova-conductor connection '
'established successfully')
break
except messaging.MessagingTimeout:
has_timedout = True
LOG.warning(_LW('Timed out waiting for nova-conductor. '
'Is it running? Or did this service start '
'before nova-conductor? '
'Reattempting establishment of '
'nova-conductor connection...'))
LOG.warning('Timed out waiting for nova-conductor. '
'Is it running? Or did this service start '
'before nova-conductor? '
'Reattempting establishment of '
'nova-conductor connection...')
class ComputeTaskAPI(object):

View File

@ -37,7 +37,7 @@ from nova.conductor.tasks import migrate
from nova import context as nova_context
from nova.db import base
from nova import exception
from nova.i18n import _, _LE, _LI, _LW
from nova.i18n import _
from nova import image
from nova import manager
from nova import network
@ -69,7 +69,7 @@ def targets_cell(fn):
im = objects.InstanceMapping.get_by_instance_uuid(
context, instance.uuid)
except exception.InstanceMappingNotFound:
LOG.error(_LE('InstanceMapping not found, unable to target cell'),
LOG.error('InstanceMapping not found, unable to target cell',
instance=instance)
im = None
else:
@ -230,7 +230,7 @@ class ComputeTaskManager(base.Base):
self.notifier = rpc.get_notifier('compute', CONF.host)
def reset(self):
LOG.info(_LI('Reloading compute RPC API'))
LOG.info('Reloading compute RPC API')
compute_rpcapi.LAST_VERSION = None
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
@ -363,8 +363,7 @@ class ComputeTaskManager(base.Base):
self.network_api.deallocate_for_instance(
context, instance, requested_networks=requested_networks)
except Exception:
msg = _LE('Failed to deallocate networks')
LOG.exception(msg, instance=instance)
LOG.exception('Failed to deallocate networks', instance=instance)
return
instance.system_metadata['network_allocated'] = 'False'
@ -439,8 +438,8 @@ class ComputeTaskManager(base.Base):
migration.status = 'error'
migration.save()
except Exception as ex:
LOG.error(_LE('Migration of instance %(instance_id)s to host'
' %(dest)s unexpectedly failed.'),
LOG.error('Migration of instance %(instance_id)s to host'
' %(dest)s unexpectedly failed.',
{'instance_id': instance.uuid, 'dest': destination},
exc_info=True)
# Reset the task state to None to indicate completion of
@ -721,18 +720,18 @@ class ComputeTaskManager(base.Base):
exception.UnsupportedPolicyException):
instance.task_state = None
instance.save()
LOG.warning(_LW("No valid host found for unshelve instance"),
LOG.warning("No valid host found for unshelve instance",
instance=instance)
return
except Exception:
with excutils.save_and_reraise_exception():
instance.task_state = None
instance.save()
LOG.error(_LE("Unshelve attempted but an error "
"has occurred"), instance=instance)
LOG.error("Unshelve attempted but an error "
"has occurred", instance=instance)
else:
LOG.error(_LE('Unshelve attempted but vm_state not SHELVED or '
'SHELVED_OFFLOADED'), instance=instance)
LOG.error('Unshelve attempted but vm_state not SHELVED or '
'SHELVED_OFFLOADED', instance=instance)
instance.vm_state = vm_states.ERROR
instance.save()
return
@ -782,7 +781,7 @@ class ComputeTaskManager(base.Base):
'rebuild_server',
{'vm_state': instance.vm_state,
'task_state': None}, ex, request_spec)
LOG.warning(_LW("No valid host found for rebuild"),
LOG.warning("No valid host found for rebuild",
instance=instance)
except exception.UnsupportedPolicyException as ex:
request_spec = request_spec.to_legacy_request_spec_dict()
@ -791,9 +790,8 @@ class ComputeTaskManager(base.Base):
'rebuild_server',
{'vm_state': instance.vm_state,
'task_state': None}, ex, request_spec)
LOG.warning(_LW("Server with unsupported policy "
"cannot be rebuilt"),
instance=instance)
LOG.warning("Server with unsupported policy "
"cannot be rebuilt", instance=instance)
try:
migration = objects.Migration.get_by_instance_and_status(
@ -883,9 +881,9 @@ class ComputeTaskManager(base.Base):
# Not yet setup for cellsv2. Instances will need to be written
# to the configured database. This will become a deployment
# error in Ocata.
LOG.error(_LE('No cell mapping found for cell0 while '
'trying to record scheduling failure. '
'Setup is incomplete.'))
LOG.error('No cell mapping found for cell0 while '
'trying to record scheduling failure. '
'Setup is incomplete.')
return
build_requests = build_requests or []
@ -938,7 +936,7 @@ class ComputeTaskManager(base.Base):
hosts = self._schedule_instances(context, request_specs[0],
instance_uuids)
except Exception as exc:
LOG.exception(_LE('Failed to schedule instances'))
LOG.exception('Failed to schedule instances')
self._bury_in_cell0(context, request_specs[0], exc,
build_requests=build_requests)
return
@ -956,8 +954,8 @@ class ComputeTaskManager(base.Base):
context, host['host'])
host_mapping_cache[host['host']] = host_mapping
except exception.HostMappingNotFound as exc:
LOG.error(_LE('No host-to-cell mapping found for selected '
'host %(host)s. Setup is incomplete.'),
LOG.error('No host-to-cell mapping found for selected '
'host %(host)s. Setup is incomplete.',
{'host': host['host']})
self._bury_in_cell0(context, request_spec, exc,
build_requests=[build_request],

View File

@ -22,7 +22,6 @@ from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova.console import xvp
from nova import exception
from nova.i18n import _LI
from nova import manager
from nova import objects
from nova import utils
@ -49,7 +48,7 @@ class ConsoleProxyManager(manager.Manager):
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
def reset(self):
LOG.info(_LI('Reloading compute RPC API'))
LOG.info('Reloading compute RPC API')
compute_rpcapi.LAST_VERSION = None
self.compute_rpcapi = compute_rpcapi.ComputeAPI()

View File

@ -21,7 +21,6 @@ import six.moves
import nova.conf
from nova import exception
from nova.i18n import _LW
from nova import utils
LOG = logging.getLogger(__name__)
@ -71,10 +70,10 @@ def _get_port_range():
start, stop = map(int, config_range.split(':'))
if start >= stop:
default_port_range = nova.conf.serial_console.DEFAULT_PORT_RANGE
LOG.warning(_LW("serial_console.port_range should be in the "
"format <start>:<stop> and start < stop, "
"Given value %(port_range)s is invalid. "
"Taking the default port range %(default)s."),
LOG.warning("serial_console.port_range should be in the "
"format <start>:<stop> and start < stop, "
"Given value %(port_range)s is invalid. "
"Taking the default port range %(default)s.",
{'port_range': config_range,
'default': default_port_range})
start, stop = map(int, default_port_range.split(':'))

View File

@ -31,7 +31,6 @@ from nova.consoleauth import rpcapi as consoleauth_rpcapi
from nova import context
from nova import exception
from nova.i18n import _
from nova.i18n import _LW
LOG = logging.getLogger(__name__)
@ -96,7 +95,7 @@ class NovaProxyRequestHandlerBase(object):
except Cookie.CookieError:
# NOTE(stgleb): Do not print out cookie content
# for security reasons.
LOG.warning(_LW('Found malformed cookie'))
LOG.warning('Found malformed cookie')
else:
if 'token' in cookie:
token = cookie['token'].value

View File

@ -26,7 +26,7 @@ from oslo_utils import excutils
import nova.conf
from nova import context
from nova import db
from nova.i18n import _, _LE
from nova.i18n import _
from nova import utils
@ -101,7 +101,7 @@ class XVPConsoleProxy(object):
cfile.write(config)
except IOError:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to write configuration file"))
LOG.exception("Failed to write configuration file")
def _xvp_stop(self):
LOG.debug('Stopping xvp')
@ -124,7 +124,7 @@ class XVPConsoleProxy(object):
'-c', CONF.xvp.console_xvp_conf,
'-l', CONF.xvp.console_xvp_log)
except processutils.ProcessExecutionError as err:
LOG.error(_LE('Error starting xvp: %s'), err)
LOG.error('Error starting xvp: %s', err)
def _xvp_restart(self):
LOG.debug('Restarting xvp')

View File

@ -27,7 +27,6 @@ from nova.cells import rpcapi as cells_rpcapi
from nova.compute import rpcapi as compute_rpcapi
import nova.conf
from nova import context as nova_context
from nova.i18n import _LI
from nova import manager
from nova import objects
@ -63,7 +62,7 @@ class ConsoleAuthManager(manager.Manager):
return self._mc_instance
def reset(self):
LOG.info(_LI('Reloading compute RPC API'))
LOG.info('Reloading compute RPC API')
compute_rpcapi.LAST_VERSION = None
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
@ -102,8 +101,8 @@ class ConsoleAuthManager(manager.Manager):
self.mc_instance.set(instance_uuid.encode('UTF-8'),
jsonutils.dumps(tokens))
LOG.info(_LI("Received Token: %(token)s, %(token_dict)s"),
{'token': token, 'token_dict': token_dict})
LOG.info("Received Token: %(token)s, %(token_dict)s",
{'token': token, 'token_dict': token_dict})
def _validate_token(self, context, token):
instance_uuid = token['instance_uuid']
@ -131,8 +130,8 @@ class ConsoleAuthManager(manager.Manager):
def check_token(self, context, token):
token_str = self.mc.get(token.encode('UTF-8'))
token_valid = (token_str is not None)
LOG.info(_LI("Checking Token: %(token)s, %(token_valid)s"),
{'token': token, 'token_valid': token_valid})
LOG.info("Checking Token: %(token)s, %(token_valid)s",
{'token': token, 'token_valid': token_valid})
if token_valid:
token = jsonutils.loads(token_str)
if self._validate_token(context, token):

View File

@ -32,7 +32,6 @@ from oslo_log import log as logging
from nova.cells import rpcapi as cells_rpcapi
import nova.conf
from nova.i18n import _LE
CONF = nova.conf.CONF
@ -1787,7 +1786,7 @@ def bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out,
uuid, mac, start_period, bw_in, bw_out,
last_ctr_in, last_ctr_out, last_refreshed)
except Exception:
LOG.exception(_LE("Failed to notify cells of bw_usage update"))
LOG.exception("Failed to notify cells of bw_usage update")
return rv

View File

@ -65,7 +65,7 @@ import nova.conf
import nova.context
from nova.db.sqlalchemy import models
from nova import exception
from nova.i18n import _, _LI, _LE, _LW
from nova.i18n import _
from nova import safe_utils
profiler_sqlalchemy = importutils.try_import('osprofiler.sqlalchemy')
@ -905,7 +905,7 @@ def floating_ip_get(context, id):
if not result:
raise exception.FloatingIpNotFound(id=id)
except db_exc.DBError:
LOG.warning(_LW("Invalid floating IP ID %s in request"), id)
LOG.warning("Invalid floating IP ID %s in request", id)
raise exception.InvalidID(id=id)
return result
@ -1589,7 +1589,7 @@ def virtual_interface_create(context, values):
vif_ref.update(values)
vif_ref.save(context.session)
except db_exc.DBError:
LOG.exception(_LE("VIF creation failed with a database error."))
LOG.exception("VIF creation failed with a database error.")
raise exception.VirtualInterfaceCreateException()
return vif_ref
@ -1936,7 +1936,7 @@ def instance_get(context, instance_id, columns_to_join=None):
except db_exc.DBError:
# NOTE(sdague): catch all in case the db engine chokes on the
# id because it's too long of an int to store.
LOG.warning(_LW("Invalid instance id %s in request"), instance_id)
LOG.warning("Invalid instance id %s in request", instance_id)
raise exception.InvalidID(id=instance_id)
@ -3689,17 +3689,17 @@ def _refresh_quota_usages(quota_usage, until_refresh, in_use):
:param in_use: Actual quota usage for the resource.
"""
if quota_usage.in_use != in_use:
LOG.info(_LI('quota_usages out of sync, updating. '
'project_id: %(project_id)s, '
'user_id: %(user_id)s, '
'resource: %(res)s, '
'tracked usage: %(tracked_use)s, '
'actual usage: %(in_use)s'),
{'project_id': quota_usage.project_id,
'user_id': quota_usage.user_id,
'res': quota_usage.resource,
'tracked_use': quota_usage.in_use,
'in_use': in_use})
LOG.info('quota_usages out of sync, updating. '
'project_id: %(project_id)s, '
'user_id: %(user_id)s, '
'resource: %(res)s, '
'tracked usage: %(tracked_use)s, '
'actual usage: %(in_use)s',
{'project_id': quota_usage.project_id,
'user_id': quota_usage.user_id,
'res': quota_usage.resource,
'tracked_use': quota_usage.in_use,
'in_use': in_use})
else:
LOG.debug('QuotaUsage has not changed, refresh is unnecessary for: %s',
dict(quota_usage))
@ -3896,8 +3896,8 @@ def quota_reserve(context, resources, project_quotas, user_quotas, deltas,
context.session.add(usage_ref)
if unders:
LOG.warning(_LW("Change will make usage less than 0 for the following "
"resources: %s"), unders)
LOG.warning("Change will make usage less than 0 for the following "
"resources: %s", unders)
if overs:
if project_quotas == user_quotas:
@ -5598,9 +5598,9 @@ def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
rd_bytes < current_usage['curr_read_bytes'] or
wr_req < current_usage['curr_writes'] or
wr_bytes < current_usage['curr_write_bytes']):
LOG.info(_LI("Volume(%s) has lower stats then what is in "
"the database. Instance must have been rebooted "
"or crashed. Updating totals."), id)
LOG.info("Volume(%s) has lower stats then what is in "
"the database. Instance must have been rebooted "
"or crashed. Updating totals.", id)
if not update_totals:
values['tot_reads'] = (models.VolumeUsage.tot_reads +
current_usage['curr_reads'])
@ -5959,8 +5959,8 @@ def aggregate_metadata_add(context, aggregate_id, metadata, set_delete=False,
if attempt < max_retries - 1:
ctxt.reraise = False
else:
LOG.warning(_LW("Add metadata failed for aggregate %(id)s "
"after %(retries)s retries"),
LOG.warning("Add metadata failed for aggregate %(id)s "
"after %(retries)s retries",
{"id": aggregate_id, "retries": max_retries})
@ -6380,7 +6380,7 @@ def _archive_if_instance_deleted(table, shadow_table, instances, conn,
result_delete = conn.execute(delete_statement)
return result_delete.rowcount
except db_exc.DBReferenceError as ex:
LOG.warning(_LW('Failed to archive %(table)s: %(error)s'),
LOG.warning('Failed to archive %(table)s: %(error)s',
{'table': table.__tablename__,
'error': six.text_type(ex)})
return 0
@ -6472,8 +6472,8 @@ def _archive_deleted_rows_for_table(tablename, max_rows):
# A foreign key constraint keeps us from deleting some of
# these rows until we clean up a dependent table. Just
# skip this table for now; we'll come back to it later.
LOG.warning(_LW("IntegrityError detected when archiving table "
"%(tablename)s: %(error)s"),
LOG.warning("IntegrityError detected when archiving table "
"%(tablename)s: %(error)s",
{'tablename': tablename, 'error': six.text_type(ex)})
if ((max_rows is None or rows_archived < max_rows)

View File

@ -14,7 +14,7 @@ from oslo_log import log as logging
from sqlalchemy import MetaData, Table, func, select
from nova import exception
from nova.i18n import _, _LW
from nova.i18n import _
from nova import objects
LOG = logging.getLogger(__name__)
@ -54,7 +54,6 @@ def upgrade(migrate_engine):
host_mappings = Table('host_mappings', meta, autoload=True)
count = select([func.count()]).select_from(host_mappings).scalar()
if count == 0:
msg = _LW('No host mappings were found, but are required for Ocata. '
'Please run nova-manage cell_v2 simple_cell_setup before '
'continuing.')
LOG.warning(msg)
LOG.warning('No host mappings were found, but are required for Ocata. '
'Please run nova-manage cell_v2 simple_cell_setup before '
'continuing.')

View File

@ -21,8 +21,6 @@ from sqlalchemy import ForeignKey, Index, Integer, MetaData, String, Table
from sqlalchemy import Text
from sqlalchemy.types import NullType
from nova.i18n import _LE
LOG = logging.getLogger(__name__)
@ -81,7 +79,7 @@ def _create_shadow_tables(migrate_engine):
shadow_table.create()
except Exception:
LOG.info(repr(shadow_table))
LOG.exception(_LE('Exception while creating table.'))
LOG.exception('Exception while creating table.')
raise
@ -1075,7 +1073,7 @@ def upgrade(migrate_engine):
table.create()
except Exception:
LOG.info(repr(table))
LOG.exception(_LE('Exception while creating table.'))
LOG.exception('Exception while creating table.')
raise
# task log unique constraint

View File

@ -15,8 +15,6 @@
from oslo_log import log as logging
from sqlalchemy import Index, MetaData, Table
from nova.i18n import _LI
LOG = logging.getLogger(__name__)
@ -33,8 +31,8 @@ def upgrade(migrate_engine):
reservations = Table('reservations', meta, autoload=True)
if _get_deleted_expire_index(reservations):
LOG.info(_LI('Skipped adding reservations_deleted_expire_idx '
'because an equivalent index already exists.'))
LOG.info('Skipped adding reservations_deleted_expire_idx '
'because an equivalent index already exists.')
return
# Based on expire_reservations query

View File

@ -15,8 +15,6 @@
from oslo_log import log as logging
from sqlalchemy import Index, MetaData, Table
from nova.i18n import _LI
LOG = logging.getLogger(__name__)
@ -33,8 +31,8 @@ def upgrade(migrate_engine):
reservations = Table('reservations', meta, autoload=True)
if _get_deleted_expire_index(reservations):
LOG.info(_LI('Skipped adding reservations_deleted_expire_idx '
'because an equivalent index already exists.'))
LOG.info('Skipped adding reservations_deleted_expire_idx '
'because an equivalent index already exists.')
return
# Based on expire_reservations query

View File

@ -16,8 +16,6 @@
from oslo_log import log as logging
from sqlalchemy import MetaData, Table, Index
from nova.i18n import _LI
LOG = logging.getLogger(__name__)
@ -33,8 +31,8 @@ def upgrade(migrate_engine):
for index in instances.indexes:
if [c.name for c in index.columns] == ['project_id', 'deleted']:
LOG.info(_LI('Skipped adding instances_project_id_deleted_idx '
'because an equivalent index already exists.'))
LOG.info('Skipped adding instances_project_id_deleted_idx '
'because an equivalent index already exists.')
break
else:
index = Index('instances_project_id_deleted_idx',

View File

@ -13,8 +13,6 @@
from oslo_log import log as logging
from sqlalchemy import Index, MetaData, Table
from nova.i18n import _LI
LOG = logging.getLogger(__name__)
@ -37,8 +35,8 @@ def _get_table_index(migrate_engine):
def upgrade(migrate_engine):
meta, table, index = _get_table_index(migrate_engine)
if index:
LOG.info(_LI('Skipped adding %s because an equivalent index'
' already exists.'), INDEX_NAME)
LOG.info('Skipped adding %s because an equivalent index'
' already exists.', INDEX_NAME)
return
columns = [getattr(table.c, col_name) for col_name in INDEX_COLUMNS]
index = Index(INDEX_NAME, *columns)

View File

@ -14,8 +14,6 @@
from oslo_log import log as logging
from sqlalchemy import MetaData, Table, Index
from nova.i18n import _LI
LOG = logging.getLogger(__name__)
INDEX_COLUMNS = ['uuid']
@ -37,8 +35,8 @@ def _get_table_index(migrate_engine):
def upgrade(migrate_engine):
meta, table, index = _get_table_index(migrate_engine)
if index:
LOG.info(_LI('Skipped adding %s because an equivalent index'
' already exists.'), INDEX_NAME)
LOG.info('Skipped adding %s because an equivalent index'
' already exists.', INDEX_NAME)
return
columns = [getattr(table.c, col_name) for col_name in INDEX_COLUMNS]
index = Index(INDEX_NAME, *columns)

View File

@ -16,8 +16,6 @@
from oslo_log import log as logging
from sqlalchemy import MetaData, Table, Index
from nova.i18n import _LI
LOG = logging.getLogger(__name__)
INDEX_COLUMNS = ['deleted', 'created_at']
@ -39,8 +37,8 @@ def _get_table_index(migrate_engine):
def upgrade(migrate_engine):
meta, table, index = _get_table_index(migrate_engine)
if index:
LOG.info(_LI('Skipped adding %s because an equivalent index'
' already exists.'), INDEX_NAME)
LOG.info('Skipped adding %s because an equivalent index'
' already exists.', INDEX_NAME)
return
columns = [getattr(table.c, col_name) for col_name in INDEX_COLUMNS]
index = Index(INDEX_NAME, *columns)

View File

@ -14,8 +14,6 @@ from oslo_log import log as logging
from sqlalchemy import MetaData, Table, Index
from sqlalchemy.engine import reflection
from nova.i18n import _LI
LOG = logging.getLogger(__name__)
INDEX_COLUMNS_1 = ['project_id']
@ -42,16 +40,16 @@ def upgrade(migrate_engine):
meta.bind = migrate_engine
table = Table(TABLE_NAME, meta, autoload=True)
if _get_table_index(migrate_engine, TABLE_NAME, INDEX_COLUMNS_1):
LOG.info(_LI('Skipped adding %s because an equivalent index'
' already exists.'), INDEX_NAME_1)
LOG.info('Skipped adding %s because an equivalent index'
' already exists.', INDEX_NAME_1)
else:
columns = [getattr(table.c, col_name) for col_name in INDEX_COLUMNS_1]
index = Index(INDEX_NAME_1, *columns)
index.create(migrate_engine)
if _get_table_index(migrate_engine, TABLE_NAME, INDEX_COLUMNS_2):
LOG.info(_LI('Skipped adding %s because an equivalent index'
' already exists.'), INDEX_NAME_2)
LOG.info('Skipped adding %s because an equivalent index'
' already exists.', INDEX_NAME_2)
else:
columns = [getattr(table.c, col_name) for col_name in INDEX_COLUMNS_2]
index = Index(INDEX_NAME_2, *columns)

View File

@ -23,7 +23,7 @@ from sqlalchemy.types import NullType
from nova.db.sqlalchemy import api as db
from nova import exception
from nova.i18n import _, _LE
from nova.i18n import _
LOG = logging.getLogger(__name__)
@ -109,8 +109,8 @@ def create_shadow_table(migrate_engine, table_name=None, table=None,
# which raises unwrapped OperationalError, so we should catch it until
# oslo.db would wraps all such exceptions
LOG.info(repr(shadow_table))
LOG.exception(_LE('Exception while creating table.'))
LOG.exception('Exception while creating table.')
raise exception.ShadowTableExists(name=shadow_table_name)
except Exception:
LOG.info(repr(shadow_table))
LOG.exception(_LE('Exception while creating table.'))
LOG.exception('Exception while creating table.')

View File

@ -17,8 +17,6 @@ from oslo_log import log as logging
import stevedore.driver
import stevedore.extension
from nova.i18n import _LE
LOG = logging.getLogger(__name__)
@ -36,8 +34,8 @@ def load_transfer_modules():
schemes_list = mgr.driver.get_schemes()
for scheme in schemes_list:
if scheme in module_dictionary:
LOG.error(_LE('%(scheme)s is registered as a module twice. '
'%(module_name)s is not being used.'),
LOG.error('%(scheme)s is registered as a module twice. '
'%(module_name)s is not being used.',
{'scheme': scheme,
'module_name': module_name})
else:

View File

@ -42,7 +42,6 @@ import six.moves.urllib.parse as urlparse
import nova.conf
from nova import exception
from nova.i18n import _LE, _LI, _LW
import nova.image.download as image_xfers
from nova import objects
from nova.objects import fields
@ -115,11 +114,10 @@ def get_api_servers():
if '//' not in api_server:
api_server = 'http://' + api_server
# NOTE(sdague): remove in O.
LOG.warning(
_LW("No protocol specified in for api_server '%s', "
"please update [glance] api_servers with fully "
"qualified url including scheme (http / https)"),
api_server)
LOG.warning("No protocol specified in for api_server '%s', "
"please update [glance] api_servers with fully "
"qualified url including scheme (http / https)",
api_server)
api_servers.append(api_server)
random.shuffle(api_servers)
return itertools.cycle(api_servers)
@ -177,9 +175,9 @@ class GlanceClientWrapper(object):
else:
extra = 'done trying'
LOG.exception(_LE("Error contacting glance server "
"'%(server)s' for '%(method)s', "
"%(extra)s."),
LOG.exception("Error contacting glance server "
"'%(server)s' for '%(method)s', "
"%(extra)s.",
{'server': self.api_server,
'method': method, 'extra': extra})
if attempt == num_attempts:
@ -208,8 +206,8 @@ class GlanceImageServiceV2(object):
try:
self._download_handlers[scheme] = mod.get_download_handler()
except Exception as ex:
LOG.error(_LE('When loading the module %(module_str)s the '
'following error occurred: %(ex)s'),
LOG.error('When loading the module %(module_str)s the '
'following error occurred: %(ex)s',
{'module_str': str(mod), 'ex': ex})
def show(self, context, image_id, include_locations=False,
@ -255,8 +253,8 @@ class GlanceImageServiceV2(object):
except KeyError:
return None
except Exception:
LOG.error(_LE("Failed to instantiate the download handler "
"for %(scheme)s"), {'scheme': scheme})
LOG.error("Failed to instantiate the download handler "
"for %(scheme)s", {'scheme': scheme})
return
def detail(self, context, **kwargs):
@ -286,11 +284,10 @@ class GlanceImageServiceV2(object):
if xfer_mod:
try:
xfer_mod.download(context, o, dst_path, loc_meta)
LOG.info(_LI("Successfully transferred "
"using %s"), o.scheme)
LOG.info("Successfully transferred using %s", o.scheme)
return
except Exception:
LOG.exception(_LE("Download image error"))
LOG.exception("Download image error")
try:
image_chunks = self._client.call(context, 2, 'data', image_id)
@ -323,8 +320,8 @@ class GlanceImageServiceV2(object):
)
except cursive_exception.SignatureVerificationError:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Image signature verification failed '
'for image: %s'), image_id)
LOG.error('Image signature verification failed '
'for image: %s', image_id)
close_file = False
if data is None and dst_path:
@ -340,13 +337,13 @@ class GlanceImageServiceV2(object):
verifier.update(chunk)
verifier.verify()
LOG.info(_LI('Image signature verification succeeded '
'for image: %s'), image_id)
LOG.info('Image signature verification succeeded '
'for image: %s', image_id)
except cryptography.exceptions.InvalidSignature:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Image signature verification failed '
'for image: %s'), image_id)
LOG.error('Image signature verification failed '
'for image: %s', image_id)
return image_chunks
else:
try:
@ -356,16 +353,16 @@ class GlanceImageServiceV2(object):
data.write(chunk)
if verifier:
verifier.verify()
LOG.info(_LI('Image signature verification succeeded '
'for image %s'), image_id)
LOG.info('Image signature verification succeeded '
'for image %s', image_id)
except cryptography.exceptions.InvalidSignature:
data.truncate(0)
with excutils.save_and_reraise_exception():
LOG.error(_LE('Image signature verification failed '
'for image: %s'), image_id)
LOG.error('Image signature verification failed '
'for image: %s', image_id)
except Exception as ex:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Error writing to %(path)s: %(exception)s"),
LOG.error("Error writing to %(path)s: %(exception)s",
{'path': dst_path, 'exception': ex})
finally:
if close_file:
@ -445,9 +442,9 @@ class GlanceImageServiceV2(object):
supported_disk_formats[0])
return supported_disk_formats[0]
LOG.warning(_LW('Unable to determine disk_format schema from the '
'Image Service v2 API. Defaulting to '
'%(preferred_disk_format)s.'),
LOG.warning('Unable to determine disk_format schema from the '
'Image Service v2 API. Defaulting to '
'%(preferred_disk_format)s.',
{'preferred_disk_format': preferred_disk_formats[0]})
return preferred_disk_formats[0]