Update Ilo drivers to use REST API interface to iLO

Currently, Ilo Drivers use only RIBCL to communicate with
iLO. As proliantutils module has been enhanced to support
communication over REST API for Gen9 Servers, the fix is
to support the use of newer version of proliantutils.

Closes-Bug: 1420210
Change-Id: Idba8a29a725ae393facca65ed0ae02a352e1da48
This commit is contained in:
Anusha Ramineni 2015-02-10 21:09:46 +05:30
parent b1f932a5c1
commit 5463cccf4b
10 changed files with 35 additions and 35 deletions

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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)

View File

@ -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,

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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'])