diff --git a/nova/virt/lxd/driver.py b/nova/virt/lxd/driver.py index cf613046..1a2a3fa2 100644 --- a/nova/virt/lxd/driver.py +++ b/nova/virt/lxd/driver.py @@ -65,8 +65,6 @@ from oslo_utils import excutils from nova.virt import firewall _ = i18n._ -_LW = i18n._LW -_LE = i18n._LE lxd_opts = [ cfg.StrOpt('root_dir', @@ -94,8 +92,8 @@ BASE_DIR = os.path.join( def _neutron_failed_callback(event_name, instance): - LOG.error(_LE('Neutron Reported failure on event ' - '%(event)s for instance %(uuid)s'), + LOG.error('Neutron Reported failure on event ' + '%(event)s for instance %(uuid)s', {'event': event_name, 'uuid': instance.name}, instance=instance) if CONF.vif_plugging_is_fatal: @@ -365,8 +363,8 @@ class LXDDriver(driver.ComputeDriver): error_callback=_neutron_failed_callback): self.plug_vifs(instance, network_info) except eventlet.timeout.Timeout: - LOG.warn(_LW('Timeout waiting for vif plugging callback for ' - 'instance %(uuid)s'), {'uuid': instance['name']}) + LOG.warn('Timeout waiting for vif plugging callback for ' + 'instance %(uuid)s', {'uuid': instance['name']}) if CONF.vif_plugging_is_fatal: self.destroy( context, instance, network_info, block_device_info) @@ -453,8 +451,8 @@ class LXDDriver(driver.ComputeDriver): container.delete(wait=True) except lxd_exceptions.LXDAPIException as e: if e.response.status_code == 404: - LOG.warning(_LW('Failed to delete instance. ' - 'Container does not exist for %(instance)s.'), + LOG.warning('Failed to delete instance. ' + 'Container does not exist for %(instance)s.', {'instance': instance.name}) else: raise @@ -489,8 +487,8 @@ class LXDDriver(driver.ComputeDriver): self.client.profiles.get(instance.name).delete() except lxd_exceptions.LXDAPIException as e: if e.response.status_code == 404: - LOG.warning(_LW('Failed to delete instance. ' - 'Profile does not exist for %(instance)s.'), + LOG.warning('Failed to delete instance. ' + 'Profile does not exist for %(instance)s.', {'instance': instance.name}) else: raise @@ -1027,8 +1025,8 @@ class LXDDriver(driver.ComputeDriver): cdb.make_drive(iso_path) except processutils.ProcessExecutionError as e: with excutils.save_and_reraise_exception(): - LOG.error(_LE('Creating config drive failed with ' - 'error: %s'), + LOG.error('Creating config drive failed with ' + 'error: %s', e, instance=instance) configdrive_dir = os.path.join( diff --git a/nova/virt/lxd/session.py b/nova/virt/lxd/session.py index 881b5cf2..da1ab0f5 100644 --- a/nova/virt/lxd/session.py +++ b/nova/virt/lxd/session.py @@ -27,8 +27,6 @@ from pylxd.deprecated import api from pylxd.deprecated import exceptions as lxd_exceptions _ = i18n._ -_LE = i18n._LE -_LI = i18n._LI CONF = nova.conf.CONF LOG = logging.getLogger(__name__) @@ -54,7 +52,7 @@ class LXDAPISession(object): except Exception as ex: # notify the compute host that the connection failed # via an rpc call - LOG.exception(_LE('Connection to LXD failed')) + LOG.exception('Connection to LXD failed') payload = dict(ip=CONF.host, method='_connect', reason=ex) @@ -76,9 +74,9 @@ class LXDAPISession(object): """ LOG.debug('container_init called for instance', instance=instance) try: - LOG.info(_LI('Creating container %(instance)s with' - ' %(image)s'), {'instance': instance.name, - 'image': instance.image_ref}) + LOG.info('Creating container %(instance)s with' + ' %(image)s', {'instance': instance.name, + 'image': instance.image_ref}) client = self.get_session(host=host) (state, data) = client.container_init(config) @@ -90,9 +88,9 @@ class LXDAPISession(object): msg = data.get('err') or data['metadata'] raise exception.NovaException(msg) - LOG.info(_LI('Successfully created container %(instance)s with' - ' %(image)s'), {'instance': instance.name, - 'image': instance.image_ref}) + LOG.info('Successfully created container %(instance)s with' + ' %(image)s', {'instance': instance.name, + 'image': instance.image_ref}) except lxd_exceptions.APIError as ex: msg = _('Failed to communicate with LXD API %(instance)s:' ' %(reason)s') % {'instance': instance.name, @@ -101,7 +99,7 @@ class LXDAPISession(object): except Exception as ex: with excutils.save_and_reraise_exception(): LOG.error( - _LE('Failed to create container %(instance)s: %(reason)s'), + 'Failed to create container %(instance)s: %(reason)s', {'instance': instance.name, 'reason': ex}, instance=instance) @@ -129,8 +127,8 @@ class LXDAPISession(object): raise exception.NovaException(msg) except Exception as e: with excutils.save_and_reraise_exception(): - LOG.error(_LE('Error from LXD during operation wait' - '%(instance)s: %(reason)s'), + LOG.error('Error from LXD during operation wait' + '%(instance)s: %(reason)s', {'instance': instance.image_ref, 'reason': e}, instance=instance) @@ -147,8 +145,8 @@ class LXDAPISession(object): raise exception.NovaException(msg) except Exception as e: with excutils.save_and_reraise_exception(): - LOG.error(_LE('Error from LXD during operation_info ' - '%(instance)s: %(reason)s'), + LOG.error('Error from LXD during operation_info ' + '%(instance)s: %(reason)s', {'instance': instance.image_ref, 'reason': e}, instance=instance) @@ -166,15 +164,15 @@ class LXDAPISession(object): """ LOG.debug('container_migrate called for instance', instance=instance) try: - LOG.info(_LI('Migrating instance %(instance)s with ' - '%(image)s'), {'instance': instance_name, - 'image': instance.image_ref}) + LOG.info('Migrating instance %(instance)s with ' + '%(image)s', {'instance': instance_name, + 'image': instance.image_ref}) client = self.get_session() (state, data) = client.container_migrate(instance_name) - LOG.info(_LI('Successfully initialized migration for instance ' - '%(instance)s with %(image)s'), + LOG.info('Successfully initialized migration for instance ' + '%(instance)s with %(image)s', {'instance': instance.name, 'image': instance.image_ref}) return (state, data) @@ -186,6 +184,6 @@ class LXDAPISession(object): except Exception as ex: with excutils.save_and_reraise_exception(): LOG.error( - _LE('Failed to migrate container %(instance)s: %(' - 'reason)s'), {'instance': instance.name, - 'reason': ex}, instance=instance) + 'Failed to migrate container %(instance)s: %(' + 'reason)s', {'instance': instance.name, + 'reason': ex}, instance=instance)