Remove log translations

Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: I97f9b445cb572adf936d0171bcda1e0f8724b367
This commit is contained in:
libing 2017-06-12 11:08:02 +08:00
parent 9b7eb5310b
commit 9887de79eb
5 changed files with 72 additions and 72 deletions

View File

@ -27,7 +27,7 @@ from nova.compute import task_states
from nova.compute import utils as compute_utils
from nova.compute import vm_states
from nova import exception as nova_exception
from nova.i18n import _, _LI, _LW
from nova.i18n import _
from nova.image import api as image_api
from nova.image import glance
from nova.objects import fields
@ -87,12 +87,12 @@ class ZVMDriver(driver.ComputeDriver):
self._xcat_version = self._get_xcat_version()
version_ok = self.has_min_version(const.XCAT_MINIMUM_VERSION)
while (not version_ok):
LOG.warning(_LW("WARNING: the xcat version communicating with is "
"%(xcat_version)s, but the minimum requested "
"version by openstack zvm driver is %(minimum)s "
"will sleep some time and check again"),
{'xcat_version': self._xcat_version,
'minimum': const.XCAT_MINIMUM_VERSION})
LOG.warning(_("WARNING: the xcat version communicating with is "
"%(xcat_version)s, but the minimum requested "
"version by openstack zvm driver is %(minimum)s "
"will sleep some time and check again"),
{'xcat_version': self._xcat_version,
'minimum': const.XCAT_MINIMUM_VERSION})
self._xcat_version = self._get_xcat_version()
version_ok = self.has_min_version(const.XCAT_MINIMUM_VERSION)
@ -108,9 +108,9 @@ class ZVMDriver(driver.ComputeDriver):
except Exception as e:
# Ignore any exceptions and log as warning
_slp = len(_inc_slp) != 0 and _inc_slp.pop(0) or _slp
msg = _LW("Failed to get host stats while initializing zVM "
"driver due to reason %(reason)s, will re-try in "
"%(slp)d seconds")
msg = _("Failed to get host stats while initializing zVM "
"driver due to reason %(reason)s, will re-try in "
"%(slp)d seconds")
LOG.warning(msg, {'reason': six.text_type(e),
'slp': _slp})
time.sleep(_slp)
@ -139,8 +139,8 @@ class ZVMDriver(driver.ComputeDriver):
self._volumeop.init_host(self._host_stats)
except Exception as e:
emsg = zvmutils.format_exception_msg(e)
LOG.warning(_LW("Exception raised while initializing z/VM driver: "
"%s"), emsg)
LOG.warning(_("Exception raised while initializing z/VM driver: "
"%s"), emsg)
def get_info(self, instance):
"""Get the current status of an instance, by name (not ID!)
@ -162,7 +162,7 @@ class ZVMDriver(driver.ComputeDriver):
emsg = err.format_message()
if (emsg.__contains__("Invalid nodes and/or groups") and
emsg.__contains__("Forbidden")):
LOG.warning(_LW("z/VM instance %s does not exist"), inst_name,
LOG.warning(_("z/VM instance %s does not exist"), inst_name,
instance=instance)
raise nova_exception.InstanceNotFound(instance_id=inst_name)
else:
@ -310,7 +310,7 @@ class ZVMDriver(driver.ComputeDriver):
instance, injected_files, admin_password,
net_conf_cmds, linuxdist, image_type)
LOG.info(_LI("The instance %(name)s is spawning at %(node)s"),
LOG.info(_("The instance %(name)s is spawning at %(node)s"),
{'name': zvm_inst._name, 'node': compute_node},
instance=instance)
@ -422,7 +422,7 @@ class ZVMDriver(driver.ComputeDriver):
# Power on the instance, then put MN's public key into instance
zvm_inst.power_on()
spawn_time = time.time() - spawn_start
LOG.info(_LI("Instance spawned succeeded in %s seconds"),
LOG.info(_("Instance spawned succeeded in %s seconds"),
spawn_time, instance=instance)
except (exception.ZVMXCATCreateNodeFailed,
exception.ZVMImageError):
@ -605,7 +605,7 @@ class ZVMDriver(driver.ComputeDriver):
zvm_inst = ZVMInstance(self, instance)
if self._instance_exists(inst_name):
LOG.info(_LI("Destroying instance %s"), inst_name,
LOG.info(_("Destroying instance %s"), inst_name,
instance=instance)
# Collect diagnostics when the instance is unreachable, since this
@ -637,7 +637,7 @@ class ZVMDriver(driver.ComputeDriver):
zvm_inst.clean_volume_boot(context, instance, bdm,
root_mount_device)
except exception.ZVMBaseException as err:
LOG.warning(_LW("Failed to detach volume: %s"),
LOG.warning(_("Failed to detach volume: %s"),
err.format_message(), instance=instance)
if network_info:
@ -645,7 +645,7 @@ class ZVMDriver(driver.ComputeDriver):
for vif in network_info:
self._networkop.clean_mac_switch_host(inst_name)
except exception.ZVMNetworkError:
LOG.warning(_LW("Clean MAC and VSWITCH failed while "
LOG.warning(_("Clean MAC and VSWITCH failed while "
"destroying z/VM instance %s"), inst_name,
instance=instance)
@ -653,15 +653,15 @@ class ZVMDriver(driver.ComputeDriver):
nodename = self._get_hcp_info()['nodename']
zvm_inst.delete_userid(nodename, context)
except exception.ZVMBaseException as err:
LOG.warning(_LW("Failed to delete user node: %s"),
LOG.warning(_("Failed to delete user node: %s"),
err.format_message(), instance=instance)
else:
LOG.warning(_LW('Instance %s does not exist'), inst_name,
LOG.warning(_('Instance %s does not exist'), inst_name,
instance=instance)
def manage_image_cache(self, context, filtered_instances):
"""Clean the image cache in xCAT MN."""
LOG.info(_LI("Check and clean image cache in xCAT"))
LOG.info(_("Check and clean image cache in xCAT"))
clean_period = CONF.xcat_image_clean_period
self._zvm_images.clean_image_cache_xcat(clean_period)
@ -765,7 +765,7 @@ class ZVMDriver(driver.ComputeDriver):
try:
self.power_on({}, instance, [])
except nova_exception.InstancePowerOnFailure as err:
LOG.warning(_LW("Power On instance %(inst)s fail after "
LOG.warning(_("Power On instance %(inst)s fail after "
"capture, please check manually. The error is: %(err)s"),
{'inst': instance['name'], 'err': err.format_message()},
instance=instance)
@ -775,7 +775,7 @@ class ZVMDriver(driver.ComputeDriver):
except (exception.ZVMXCATRequestFailed,
exception.ZVMInvalidXCATResponseDataError,
exception.ZVMXCATInternalError) as err:
LOG.warning(_LW("Pause instance %(inst)s fail after capture, "
LOG.warning(_("Pause instance %(inst)s fail after capture, "
"please check manually. The error is: %(err)s"),
{'inst': instance['name'], 'err': err.format_message()},
instance=instance)
@ -959,7 +959,7 @@ class ZVMDriver(driver.ComputeDriver):
cleanup_temp_image()
LOG.info(_LI("Snapshot complete successfully"), instance=instance)
LOG.info(_("Snapshot complete successfully"), instance=instance)
def pause(self, instance):
"""Pause the specified instance."""
@ -1060,7 +1060,7 @@ class ZVMDriver(driver.ComputeDriver):
:param dest_check_data: result of check_can_live_migrate_destination
"""
LOG.info(_LI("Checking source host for live-migration for %s"),
LOG.info(_("Checking source host for live-migration for %s"),
instance_ref['name'], instance=instance_ref)
migrate_data = dest_check_data.get('migrate_data', {})
@ -1170,7 +1170,7 @@ class ZVMDriver(driver.ComputeDriver):
"""
inst_name = instance_ref['name']
dest_host = migrate_data['dest_host']
LOG.info(_LI("Live-migrating %(inst)s to %(dest)s"),
LOG.info(_("Live-migrating %(inst)s to %(dest)s"),
{'inst': inst_name, 'dest': dest_host}, instance=instance_ref)
same_mn = migrate_data['pre_live_migration_result']['same_xcat_mn']
@ -1533,11 +1533,11 @@ class ZVMDriver(driver.ComputeDriver):
instance, mountpoint, is_active,
rollback=False)
except exception.ZVMVolumeError as err:
LOG.warning(_LW("Failed to detach volume from %(inst)s: "
"%(err)s"),
{'inst': instance['name'],
'err': err.format_message()},
instance=instance)
LOG.warning(_("Failed to detach volume from %(inst)s: "
"%(err)s"),
{'inst': instance['name'],
'err': err.format_message()},
instance=instance)
def _capture_disk_for_instance(self, context, instance):
"""Capture disk."""
@ -1926,18 +1926,18 @@ class ZVMDriver(driver.ComputeDriver):
except exception.ZVMBaseException as e:
# Ignore any zvm driver exceptions
LOG.info(_LI('encounter error %s during get vswitch info'),
LOG.info(_('encounter error %s during get vswitch info'),
e.format_message(), instance=instance)
return
# Enter here means all NIC granted
LOG.info(_LI("All NICs are added in user direct for "
"instance %s."), inst_name, instance=instance)
LOG.info(_("All NICs are added in user direct for "
"instance %s."), inst_name, instance=instance)
raise loopingcall.LoopingCallDone()
expiration = timeutils.utcnow() + datetime.timedelta(
seconds=CONF.zvm_reachable_timeout)
LOG.info(_LI("Wait neturon-zvm-agent to add NICs to %s user direct."),
LOG.info(_("Wait neturon-zvm-agent to add NICs to %s user direct."),
inst_name, instance=instance)
timer = loopingcall.FixedIntervalLoopingCall(
_wait_for_nic_add_in_direct, inst_name, expiration)
@ -1962,7 +1962,7 @@ class ZVMDriver(driver.ComputeDriver):
console_log = zvm_inst.get_console_log(logsize)
except exception.ZVMXCATInternalError:
# Ignore no console log avaiable error
LOG.info(_LI("No new console log avaiable."))
LOG.info(_("No new console log avaiable."))
log_path = self._pathutils.get_console_log_path(CONF.zvm_host,
zvm_inst._name)
# TODO(jichenjc): need consider shrink log file size
@ -1971,7 +1971,7 @@ class ZVMDriver(driver.ComputeDriver):
log_fp = file(log_path, 'rb')
log_data, remaining = utils.last_bytes(log_fp, logsize)
if remaining > 0:
LOG.info(_LI('Truncated console log returned, %d bytes ignored'),
LOG.info(_('Truncated console log returned, %d bytes ignored'),
remaining, instance=instance)
return log_data

View File

@ -21,7 +21,7 @@ import tarfile
import xml.dom.minidom as Dom
from nova import exception as nova_exception
from nova.i18n import _, _LW
from nova.i18n import _
from nova.image import glance
from nova import utils
from nova.virt import images
@ -151,7 +151,7 @@ class ZVMImages(object):
except (exception.ZVMXCATInternalError,
exception.ZVMInvalidXCATResponseDataError,
exception.ZVMXCATRequestFailed):
LOG.warning(_LW("Failed to delete image file %s from xCAT"),
LOG.warning(_("Failed to delete image file %s from xCAT"),
image_name_xcat)
def _delete_image_object_from_xcat(self, image_name_xcat):
@ -168,7 +168,7 @@ class ZVMImages(object):
except (exception.ZVMXCATInternalError,
exception.ZVMInvalidXCATResponseDataError,
exception.ZVMXCATRequestFailed):
LOG.warning(_LW("Failed to delete image definition %s from xCAT"),
LOG.warning(_("Failed to delete image definition %s from xCAT"),
image_name_xcat)
def get_image_file_path_from_image_name(self, image_name_xcat):
@ -198,7 +198,7 @@ class ZVMImages(object):
if os.path.exists(manifest_xml):
xml_file = Dom.parse(manifest_xml) # nosec
else:
LOG.warning(_LW('manifest.xml does not exist'))
LOG.warning(_('manifest.xml does not exist'))
manifest['imagename'] = ''
manifest['imagetype'] = ''
manifest['osarch'] = ''
@ -518,7 +518,7 @@ class ZVMImages(object):
except (exception.ZVMXCATRequestFailed,
exception.ZVMInvalidXCATResponseDataError,
exception.ZVMXCATInternalError) as err:
LOG.warning(_LW("Illegal date for last_use_date %s"),
LOG.warning(_("Illegal date for last_use_date %s"),
err.format_message())
return last_use_date_string
@ -533,7 +533,7 @@ class ZVMImages(object):
re.match(timere, last_use_date_string)):
LOG.debug("The format for last_use_date is valid ")
else:
LOG.warning(_LW("The format for image %s record in xcat table "
LOG.warning(_("The format for image %s record in xcat table "
"osimage's last_used_date is not valid. The correct "
"format is auto:last_use_date:yyyy-mm-dd"), image_name)
return
@ -542,7 +542,7 @@ class ZVMImages(object):
last_use_date_datetime = datetime.datetime.strptime(
last_use_date_string, '%Y-%m-%d')
except Exception as err:
LOG.warning(_LW("Illegal date for last_use_date %(msg)s"), err)
LOG.warning(_("Illegal date for last_use_date %(msg)s"), err)
return
return last_use_date_datetime.date()
@ -702,7 +702,7 @@ class ZVMImages(object):
to_be_deleted_image_profile = []
if len(image_list) <= 0:
msg = _LW("No image to be deleted, please create space manually "
msg = _("No image to be deleted, please create space manually "
"on xcat(%s).") % CONF.zvm_xcat_server
LOG.warning(msg)
else:
@ -721,7 +721,7 @@ class ZVMImages(object):
return to_be_deleted_image_profile
if size_sum < current_needed:
msg = _LW("xCAT MN space not enough for current image operation: "
msg = _("xCAT MN space not enough for current image operation: "
"%(n)d G needed,%(a)d G available") % {'n': current_needed,
'a': size_sum}
LOG.warning(msg)

View File

@ -19,7 +19,7 @@ import time
from nova.compute import power_state
from nova import exception as nova_exception
from nova.i18n import _, _LW
from nova.i18n import _
from nova.virt import hardware
from oslo_config import cfg
from oslo_log import log as logging
@ -83,7 +83,7 @@ class ZVMInstance(object):
if ("Return Code: 200" in err_str and
"Reason Code: 12" in err_str):
# Instance already not active
LOG.warning(_LW("z/VM instance %s not active"), self._name)
LOG.warning(_("z/VM instance %s not active"), self._name)
return
else:
msg = _("Failed to power off instance: %s") % err_str
@ -101,7 +101,7 @@ class ZVMInstance(object):
time.sleep(retry_interval)
retry_count -= 1
LOG.warning(_LW("Failed to shutdown instance %(inst)s in %(time)d "
LOG.warning(_("Failed to shutdown instance %(inst)s in %(time)d "
"seconds"), {'inst': self._name, 'time': timeout})
def power_on(self):
@ -113,7 +113,7 @@ class ZVMInstance(object):
if ("Return Code: 200" in err_str and
"Reason Code: 8" in err_str):
# Instance already active
LOG.warning(_LW("z/VM instance %s already active"), self._name)
LOG.warning(_("z/VM instance %s already active"), self._name)
return
raise nova_exception.InstancePowerOnFailure(reason=err_str)
@ -135,7 +135,7 @@ class ZVMInstance(object):
if ("Return Code: 200" in err_str and
"Reason Code: 12" in err_str):
# Be able to reset in power state of SHUTDOWN
LOG.warning(_LW("Reset z/VM instance %s from SHUTDOWN state"),
LOG.warning(_("Reset z/VM instance %s from SHUTDOWN state"),
self._name)
return
else:
@ -230,7 +230,7 @@ class ZVMInstance(object):
_instance_info.cpu_time_ns = cpu_time
except exception.ZVMInvalidXCATResponseDataError:
LOG.warning(_LW("Failed to get inventory info for %s"),
LOG.warning(_("Failed to get inventory info for %s"),
self._name)
_instance_info.state = power_stat
_instance_info.max_mem_kb = max_mem_kb
@ -434,8 +434,8 @@ class ZVMInstance(object):
exception.ZVMVolumeError,
exception.ZVMDriverError) as err:
emsg = err.format_message()
msg = _LW("Failed to clean boot from volume "
"preparations: %s") % emsg
msg = _("Failed to clean boot from volume "
"preparations: %s") % emsg
LOG.warning(msg)
raise exception.ZVMVolumeError(msg=msg)

View File

@ -26,7 +26,7 @@ import time
from nova import block_device
from nova.compute import power_state
from nova import exception as nova_exception
from nova.i18n import _, _LE, _LI, _LW
from nova.i18n import _
from nova.virt import driver
from oslo_config import cfg
from oslo_log import log as logging
@ -268,7 +268,7 @@ class HTTPSClientAuthConnection(httplib.HTTPSConnection):
if (self.ca_file is not None and
not os.path.exists(self.ca_file)):
LOG.warning(_LW("the CA file %(ca_file) does not exist!"),
LOG.warning(_("the CA file %(ca_file) does not exist!"),
{'ca_file': self.ca_file})
self.use_ca = False
@ -401,11 +401,11 @@ def xcat_request(method, url, body=None, headers=None, ignore_warning=False):
# Yes, we finished the request, let's return or handle error
return ret
LOG.info(_LI("xCAT encounter service handling error (http 503), "
"Attempt %(retry)s of %(max_retry)s "
"request: xCAT-Server: %(xcat_server)s "
"Request-method: %(method)s "
"URL: %(url)s."),
LOG.info(_("xCAT encounter service handling error (http 503), "
"Attempt %(retry)s of %(max_retry)s "
"request: xCAT-Server: %(xcat_server)s "
"Request-method: %(method)s "
"URL: %(url)s."),
{'retry': max_attempts - retry_attempts + 1,
'max_retry': max_attempts,
'xcat_server': CONF.zvm_xcat_server,
@ -416,11 +416,11 @@ def xcat_request(method, url, body=None, headers=None, ignore_warning=False):
if retry_attempts > 0:
time.sleep(2)
LOG.warning(_LW("xCAT encounter service handling error (http 503), "
"Retried %(max_retry)s times but still failed. "
"request: xCAT-Server: %(xcat_server)s "
"Request-method: %(method)s "
"URL: %(url)s."),
LOG.warning(_("xCAT encounter service handling error (http 503), "
"Retried %(max_retry)s times but still failed. "
"request: xCAT-Server: %(xcat_server)s "
"Request-method: %(method)s "
"URL: %(url)s."),
{'max_retry': max_attempts,
'xcat_server': CONF.zvm_xcat_server,
'method': method,
@ -491,7 +491,7 @@ def except_xcat_call_failed_and_reraise(exc, **kwargs):
exception.ZVMXCATInternalError) as err:
msg = err.format_message()
kwargs['msg'] = msg
LOG.error(_LE('XCAT response return error: %s'), msg)
LOG.error(_('XCAT response return error: %s'), msg)
raise exc(**kwargs)
@ -597,7 +597,7 @@ def _log_warnings(resp):
for msg in (resp['info'], resp['node'], resp['data']):
msgstr = str(msg)
if 'warn' in msgstr.lower():
LOG.info(_LI("Warning from xCAT: %s"), msgstr)
LOG.info(_("Warning from xCAT: %s"), msgstr)
def _is_warning_or_recoverable_issue(err_str):
@ -868,8 +868,8 @@ def aemod_handler(instance_name, func_name, parms):
except Exception as err:
emsg = format_exception_msg(err)
with excutils.save_and_reraise_exception():
LOG.error(_LE('Invoke AE method function: %(func)s on %(node)s '
'failed with reason: %(msg)s'),
LOG.error(_('Invoke AE method function: %(func)s on %(node)s '
'failed with reason: %(msg)s'),
{'func': func_name, 'node': instance_name, 'msg': emsg})

View File

@ -18,7 +18,7 @@ import six
import time
import nova.context
from nova.i18n import _, _LW
from nova.i18n import _
from nova.objects import block_device as block_device_obj
from nova.objects import instance as instance_obj
from nova.volume import cinder
@ -50,7 +50,7 @@ class VolumeOperator(object):
try:
self._svc_driver.init_host(host_stats)
except (exception.ZVMDriverError, exception.ZVMVolumeError) as err:
LOG.warning(_LW("Initialize zhcp failed. Reason: %s"),
LOG.warning(_("Initialize zhcp failed. Reason: %s"),
err.format_message())
def attach_volume_to_instance(self, context, connection_info, instance,