Browse Source

Merge "opt: Enhance old stable branches to use latest python-ibmcclient" into stable/train

changes/92/760792/1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
aa68e1b504
4 changed files with 13 additions and 6 deletions
  1. +1
    -1
      driver-requirements.txt
  2. +8
    -1
      ironic/drivers/modules/ibmc/utils.py
  3. +2
    -2
      ironic/tests/unit/drivers/modules/ibmc/test_utils.py
  4. +2
    -2
      ironic/tests/unit/drivers/third_party_driver_mocks.py

+ 1
- 1
driver-requirements.txt View File

@ -17,5 +17,5 @@ sushy>=1.9.0
ansible>=2.5
# HUAWEI iBMC hardware type uses the python-ibmcclient library
python-ibmcclient>=0.1.0,<0.2.0
python-ibmcclient>=0.1.0,!=0.2.1,<0.3.0

+ 8
- 1
ironic/drivers/modules/ibmc/utils.py View File

@ -31,6 +31,13 @@ from ironic.conf import CONF
ibmc_client = importutils.try_import('ibmcclient')
ibmc_error = importutils.try_import('ibmc_client.exceptions')
try:
# NOTE(Qianbiao.NG) from python-ibmcclient>=0.2.2, ConnectionError is
# renamed to IBMCConnectionError
ibmc_error.IBMCConnectionError
except AttributeError:
ibmc_error.IBMCConnectionError = ibmc_error.ConnectionError
LOG = log.getLogger(__name__)
REQUIRED_PROPERTIES = {
@ -153,7 +160,7 @@ def handle_ibmc_exception(action):
try:
return f(*args, **kwargs)
except ibmc_error.ConnectionError as e:
except ibmc_error.IBMCConnectionError as e:
error = (_('Failed to connect to iBMC for node %(node)s, '
'Error: %(error)s')
% {'node': node.uuid, 'error': e})


+ 2
- 2
ironic/tests/unit/drivers/modules/ibmc/test_utils.py View File

@ -144,8 +144,8 @@ class IBMCUtilsTestCase(base.IBMCTestCase):
conn = self.mock_ibmc_conn(connect_ibmc)
# Mocks
conn.system.get.side_effect = [
ibmc_error.ConnectionError(url=self.ibmc['address'],
error='Failed to connect to host'),
ibmc_error.IBMCConnectionError(url=self.ibmc['address'],
error='Failed to connect to host'),
mock.PropertyMock(
boot_source_override=mock.PropertyMock(
target=constants.BOOT_SOURCE_TARGET_PXE,


+ 2
- 2
ironic/tests/unit/drivers/third_party_driver_mocks.py View File

@ -262,8 +262,8 @@ if not ibmc_client:
# Mock iBMC client exceptions
exceptions = mock.MagicMock()
exceptions.ConnectionError = (
type('ConnectionError', (MockKwargsException,), {}))
exceptions.IBMCConnectionError = (
type('IBMCConnectionError', (MockKwargsException,), {}))
exceptions.IBMCClientError = (
type('IBMCClientError', (MockKwargsException,), {}))
sys.modules['ibmc_client.exceptions'] = exceptions


Loading…
Cancel
Save