From 4f08f726beb89937ea4cc50ac65e10ab42f849ff Mon Sep 17 00:00:00 2001 From: Rushil Chugh Date: Thu, 1 Mar 2018 01:35:44 -0500 Subject: [PATCH] Fix nits in the XClarity Driver codebase. Follow up to commit 346a9a3bfc5312deb78bda8a82ae238e031413bd * Move exception XClarityError to common/exceptions.py * Update language of the release note. * Specify the kind of power operation being performed. Change-Id: I1dbc49d7d6185ce3c5f37f518bbecd11571a74fb --- ironic/common/exception.py | 4 ++++ ironic/drivers/modules/xclarity/common.py | 6 +----- ironic/drivers/modules/xclarity/management.py | 4 ++-- ironic/drivers/modules/xclarity/power.py | 7 ++++--- .../unit/drivers/modules/xclarity/test_management.py | 9 +++++---- ironic/tests/unit/drivers/modules/xclarity/test_power.py | 9 +++++---- releasenotes/notes/xclarity-driver-622800d17459e3f9.yaml | 4 ++-- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/ironic/common/exception.py b/ironic/common/exception.py index 8cbc15b8ca..d40e64f6e9 100644 --- a/ironic/common/exception.py +++ b/ironic/common/exception.py @@ -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") diff --git a/ironic/drivers/modules/xclarity/common.py b/ironic/drivers/modules/xclarity/common.py index ee35a843ca..1ffdfe248c 100644 --- a/ironic/drivers/modules/xclarity/common.py +++ b/ironic/drivers/modules/xclarity/common.py @@ -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") diff --git a/ironic/drivers/modules/xclarity/management.py b/ironic/drivers/modules/xclarity/management.py index c892687d16..2ae03f0be5 100644 --- a/ironic/drivers/modules/xclarity/management.py +++ b/ironic/drivers/modules/xclarity/management.py @@ -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) diff --git a/ironic/drivers/modules/xclarity/power.py b/ironic/drivers/modules/xclarity/power.py index f1bdc70140..eaaea67461 100644 --- a/ironic/drivers/modules/xclarity/power.py +++ b/ironic/drivers/modules/xclarity/power.py @@ -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. diff --git a/ironic/tests/unit/drivers/modules/xclarity/test_management.py b/ironic/tests/unit/drivers/modules/xclarity/test_management.py index 1d4fc92095..6e7034a1fb 100644 --- a/ironic/tests/unit/drivers/modules/xclarity/test_management.py +++ b/ironic/tests/unit/drivers/modules/xclarity/test_management.py @@ -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) diff --git a/ironic/tests/unit/drivers/modules/xclarity/test_power.py b/ironic/tests/unit/drivers/modules/xclarity/test_power.py index 6cec8cd31f..b01ee66237 100644 --- a/ironic/tests/unit/drivers/modules/xclarity/test_power.py +++ b/ironic/tests/unit/drivers/modules/xclarity/test_power.py @@ -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) diff --git a/releasenotes/notes/xclarity-driver-622800d17459e3f9.yaml b/releasenotes/notes/xclarity-driver-622800d17459e3f9.yaml index e9a83acf84..f0f7fe5e32 100644 --- a/releasenotes/notes/xclarity-driver-622800d17459e3f9.yaml +++ b/releasenotes/notes/xclarity-driver-622800d17459e3f9.yaml @@ -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``