Merge "Try to standardize retrieval of an Exception's description"
This commit is contained in:
commit
4b5c8f13d9
@ -99,6 +99,10 @@ class IronicException(Exception):
|
|||||||
|
|
||||||
return self.args[0]
|
return self.args[0]
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
"""Return a unicode representation of the exception message."""
|
||||||
|
return unicode(self.args[0])
|
||||||
|
|
||||||
def format_message(self):
|
def format_message(self):
|
||||||
if self.__class__.__name__.endswith('_Remote'):
|
if self.__class__.__name__.endswith('_Remote'):
|
||||||
return self.args[0]
|
return self.args[0]
|
||||||
|
@ -41,6 +41,7 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_service import loopingcall
|
from oslo_service import loopingcall
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
|
import six
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
@ -401,7 +402,7 @@ def _exec_ipmitool(driver_info, command):
|
|||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
with excutils.save_and_reraise_exception() as ctxt:
|
with excutils.save_and_reraise_exception() as ctxt:
|
||||||
err_list = [x for x in IPMITOOL_RETRYABLE_FAILURES
|
err_list = [x for x in IPMITOOL_RETRYABLE_FAILURES
|
||||||
if x in e.args[0]]
|
if x in six.text_type(e)]
|
||||||
if ((time.time() > end_time) or
|
if ((time.time() > end_time) or
|
||||||
(num_tries == 0) or
|
(num_tries == 0) or
|
||||||
not err_list):
|
not err_list):
|
||||||
|
@ -69,9 +69,9 @@ class MSFTOCSClientApi(object):
|
|||||||
url, auth=auth.HTTPBasicAuth(self._username, self._password))
|
url, auth=auth.HTTPBasicAuth(self._username, self._password))
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except requests_exceptions.RequestException as ex:
|
except requests_exceptions.RequestException as ex:
|
||||||
LOG.exception(_LE("HTTP call failed: %s"), ex)
|
msg = _("HTTP call failed: %s") % ex
|
||||||
raise exception.MSFTOCSClientApiException(
|
LOG.exception(msg)
|
||||||
_("HTTP call failed: %s") % ex.args[0])
|
raise exception.MSFTOCSClientApiException(msg)
|
||||||
|
|
||||||
xml_response = response.text
|
xml_response = response.text
|
||||||
LOG.debug("Call to %(url)s got response: %(xml_response)s",
|
LOG.debug("Call to %(url)s got response: %(xml_response)s",
|
||||||
|
@ -25,6 +25,7 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_service import loopingcall
|
from oslo_service import loopingcall
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
|
import six
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
@ -580,8 +581,8 @@ class Management(base.ManagementInterface):
|
|||||||
except seamicro_client_exception.ClientException as ex:
|
except seamicro_client_exception.ClientException as ex:
|
||||||
LOG.error(_LE("Seamicro set boot device failed for node "
|
LOG.error(_LE("Seamicro set boot device failed for node "
|
||||||
"%(node)s with the following error: %(error)s"),
|
"%(node)s with the following error: %(error)s"),
|
||||||
{'node': task.node.uuid, 'error': ex.args[0]})
|
{'node': task.node.uuid, 'error': ex})
|
||||||
raise exception.IronicException(message=ex.args[0])
|
raise exception.IronicException(message=six.text_type(ex))
|
||||||
|
|
||||||
def get_boot_device(self, task):
|
def get_boot_device(self, task):
|
||||||
"""Get the current boot device for the task's node.
|
"""Get the current boot device for the task's node.
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
import six
|
||||||
|
|
||||||
from ironic.common import exception
|
from ironic.common import exception
|
||||||
from ironic.common import states
|
from ironic.common import states
|
||||||
@ -279,7 +280,7 @@ class TestInspectPrivateMethods(db_base.DbTestCase):
|
|||||||
self.node,
|
self.node,
|
||||||
ilo_mock)
|
ilo_mock)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
result.format_message(),
|
six.text_type(result),
|
||||||
("Failed to inspect hardware. Reason: Server didn't return the "
|
("Failed to inspect hardware. Reason: Server didn't return the "
|
||||||
"key(s): cpu_arch"))
|
"key(s): cpu_arch"))
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import mock
|
|||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
import six
|
||||||
|
|
||||||
from ironic.common import boot_devices
|
from ironic.common import boot_devices
|
||||||
from ironic.common import driver_factory
|
from ironic.common import driver_factory
|
||||||
@ -348,7 +349,7 @@ class IPMIToolPrivateMethodTestCase(db_base.DbTestCase):
|
|||||||
ValueError,
|
ValueError,
|
||||||
self._test__make_password_file,
|
self._test__make_password_file,
|
||||||
mock_sleep, 12345, ValueError('we should fail'))
|
mock_sleep, 12345, ValueError('we should fail'))
|
||||||
self.assertEqual('we should fail', result.args[0])
|
self.assertEqual('we should fail', six.text_type(result))
|
||||||
|
|
||||||
@mock.patch.object(tempfile, 'NamedTemporaryFile',
|
@mock.patch.object(tempfile, 'NamedTemporaryFile',
|
||||||
new=mock.MagicMock(side_effect=OSError('Test Error')))
|
new=mock.MagicMock(side_effect=OSError('Test Error')))
|
||||||
@ -367,7 +368,7 @@ class IPMIToolPrivateMethodTestCase(db_base.DbTestCase):
|
|||||||
result = self.assertRaises(
|
result = self.assertRaises(
|
||||||
OverflowError,
|
OverflowError,
|
||||||
self._test__make_password_file, mock_sleep, 12345)
|
self._test__make_password_file, mock_sleep, 12345)
|
||||||
self.assertEqual('Test Error', result.args[0])
|
self.assertEqual('Test Error', six.text_type(result))
|
||||||
|
|
||||||
def test__make_password_file_write_exception(self, mock_sleep):
|
def test__make_password_file_write_exception(self, mock_sleep):
|
||||||
# Test exception in _make_password_file for write()
|
# Test exception in _make_password_file for write()
|
||||||
|
Loading…
Reference in New Issue
Block a user