diff --git a/doc/source/drivers/ilo.rst b/doc/source/drivers/ilo.rst index c5beb3b4b7..63c3c1a716 100644 --- a/doc/source/drivers/ilo.rst +++ b/doc/source/drivers/ilo.rst @@ -40,9 +40,9 @@ Prerequisites managing HP Proliant hardware. Install ``proliantutils`` [2]_ module on the Ironic conductor node. Minimum - version required is 0.1.0.:: + version required is 2.0.1.:: - $ pip install "proliantutils>=0.1.0" + $ pip install "proliantutils>=2.0.1" * ``ipmitool`` command must be present on the service node(s) where ``ironic-conductor`` is running. On most distros, this is provided as part diff --git a/driver-requirements.txt b/driver-requirements.txt index 7cc0f7844a..9b0d25836a 100644 --- a/driver-requirements.txt +++ b/driver-requirements.txt @@ -4,7 +4,7 @@ # python projects they should package as optional dependencies for Ironic. # These are available on pypi -proliantutils +proliantutils>=2.0.1 pyghmi pysnmp python-scciclient diff --git a/ironic/drivers/modules/ilo/common.py b/ironic/drivers/modules/ilo/common.py index 93a6b97abd..99d7a31f0f 100644 --- a/ironic/drivers/modules/ilo/common.py +++ b/ironic/drivers/modules/ilo/common.py @@ -31,7 +31,8 @@ from ironic.common import utils from ironic.drivers import utils as driver_utils from ironic.openstack.common import log as logging -ilo_client = importutils.try_import('proliantutils.ilo.ribcl') +ilo_client = importutils.try_import('proliantutils.ilo.client') +ilo_error = importutils.try_import('proliantutils.exception') STANDARD_LICENSE = 1 ESSENTIALS_LICENSE = 2 @@ -173,7 +174,7 @@ def get_ilo_license(node): ilo_object = get_ilo_object(node) try: license_info = ilo_object.get_all_licenses() - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: raise exception.IloOperationError(operation=_('iLO license check'), error=str(ilo_exception)) @@ -285,7 +286,7 @@ def attach_vmedia(node, device, url): ilo_object.insert_virtual_media(url, device=device) ilo_object.set_vm_status(device=device, boot_option='CONNECT', write_protect='YES') - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: operation = _("Inserting virtual media %s") % device raise exception.IloOperationError(operation=operation, error=ilo_exception) @@ -304,7 +305,7 @@ def set_boot_mode(node, boot_mode): try: p_boot_mode = ilo_object.get_pending_boot_mode() - except ilo_client.IloCommandNotSupportedError: + except ilo_error.IloCommandNotSupportedError: p_boot_mode = DEFAULT_BOOT_MODE if BOOT_MODE_ILO_TO_GENERIC[p_boot_mode.lower()] == boot_mode: @@ -315,7 +316,7 @@ def set_boot_mode(node, boot_mode): try: ilo_object.set_pending_boot_mode( BOOT_MODE_GENERIC_TO_ILO[boot_mode].upper()) - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: operation = _("Setting %s as boot mode") % boot_mode raise exception.IloOperationError(operation=operation, error=ilo_exception) @@ -341,7 +342,7 @@ def update_boot_mode_capability(task): # and if it fails then we fall back to BIOS boot mode. ilo_object.set_pending_boot_mode('UEFI') p_boot_mode = 'UEFI' - except ilo_client.IloCommandNotSupportedError: + except ilo_error.IloCommandNotSupportedError: p_boot_mode = DEFAULT_BOOT_MODE driver_utils.rm_node_capability(task, 'boot_mode') @@ -418,7 +419,7 @@ def cleanup_vmedia_boot(task): for device in ('FLOPPY', 'CDROM'): try: ilo_object.eject_virtual_media(device) - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: LOG.exception(_LE("Error while ejecting virtual media %(device)s " "from node %(uuid)s. Error: %(error)s"), {'device': device, 'uuid': task.node.uuid, diff --git a/ironic/drivers/modules/ilo/management.py b/ironic/drivers/modules/ilo/management.py index 6bf47e5e66..0354441b6a 100644 --- a/ironic/drivers/modules/ilo/management.py +++ b/ironic/drivers/modules/ilo/management.py @@ -28,7 +28,7 @@ from ironic.openstack.common import log as logging LOG = logging.getLogger(__name__) -ilo_client = importutils.try_import('proliantutils.ilo.ribcl') +ilo_error = importutils.try_import('proliantutils.exception') BOOT_DEVICE_MAPPING_TO_ILO = {boot_devices.PXE: 'NETWORK', boot_devices.DISK: 'HDD', @@ -96,7 +96,7 @@ class IloManagement(base.ManagementInterface): persistent = True next_boot = ilo_object.get_persistent_boot_device() - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: operation = _("Get boot device") raise exception.IloOperationError(operation=operation, error=ilo_exception) @@ -139,7 +139,7 @@ class IloManagement(base.ManagementInterface): else: ilo_object.update_persistent_boot([boot_device]) - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: operation = _("Setting %s as boot device") % device raise exception.IloOperationError(operation=operation, error=ilo_exception) diff --git a/ironic/drivers/modules/ilo/power.py b/ironic/drivers/modules/ilo/power.py index 1230c84f14..97e1c23e34 100644 --- a/ironic/drivers/modules/ilo/power.py +++ b/ironic/drivers/modules/ilo/power.py @@ -31,7 +31,7 @@ from ironic.drivers.modules.ilo import common as ilo_common from ironic.openstack.common import log as logging from ironic.openstack.common import loopingcall -ilo_client = importutils.try_import('proliantutils.ilo.ribcl') +ilo_error = importutils.try_import('proliantutils.exception') opts = [ @@ -81,7 +81,7 @@ def _get_power_state(node): try: power_status = ilo_object.get_host_power_status() - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: LOG.error(_LE("iLO get_power_state failed for node %(node_id)s with " "error: %(error)s."), {'node_id': node.uuid, 'error': ilo_exception}) @@ -153,7 +153,7 @@ def _set_power_state(task, target_state): "'%s'") % target_state raise exception.InvalidParameterValue(msg) - except ilo_client.IloError as ilo_exception: + except ilo_error.IloError as ilo_exception: LOG.error(_LE("iLO set_power_state failed to set state to %(tstate)s " " for node %(node_id)s with error: %(error)s"), {'tstate': target_state, 'node_id': node.uuid, diff --git a/ironic/tests/drivers/ilo/test_common.py b/ironic/tests/drivers/ilo/test_common.py index f1f771a1a4..a87f0bef8c 100644 --- a/ironic/tests/drivers/ilo/test_common.py +++ b/ironic/tests/drivers/ilo/test_common.py @@ -33,7 +33,8 @@ from ironic.tests.db import base as db_base from ironic.tests.db import utils as db_utils from ironic.tests.objects import utils as obj_utils -ilo_client = importutils.try_import('proliantutils.ilo.ribcl') +ilo_client = importutils.try_import('proliantutils.ilo.client') +ilo_error = importutils.try_import('proliantutils.exception') CONF = cfg.CONF @@ -142,7 +143,7 @@ class IloCommonMethodsTestCase(db_base.DbTestCase): @mock.patch.object(ilo_common, 'get_ilo_object') def test_get_ilo_license_fail(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') ilo_mock_object.get_all_licenses.side_effect = exc self.assertRaises(exception.IloOperationError, ilo_common.get_ilo_license, @@ -256,7 +257,7 @@ class IloCommonMethodsTestCase(db_base.DbTestCase): def test_attach_vmedia_fails(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value set_status_mock = ilo_mock_object.set_vm_status - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') set_status_mock.side_effect = exc self.assertRaises(exception.IloOperationError, ilo_common.attach_vmedia, self.node, @@ -291,7 +292,7 @@ class IloCommonMethodsTestCase(db_base.DbTestCase): get_pending_boot_mode_mock = ilo_object_mock.get_pending_boot_mode get_pending_boot_mode_mock.return_value = 'UEFI' set_pending_boot_mode_mock = ilo_object_mock.set_pending_boot_mode - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') set_pending_boot_mode_mock.side_effect = exc self.assertRaises(exception.IloOperationError, ilo_common.set_boot_mode, self.node, 'bios') @@ -342,7 +343,7 @@ class IloCommonMethodsTestCase(db_base.DbTestCase): get_ilo_object_mock, add_node_capability_mock): ilo_mock_obj = get_ilo_object_mock.return_value - exc = ilo_client.IloCommandNotSupportedError('error') + exc = ilo_error.IloCommandNotSupportedError('error') ilo_mock_obj.get_pending_boot_mode.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, diff --git a/ironic/tests/drivers/ilo/test_deploy.py b/ironic/tests/drivers/ilo/test_deploy.py index 4147b161d4..ed1add1f1f 100644 --- a/ironic/tests/drivers/ilo/test_deploy.py +++ b/ironic/tests/drivers/ilo/test_deploy.py @@ -34,14 +34,11 @@ from ironic.drivers.modules.ilo import deploy as ilo_deploy from ironic.drivers.modules import iscsi_deploy from ironic.drivers.modules import pxe from ironic.drivers import utils as driver_utils -from ironic.openstack.common import importutils from ironic.tests.conductor import utils as mgr_utils from ironic.tests.db import base as db_base from ironic.tests.db import utils as db_utils from ironic.tests.objects import utils as obj_utils -ilo_client = importutils.try_import('proliantutils.ilo.ribcl') - INFO_DICT = db_utils.get_test_ilo_info() CONF = cfg.CONF diff --git a/ironic/tests/drivers/ilo/test_management.py b/ironic/tests/drivers/ilo/test_management.py index 149fff8944..71117af83a 100644 --- a/ironic/tests/drivers/ilo/test_management.py +++ b/ironic/tests/drivers/ilo/test_management.py @@ -29,7 +29,7 @@ from ironic.tests.db import base as db_base from ironic.tests.db import utils as db_utils from ironic.tests.objects import utils as obj_utils -ilo_client = importutils.try_import('proliantutils.ilo.ribcl') +ilo_error = importutils.try_import('proliantutils.exception') INFO_DICT = db_utils.get_test_ilo_info() @@ -98,7 +98,7 @@ class IloManagementTestCase(db_base.DbTestCase): @mock.patch.object(ilo_common, 'get_ilo_object') def test_get_boot_device_fail(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') ilo_mock_object.get_one_time_boot.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, @@ -112,7 +112,7 @@ class IloManagementTestCase(db_base.DbTestCase): def test_get_boot_device_persistent_fail(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value ilo_mock_object.get_one_time_boot.return_value = 'Normal' - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') ilo_mock_object.get_persistent_boot_device.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, @@ -147,7 +147,7 @@ class IloManagementTestCase(db_base.DbTestCase): @mock.patch.object(ilo_common, 'get_ilo_object') def test_set_boot_device_fail(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') ilo_mock_object.set_one_time_boot.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, @@ -160,7 +160,7 @@ class IloManagementTestCase(db_base.DbTestCase): @mock.patch.object(ilo_common, 'get_ilo_object') def test_set_boot_device_persistent_fail(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') ilo_mock_object.update_persistent_boot.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, diff --git a/ironic/tests/drivers/ilo/test_power.py b/ironic/tests/drivers/ilo/test_power.py index ead1a00f3c..c7e576b79c 100644 --- a/ironic/tests/drivers/ilo/test_power.py +++ b/ironic/tests/drivers/ilo/test_power.py @@ -32,7 +32,7 @@ from ironic.tests.db import base as db_base from ironic.tests.db import utils as db_utils from ironic.tests.objects import utils as obj_utils -ilo_client = importutils.try_import('proliantutils.ilo.ribcl') +ilo_error = importutils.try_import('proliantutils.exception') INFO_DICT = db_utils.get_test_ilo_info() CONF = cfg.CONF @@ -68,7 +68,7 @@ class IloPowerInternalMethodsTestCase(db_base.DbTestCase): def test__get_power_state_fail(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') ilo_mock_object.get_host_power_status.side_effect = exc self.assertRaises(exception.IloOperationError, @@ -86,7 +86,7 @@ class IloPowerInternalMethodsTestCase(db_base.DbTestCase): def test__set_power_state_reboot_fail(self, get_ilo_object_mock): ilo_mock_object = get_ilo_object_mock.return_value - exc = ilo_client.IloError('error') + exc = ilo_error.IloError('error') ilo_mock_object.reset_server.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, diff --git a/ironic/tests/drivers/third_party_driver_mocks.py b/ironic/tests/drivers/third_party_driver_mocks.py index 4100221013..36dbf9b50b 100644 --- a/ironic/tests/drivers/third_party_driver_mocks.py +++ b/ironic/tests/drivers/third_party_driver_mocks.py @@ -87,10 +87,11 @@ if not proliantutils: proliantutils = mock.MagicMock() sys.modules['proliantutils'] = proliantutils sys.modules['proliantutils.ilo'] = proliantutils.ilo - sys.modules['proliantutils.ilo.ribcl'] = proliantutils.ilo.ribcl - proliantutils.ilo.ribcl.IloError = type('IloError', (Exception,), {}) + sys.modules['proliantutils.ilo.client'] = proliantutils.ilo.client + sys.modules['proliantutils.exception'] = proliantutils.exception + proliantutils.exception.IloError = type('IloError', (Exception,), {}) command_exception = type('IloCommandNotSupportedError', (Exception,), {}) - proliantutils.ilo.ribcl.IloCommandNotSupportedError = command_exception + proliantutils.exception.IloCommandNotSupportedError = command_exception if 'ironic.drivers.ilo' in sys.modules: reload(sys.modules['ironic.drivers.ilo'])