Merge "Add i18n translation for Log messages"
This commit is contained in:
commit
ceeccf1a95
|
@ -13,6 +13,9 @@
|
|||
from oslo_log import log as logging
|
||||
from tempest.lib import exceptions
|
||||
|
||||
from magnum.i18n import _LE
|
||||
from magnum.i18n import _LI
|
||||
from magnum.i18n import _LW
|
||||
from magnum.tests.functional.api.v1.models import bay_model
|
||||
from magnum.tests.functional.common import client
|
||||
from magnum.tests.functional.common import utils
|
||||
|
@ -120,9 +123,9 @@ class BayClient(client.MagnumClient):
|
|||
lambda: self.does_bay_exist(bay_id), 10, 1800)
|
||||
except Exception:
|
||||
# In error state. Clean up the bay id if desired
|
||||
self.LOG.error('Bay %s entered an exception state.' % bay_id)
|
||||
self.LOG.error(_LE('Bay %s entered an exception state.') % bay_id)
|
||||
if delete_on_error:
|
||||
self.LOG.error('We will attempt to delete bays now.')
|
||||
self.LOG.error(_LE('We will attempt to delete bays now.'))
|
||||
self.delete_bay(bay_id)
|
||||
self.wait_for_bay_to_delete(bay_id)
|
||||
raise
|
||||
|
@ -136,35 +139,35 @@ class BayClient(client.MagnumClient):
|
|||
resp, model = self.get_bay(bay_id)
|
||||
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
||||
'ERROR', 'CREATE_FAILED']:
|
||||
self.LOG.info('Bay %s succeeded.' % bay_id)
|
||||
self.LOG.info(_LI('Bay %s succeeded.') % bay_id)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Bay %s is not found.' % bay_id)
|
||||
self.LOG.warning(_LW('Bay %s is not found.') % bay_id)
|
||||
return False
|
||||
|
||||
def does_bay_exist(self, bay_id):
|
||||
try:
|
||||
resp, model = self.get_bay(bay_id)
|
||||
if model.status in ['CREATED', 'CREATE_COMPLETE']:
|
||||
self.LOG.info('Bay %s is created.' % bay_id)
|
||||
self.LOG.info(_LI('Bay %s is created.') % bay_id)
|
||||
return True
|
||||
elif model.status in ['ERROR', 'CREATE_FAILED']:
|
||||
self.LOG.error('Bay %s is in fail state.' % bay_id)
|
||||
self.LOG.error(_LE('Bay %s is in fail state.') % bay_id)
|
||||
raise exceptions.ServerFault(
|
||||
"Got into an error condition: %s for %s" %
|
||||
(model.status, bay_id))
|
||||
else:
|
||||
return False
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Bay %s is not found.' % bay_id)
|
||||
self.LOG.warning(_LW('Bay %s is not found.') % bay_id)
|
||||
return False
|
||||
|
||||
def does_bay_not_exist(self, bay_id):
|
||||
try:
|
||||
self.get_bay(bay_id)
|
||||
except exceptions.NotFound:
|
||||
self.LOG.warning('Bay %s is not found.' % bay_id)
|
||||
self.LOG.warning(_LW('Bay %s is not found.') % bay_id)
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -17,6 +17,8 @@ import subprocess
|
|||
from tempest.lib import base
|
||||
|
||||
import magnum
|
||||
from magnum.i18n import _LE
|
||||
from magnum.i18n import _LI
|
||||
|
||||
|
||||
COPY_LOG_HELPER = "magnum/tests/contrib/copy_instance_logs.sh"
|
||||
|
@ -44,10 +46,10 @@ class BaseMagnumTest(base.BaseTestCase):
|
|||
"""
|
||||
def int_copy_logs(exec_info):
|
||||
try:
|
||||
cls.LOG.info("Copying logs...")
|
||||
cls.LOG.info(_LI("Copying logs..."))
|
||||
fn = exec_info[2].tb_frame.f_locals['fn']
|
||||
func_name = fn.im_self._get_test_method().__name__
|
||||
msg = "Failed to copy logs for bay"
|
||||
msg = (_LE("Failed to copy logs for bay"))
|
||||
nodes_addresses = get_nodes_fn()
|
||||
|
||||
master_nodes = nodes_addresses[0]
|
||||
|
@ -61,8 +63,8 @@ class BaseMagnumTest(base.BaseTestCase):
|
|||
if not nodes_address:
|
||||
return
|
||||
|
||||
cls.LOG.info("copy logs from : %s" %
|
||||
','.join(nodes_address))
|
||||
msg = _LI("copy logs from : %s") % ','.join(nodes_address)
|
||||
cls.LOG.info(msg)
|
||||
log_name = prefix + "-" + func_name
|
||||
for node_address in nodes_address:
|
||||
try:
|
||||
|
@ -77,10 +79,13 @@ class BaseMagnumTest(base.BaseTestCase):
|
|||
])
|
||||
except Exception:
|
||||
cls.LOG.error(msg)
|
||||
cls.LOG.exception(
|
||||
"failed to copy from %s to %s%s-%s" %
|
||||
(node_address, "/opt/stack/logs/bay-nodes/",
|
||||
log_name, node_address))
|
||||
msg = (_LE("failed to copy from %{node_address}s "
|
||||
"to %{base_path}s%{log_name}s-"
|
||||
"%{node_address}s") %
|
||||
{'node_address': node_address,
|
||||
'base_path': "/opt/stack/logs/bay-nodes/",
|
||||
'log_name': log_name})
|
||||
cls.LOG.exception(msg)
|
||||
|
||||
do_copy_logs('master', master_nodes)
|
||||
do_copy_logs('node', agent_nodes)
|
||||
|
|
Loading…
Reference in New Issue