Fix nits in the XClarity Driver codebase.

Follow up to commit 346a9a3bfc

 * Move exception XClarityError to common/exceptions.py
 * Update language of the release note.
 * Specify the kind of power operation being performed.

Change-Id: I1dbc49d7d6185ce3c5f37f518bbecd11571a74fb
This commit is contained in:
Rushil Chugh 2018-03-01 01:35:44 -05:00
parent 46ee76aa46
commit 4f08f726be
7 changed files with 23 additions and 20 deletions

View File

@ -772,3 +772,7 @@ class InstanceRescueFailure(IronicException):
class InstanceUnrescueFailure(IronicException):
_msg_fmt = _('Failed to unrescue instance %(instance)s for node '
'%(node)s: %(reason)s')
class XClarityError(IronicException):
_msg_fmt = _("XClarity exception occurred. Error: %(error)s")

View File

@ -67,7 +67,7 @@ def get_xclarity_client():
msg = (_("Error getting connection to XClarity manager IP: %(ip)s. "
"Error: %(exc)s"), {'ip': CONF.xclarity.manager_ip,
'exc': exc})
raise XClarityError(error=msg)
raise exception.XClarityError(error=msg)
return xclarity_client
@ -132,7 +132,3 @@ def is_node_managed_by_xclarity(xclarity_client, node):
return xclarity_client.is_node_managed(hardware_id)
except exception.MissingParameterValue:
return False
class XClarityError(exception.IronicException):
_msg_fmt = _("XClarity exception occurred. Error: %(error)s")

View File

@ -108,7 +108,7 @@ class XClarityManagement(base.ManagementInterface):
"Error getting boot device from XClarity for node %(node)s. "
"Error: %(error)s", {'node': task.node.uuid,
'error': xclarity_exc})
raise common.XClarityError(error=xclarity_exc)
raise exception.XClarityError(error=xclarity_exc)
persistent = False
primary = None
@ -216,4 +216,4 @@ class XClarityManagement(base.ManagementInterface):
{'boot_device': xclarity_boot_device, 'node': task.node.uuid,
'error': xclarity_exc}
)
raise common.XClarityError(error=xclarity_exc)
raise exception.XClarityError(error=xclarity_exc)

View File

@ -16,6 +16,7 @@ from ironic_lib import metrics_utils
from oslo_log import log as logging
from oslo_utils import importutils
from ironic.common import exception
from ironic.common import states
from ironic.conductor import task_manager
from ironic.drivers import base
@ -66,7 +67,7 @@ class XClarityPower(base.PowerInterface):
"%(error)s"),
{'node': task.node.uuid, 'error': xclarity_exc}
)
raise common.XClarityError(error=xclarity_exc)
raise exception.XClarityError(error=xclarity_exc)
return common.translate_xclarity_power_state(power_state)
@METRICS.timer('XClarityPower.set_power_state')
@ -107,12 +108,12 @@ class XClarityPower(base.PowerInterface):
"Error setting power state of node %(node_uuid)s to "
"%(power_state)s",
{'node_uuid': task.node.uuid, 'power_state': power_state})
raise common.XClarityError(error=xclarity_exc)
raise exception.XClarityError(error=xclarity_exc)
@METRICS.timer('XClarityPower.reboot')
@task_manager.require_exclusive_lock
def reboot(self, task, timeout=None):
"""Reboot the node
"""Soft reboot the node
:param task: a TaskManager instance.
:param timeout: timeout (in seconds). Unsupported by this interface.

View File

@ -22,6 +22,7 @@ import mock
from oslo_utils import importutils
from ironic.common import boot_devices
from ironic.common import exception
from ironic.conductor import task_manager
from ironic.drivers.modules.xclarity import common
from ironic.drivers.modules.xclarity import management
@ -82,9 +83,9 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase):
if 'ironic.drivers.modules.xclarity' in sys.modules:
six.moves.reload_module(
sys.modules['ironic.drivers.modules.xclarity'])
ex = common.XClarityError('E')
ex = exception.XClarityError('E')
mock_get_xc_client.return_value.set_node_boot_info.side_effect = ex
self.assertRaises(common.XClarityError,
self.assertRaises(exception.XClarityError,
task.driver.management.set_boot_device,
task,
"pxe")
@ -117,9 +118,9 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase):
if 'ironic.drivers.modules.xclarity' in sys.modules:
six.moves.reload_module(
sys.modules['ironic.drivers.modules.xclarity'])
ex = common.XClarityError('E')
ex = exception.XClarityError('E')
mock_xc_client.return_value.get_node_all_boot_info.side_effect = ex
self.assertRaises(
common.XClarityError,
exception.XClarityError,
task.driver.management.get_boot_device,
task)

View File

@ -26,6 +26,7 @@ import mock
from oslo_utils import importutils
from ironic.common import exception
from ironic.common import states
from ironic.conductor import task_manager
from ironic.drivers.modules.xclarity import common
@ -84,9 +85,9 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
if 'ironic.drivers.modules.xclarity' in sys.modules:
six.moves.reload_module(
sys.modules['ironic.drivers.modules.xclarity'])
ex = common.XClarityError('E')
ex = exception.XClarityError('E')
mock_xc_client.return_value.get_node_power_status.side_effect = ex
self.assertRaises(common.XClarityError,
self.assertRaises(exception.XClarityError,
task.driver.power.get_power_state,
task)
@ -121,9 +122,9 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
if 'ironic.drivers.modules.xclarity' in sys.modules:
six.moves.reload_module(
sys.modules['ironic.drivers.modules.xclarity'])
ex = common.XClarityError('E')
ex = exception.XClarityError('E')
mock_xc_client.return_value.set_node_power_status.side_effect = ex
self.assertRaises(common.XClarityError,
self.assertRaises(exception.XClarityError,
task.driver.power.set_power_state,
task, states.POWER_OFF)

View File

@ -2,8 +2,8 @@
features:
- |
Adds the new ``xclarity`` hardware type for managing Lenovo server
hardware with the following interfaces:
Adds the new ``xclarity`` hardware type for managing the Lenovo IMM2 and IMM3
family of server hardware with the following interfaces:
* management: ``xclarity``
* power: ``xclarity``