Merge "DRAC: fix set/get boot device for 11g"
This commit is contained in:
commit
7a504c700c
@ -49,27 +49,40 @@ TARGET_DEVICE = 'BIOS.Setup.1-1'
|
|||||||
PERSISTENT = '1'
|
PERSISTENT = '1'
|
||||||
""" Is the next boot config the system will use. """
|
""" Is the next boot config the system will use. """
|
||||||
|
|
||||||
NOT_NEXT = '2'
|
|
||||||
""" Is not the next boot config the system will use. """
|
|
||||||
|
|
||||||
ONE_TIME_BOOT = '3'
|
ONE_TIME_BOOT = '3'
|
||||||
""" Is the next boot config the system will use, one time boot only. """
|
""" Is the next boot config the system will use, one time boot only. """
|
||||||
|
|
||||||
|
|
||||||
def _get_next_boot_mode(node):
|
def _get_boot_device(node, controller_version=None):
|
||||||
"""Get the next boot mode.
|
if controller_version is None:
|
||||||
|
controller_version = _get_lifecycle_controller_version(node)
|
||||||
|
|
||||||
To see a list of supported boot modes see: http://goo.gl/aEsvUH
|
boot_list = _get_next_boot_list(node)
|
||||||
(Section 7.2)
|
persistent = boot_list['is_next'] == PERSISTENT
|
||||||
|
boot_list_id = boot_list['instance_id']
|
||||||
|
|
||||||
|
boot_device_id = _get_boot_device_for_boot_list(node, boot_list_id,
|
||||||
|
controller_version)
|
||||||
|
boot_device = next((key for (key, value) in _BOOT_DEVICES_MAP.items()
|
||||||
|
if value in boot_device_id), None)
|
||||||
|
return {'boot_device': boot_device, 'persistent': persistent}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_next_boot_list(node):
|
||||||
|
"""Get the next boot list.
|
||||||
|
|
||||||
|
The DCIM_BootConfigSetting resource represents each boot list (eg.
|
||||||
|
IPL/BIOS, BCV, UEFI, vFlash Partition, One Time Boot).
|
||||||
|
The DCIM_BootSourceSetting resource represents each of the boot list boot
|
||||||
|
devices or sources that are shown under their corresponding boot list.
|
||||||
|
|
||||||
:param node: an ironic node object.
|
:param node: an ironic node object.
|
||||||
:raises: DracClientError on an error from pywsman library.
|
:raises: DracClientError on an error from pywsman library.
|
||||||
:returns: a dictionary containing:
|
:returns: a dictionary containing:
|
||||||
|
|
||||||
:instance_id: the instance id of the boot device.
|
:instance_id: the instance id of the boot list.
|
||||||
:is_next: whether it's the next device to boot or not. One of
|
:is_next: whether it's the next device to boot or not. One of
|
||||||
PERSISTENT, NOT_NEXT, ONE_TIME_BOOT constants.
|
PERSISTENT, ONE_TIME_BOOT constants.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
client = drac_client.get_wsman_client(node)
|
client = drac_client.get_wsman_client(node)
|
||||||
filter_query = ('select * from DCIM_BootConfigSetting where IsNext=%s '
|
filter_query = ('select * from DCIM_BootConfigSetting where IsNext=%s '
|
||||||
@ -89,20 +102,123 @@ def _get_next_boot_mode(node):
|
|||||||
|
|
||||||
# This list will have 2 items maximum, one for the persistent element
|
# This list will have 2 items maximum, one for the persistent element
|
||||||
# and another one for the OneTime if set
|
# and another one for the OneTime if set
|
||||||
boot_mode = None
|
boot_list = None
|
||||||
for i in items:
|
for i in items:
|
||||||
instance_id = drac_common.find_xml(
|
boot_list_id = drac_common.find_xml(
|
||||||
i, 'InstanceID', resource_uris.DCIM_BootConfigSetting).text
|
i, 'InstanceID', resource_uris.DCIM_BootConfigSetting).text
|
||||||
is_next = drac_common.find_xml(
|
is_next = drac_common.find_xml(
|
||||||
i, 'IsNext', resource_uris.DCIM_BootConfigSetting).text
|
i, 'IsNext', resource_uris.DCIM_BootConfigSetting).text
|
||||||
|
|
||||||
boot_mode = {'instance_id': instance_id, 'is_next': is_next}
|
boot_list = {'instance_id': boot_list_id, 'is_next': is_next}
|
||||||
# If OneTime is set we should return it, because that's
|
# If OneTime is set we should return it, because that's
|
||||||
# where the next boot device is
|
# where the next boot device is
|
||||||
if is_next == ONE_TIME_BOOT:
|
if is_next == ONE_TIME_BOOT:
|
||||||
break
|
break
|
||||||
|
|
||||||
return boot_mode
|
return boot_list
|
||||||
|
|
||||||
|
|
||||||
|
def _get_boot_device_for_boot_list(node, boot_list_id, controller_version):
|
||||||
|
"""Get the next boot device for a given boot list.
|
||||||
|
|
||||||
|
The DCIM_BootConfigSetting resource represents each boot list (eg.
|
||||||
|
IPL/BIOS, BCV, UEFI, vFlash Partition, One Time Boot).
|
||||||
|
The DCIM_BootSourceSetting resource represents each of the boot list boot
|
||||||
|
devices or sources that are shown under their corresponding boot list.
|
||||||
|
|
||||||
|
:param node: ironic node object.
|
||||||
|
:param boot_list_id: boot list id.
|
||||||
|
:param controller_version: version of the Lifecycle controller.
|
||||||
|
:raises: DracClientError on an error from pywsman library.
|
||||||
|
:returns: boot device id.
|
||||||
|
"""
|
||||||
|
client = drac_client.get_wsman_client(node)
|
||||||
|
|
||||||
|
if controller_version < '2.0.0':
|
||||||
|
filter_query = ('select * from DCIM_BootSourceSetting where '
|
||||||
|
'PendingAssignedSequence=0')
|
||||||
|
else:
|
||||||
|
filter_query = ('select * from DCIM_BootSourceSetting where '
|
||||||
|
'PendingAssignedSequence=0 and '
|
||||||
|
'BootSourceType="%s"' % boot_list_id)
|
||||||
|
try:
|
||||||
|
doc = client.wsman_enumerate(resource_uris.DCIM_BootSourceSetting,
|
||||||
|
filter_query=filter_query)
|
||||||
|
except exception.DracClientError as exc:
|
||||||
|
with excutils.save_and_reraise_exception():
|
||||||
|
LOG.error(_LE('DRAC driver failed to get the current boot '
|
||||||
|
'device for node %(node_uuid)s. '
|
||||||
|
'Reason: %(error)s.'),
|
||||||
|
{'node_uuid': node.uuid, 'error': exc})
|
||||||
|
|
||||||
|
if controller_version < '2.0.0':
|
||||||
|
boot_devices = drac_common.find_xml(
|
||||||
|
doc, 'InstanceID', resource_uris.DCIM_BootSourceSetting,
|
||||||
|
find_all=True)
|
||||||
|
for device in boot_devices:
|
||||||
|
if device.text.startswith(boot_list_id):
|
||||||
|
boot_device_id = device.text
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
boot_device_id = drac_common.find_xml(
|
||||||
|
doc, 'InstanceID', resource_uris.DCIM_BootSourceSetting).text
|
||||||
|
|
||||||
|
return boot_device_id
|
||||||
|
|
||||||
|
|
||||||
|
def _get_boot_list_for_boot_device(node, device, controller_version):
|
||||||
|
"""Get the boot list for a given boot device.
|
||||||
|
|
||||||
|
The DCIM_BootConfigSetting resource represents each boot list (eg.
|
||||||
|
IPL/BIOS, BCV, UEFI, vFlash Partition, One Time Boot).
|
||||||
|
The DCIM_BootSourceSetting resource represents each of the boot list boot
|
||||||
|
devices or sources that are shown under their corresponding boot list.
|
||||||
|
|
||||||
|
:param node: ironic node object.
|
||||||
|
:param device: boot device.
|
||||||
|
:param controller_version: version of the Lifecycle controller.
|
||||||
|
:raises: DracClientError on an error from pywsman library.
|
||||||
|
:returns: dictionary containing:
|
||||||
|
|
||||||
|
:boot_list: boot list.
|
||||||
|
:boot_device_id: boot device id.
|
||||||
|
"""
|
||||||
|
client = drac_client.get_wsman_client(node)
|
||||||
|
|
||||||
|
if controller_version < '2.0.0':
|
||||||
|
filter_query = None
|
||||||
|
else:
|
||||||
|
filter_query = ("select * from DCIM_BootSourceSetting where "
|
||||||
|
"InstanceID like '%%#%s%%'" %
|
||||||
|
_BOOT_DEVICES_MAP[device])
|
||||||
|
|
||||||
|
try:
|
||||||
|
doc = client.wsman_enumerate(resource_uris.DCIM_BootSourceSetting,
|
||||||
|
filter_query=filter_query)
|
||||||
|
except exception.DracClientError as exc:
|
||||||
|
with excutils.save_and_reraise_exception():
|
||||||
|
LOG.error(_LE('DRAC driver failed to set the boot device '
|
||||||
|
'for node %(node_uuid)s. Can\'t find the ID '
|
||||||
|
'for the %(device)s type. Reason: %(error)s.'),
|
||||||
|
{'node_uuid': node.uuid, 'error': exc,
|
||||||
|
'device': device})
|
||||||
|
|
||||||
|
if controller_version < '2.0.0':
|
||||||
|
boot_devices = drac_common.find_xml(
|
||||||
|
doc, 'InstanceID', resource_uris.DCIM_BootSourceSetting,
|
||||||
|
find_all=True)
|
||||||
|
for boot_device in boot_devices:
|
||||||
|
if _BOOT_DEVICES_MAP[device] in boot_device.text:
|
||||||
|
boot_device_id = boot_device.text
|
||||||
|
boot_list = boot_device_id.split(':')[0]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
boot_device_id = drac_common.find_xml(
|
||||||
|
doc, 'InstanceID', resource_uris.DCIM_BootSourceSetting).text
|
||||||
|
boot_list = drac_common.find_xml(
|
||||||
|
doc, 'BootSourceType', resource_uris.DCIM_BootSourceSetting).text
|
||||||
|
|
||||||
|
return {'boot_list': boot_list, 'boot_device_id': boot_device_id}
|
||||||
|
|
||||||
|
|
||||||
def _create_config_job(node):
|
def _create_config_job(node):
|
||||||
@ -177,6 +293,30 @@ def _check_for_config_job(node):
|
|||||||
target=TARGET_DEVICE)
|
target=TARGET_DEVICE)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_lifecycle_controller_version(node):
|
||||||
|
"""Returns the Lifecycle controller version of the DRAC card of the node
|
||||||
|
|
||||||
|
:param node: the node.
|
||||||
|
:returns: the Lifecycle controller version.
|
||||||
|
:raises: DracClientError if the client received unexpected response.
|
||||||
|
:raises: InvalidParameterValue if required DRAC credentials are missing.
|
||||||
|
"""
|
||||||
|
client = drac_client.get_wsman_client(node)
|
||||||
|
filter_query = ('select LifecycleControllerVersion from DCIM_SystemView')
|
||||||
|
try:
|
||||||
|
doc = client.wsman_enumerate(resource_uris.DCIM_SystemView,
|
||||||
|
filter_query=filter_query)
|
||||||
|
except exception.DracClientError as exc:
|
||||||
|
with excutils.save_and_reraise_exception():
|
||||||
|
LOG.error(_LE('DRAC driver failed to get power state for node '
|
||||||
|
'%(node_uuid)s. Reason: %(error)s.'),
|
||||||
|
{'node_uuid': node.uuid, 'error': exc})
|
||||||
|
|
||||||
|
version = drac_common.find_xml(doc, 'LifecycleControllerVersion',
|
||||||
|
resource_uris.DCIM_SystemView).text
|
||||||
|
return version
|
||||||
|
|
||||||
|
|
||||||
class DracManagement(base.ManagementInterface):
|
class DracManagement(base.ManagementInterface):
|
||||||
|
|
||||||
def get_properties(self):
|
def get_properties(self):
|
||||||
@ -228,8 +368,12 @@ class DracManagement(base.ManagementInterface):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
client = drac_client.get_wsman_client(task.node)
|
||||||
|
controller_version = _get_lifecycle_controller_version(task.node)
|
||||||
|
current_boot_device = _get_boot_device(task.node, controller_version)
|
||||||
|
|
||||||
# If we are already booting from the right device, do nothing.
|
# If we are already booting from the right device, do nothing.
|
||||||
if self.get_boot_device(task) == {'boot_device': device,
|
if current_boot_device == {'boot_device': device,
|
||||||
'persistent': persistent}:
|
'persistent': persistent}:
|
||||||
LOG.debug('DRAC already set to boot from %s', device)
|
LOG.debug('DRAC already set to boot from %s', device)
|
||||||
return
|
return
|
||||||
@ -237,35 +381,18 @@ class DracManagement(base.ManagementInterface):
|
|||||||
# Check for an existing configuration job
|
# Check for an existing configuration job
|
||||||
_check_for_config_job(task.node)
|
_check_for_config_job(task.node)
|
||||||
|
|
||||||
client = drac_client.get_wsman_client(task.node)
|
# Querying the boot device attributes
|
||||||
filter_query = ("select * from DCIM_BootSourceSetting where "
|
boot_device = _get_boot_list_for_boot_device(task.node, device,
|
||||||
"InstanceID like '%%#%s%%'" %
|
controller_version)
|
||||||
_BOOT_DEVICES_MAP[device])
|
boot_list = boot_device['boot_list']
|
||||||
try:
|
boot_device_id = boot_device['boot_device_id']
|
||||||
doc = client.wsman_enumerate(resource_uris.DCIM_BootSourceSetting,
|
|
||||||
filter_query=filter_query)
|
|
||||||
except exception.DracClientError as exc:
|
|
||||||
with excutils.save_and_reraise_exception():
|
|
||||||
LOG.error(_LE('DRAC driver failed to set the boot device '
|
|
||||||
'for node %(node_uuid)s. Can\'t find the ID '
|
|
||||||
'for the %(device)s type. Reason: %(error)s.'),
|
|
||||||
{'node_uuid': task.node.uuid, 'error': exc,
|
|
||||||
'device': device})
|
|
||||||
|
|
||||||
instance_id = drac_common.find_xml(
|
if not persistent:
|
||||||
doc, 'InstanceID', resource_uris.DCIM_BootSourceSetting).text
|
boot_list = 'OneTime'
|
||||||
|
|
||||||
source = 'OneTime'
|
# Send the request to DRAC
|
||||||
if persistent:
|
selectors = {'InstanceID': boot_list}
|
||||||
source = drac_common.find_xml(
|
properties = {'source': boot_device_id}
|
||||||
doc, 'BootSourceType',
|
|
||||||
resource_uris.DCIM_BootSourceSetting).text
|
|
||||||
|
|
||||||
# NOTE(lucasagomes): Don't ask me why 'BootSourceType' is set
|
|
||||||
# for 'InstanceID' and 'InstanceID' is set for 'source'! You
|
|
||||||
# know enterprisey...
|
|
||||||
selectors = {'InstanceID': source}
|
|
||||||
properties = {'source': instance_id}
|
|
||||||
try:
|
try:
|
||||||
client.wsman_invoke(resource_uris.DCIM_BootConfigSetting,
|
client.wsman_invoke(resource_uris.DCIM_BootConfigSetting,
|
||||||
'ChangeBootOrderByInstanceID', selectors,
|
'ChangeBootOrderByInstanceID', selectors,
|
||||||
@ -297,30 +424,7 @@ class DracManagement(base.ManagementInterface):
|
|||||||
future boots or not, None if it is unknown.
|
future boots or not, None if it is unknown.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
client = drac_client.get_wsman_client(task.node)
|
return _get_boot_device(task.node)
|
||||||
boot_mode = _get_next_boot_mode(task.node)
|
|
||||||
|
|
||||||
persistent = boot_mode['is_next'] == PERSISTENT
|
|
||||||
instance_id = boot_mode['instance_id']
|
|
||||||
|
|
||||||
filter_query = ('select * from DCIM_BootSourceSetting where '
|
|
||||||
'PendingAssignedSequence=0 and '
|
|
||||||
'BootSourceType="%s"' % instance_id)
|
|
||||||
try:
|
|
||||||
doc = client.wsman_enumerate(resource_uris.DCIM_BootSourceSetting,
|
|
||||||
filter_query=filter_query)
|
|
||||||
except exception.DracClientError as exc:
|
|
||||||
with excutils.save_and_reraise_exception():
|
|
||||||
LOG.error(_LE('DRAC driver failed to get the current boot '
|
|
||||||
'device for node %(node_uuid)s. '
|
|
||||||
'Reason: %(error)s.'),
|
|
||||||
{'node_uuid': task.node.uuid, 'error': exc})
|
|
||||||
|
|
||||||
instance_id = drac_common.find_xml(
|
|
||||||
doc, 'InstanceID', resource_uris.DCIM_BootSourceSetting).text
|
|
||||||
boot_device = next((key for (key, value) in _BOOT_DEVICES_MAP.items()
|
|
||||||
if value in instance_id), None)
|
|
||||||
return {'boot_device': boot_device, 'persistent': persistent}
|
|
||||||
|
|
||||||
def get_sensors_data(self, task):
|
def get_sensors_data(self, task):
|
||||||
"""Get sensors data.
|
"""Get sensors data.
|
||||||
|
@ -30,3 +30,6 @@ DCIM_BIOSService = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
|||||||
|
|
||||||
DCIM_LifecycleJob = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
DCIM_LifecycleJob = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
||||||
'DCIM_LifecycleJob')
|
'DCIM_LifecycleJob')
|
||||||
|
|
||||||
|
DCIM_SystemView = ('http://schemas.dell.com/wbem/wscim/1/cim-schema/2/'
|
||||||
|
'DCIM_SystemView')
|
||||||
|
@ -48,7 +48,7 @@ class DracManagementInternalMethodsTestCase(db_base.DbTestCase):
|
|||||||
driver='fake_drac',
|
driver='fake_drac',
|
||||||
driver_info=INFO_DICT)
|
driver_info=INFO_DICT)
|
||||||
|
|
||||||
def test__get_next_boot_mode(self, mock_client_pywsman):
|
def test__get_next_boot_list(self, mock_client_pywsman):
|
||||||
result_xml = test_utils.build_soap_xml(
|
result_xml = test_utils.build_soap_xml(
|
||||||
[{'DCIM_BootConfigSetting': {'InstanceID': 'IPL',
|
[{'DCIM_BootConfigSetting': {'InstanceID': 'IPL',
|
||||||
'IsNext': drac_mgmt.PERSISTENT}}],
|
'IsNext': drac_mgmt.PERSISTENT}}],
|
||||||
@ -59,13 +59,13 @@ class DracManagementInternalMethodsTestCase(db_base.DbTestCase):
|
|||||||
mock_pywsman.enumerate.return_value = mock_xml
|
mock_pywsman.enumerate.return_value = mock_xml
|
||||||
|
|
||||||
expected = {'instance_id': 'IPL', 'is_next': drac_mgmt.PERSISTENT}
|
expected = {'instance_id': 'IPL', 'is_next': drac_mgmt.PERSISTENT}
|
||||||
result = drac_mgmt._get_next_boot_mode(self.node)
|
result = drac_mgmt._get_next_boot_list(self.node)
|
||||||
|
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
mock_pywsman.enumerate.assert_called_once_with(
|
mock_pywsman.enumerate.assert_called_once_with(
|
||||||
mock.ANY, mock.ANY, resource_uris.DCIM_BootConfigSetting)
|
mock.ANY, mock.ANY, resource_uris.DCIM_BootConfigSetting)
|
||||||
|
|
||||||
def test__get_next_boot_mode_onetime(self, mock_client_pywsman):
|
def test__get_next_boot_list_onetime(self, mock_client_pywsman):
|
||||||
result_xml = test_utils.build_soap_xml(
|
result_xml = test_utils.build_soap_xml(
|
||||||
[{'DCIM_BootConfigSetting': {'InstanceID': 'IPL',
|
[{'DCIM_BootConfigSetting': {'InstanceID': 'IPL',
|
||||||
'IsNext': drac_mgmt.PERSISTENT}},
|
'IsNext': drac_mgmt.PERSISTENT}},
|
||||||
@ -79,7 +79,7 @@ class DracManagementInternalMethodsTestCase(db_base.DbTestCase):
|
|||||||
|
|
||||||
expected = {'instance_id': 'OneTime',
|
expected = {'instance_id': 'OneTime',
|
||||||
'is_next': drac_mgmt.ONE_TIME_BOOT}
|
'is_next': drac_mgmt.ONE_TIME_BOOT}
|
||||||
result = drac_mgmt._get_next_boot_mode(self.node)
|
result = drac_mgmt._get_next_boot_list(self.node)
|
||||||
|
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
mock_pywsman.enumerate.assert_called_once_with(
|
mock_pywsman.enumerate.assert_called_once_with(
|
||||||
@ -168,6 +168,21 @@ class DracManagementInternalMethodsTestCase(db_base.DbTestCase):
|
|||||||
mock.ANY, resource_uris.DCIM_BIOSService,
|
mock.ANY, resource_uris.DCIM_BIOSService,
|
||||||
'CreateTargetedConfigJob', None)
|
'CreateTargetedConfigJob', None)
|
||||||
|
|
||||||
|
def test__get_lifecycle_controller_version(self, mock_client_pywsman):
|
||||||
|
result_xml = test_utils.build_soap_xml(
|
||||||
|
[{'DCIM_SystemView': {'LifecycleControllerVersion': '42'}}],
|
||||||
|
resource_uris.DCIM_SystemView)
|
||||||
|
|
||||||
|
mock_xml = test_utils.mock_wsman_root(result_xml)
|
||||||
|
mock_pywsman = mock_client_pywsman.Client.return_value
|
||||||
|
mock_pywsman.enumerate.return_value = mock_xml
|
||||||
|
|
||||||
|
result = drac_mgmt._get_lifecycle_controller_version(self.node)
|
||||||
|
|
||||||
|
self.assertEqual('42', result)
|
||||||
|
mock_pywsman.enumerate.assert_called_once_with(
|
||||||
|
mock.ANY, mock.ANY, resource_uris.DCIM_SystemView)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(drac_client, 'pywsman', spec_set=mock_specs.PYWSMAN_SPEC)
|
@mock.patch.object(drac_client, 'pywsman', spec_set=mock_specs.PYWSMAN_SPEC)
|
||||||
class DracManagementTestCase(db_base.DbTestCase):
|
class DracManagementTestCase(db_base.DbTestCase):
|
||||||
@ -191,10 +206,14 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
self.assertEqual(sorted(expected),
|
self.assertEqual(sorted(expected),
|
||||||
sorted(self.driver.get_supported_boot_devices()))
|
sorted(self.driver.get_supported_boot_devices()))
|
||||||
|
|
||||||
@mock.patch.object(drac_mgmt, '_get_next_boot_mode', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_get_next_boot_list', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_get_boot_device(self, mock_gnbm, mock_client_pywsman):
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
mock_gnbm.return_value = {'instance_id': 'OneTime',
|
spec_set=True, autospec=True)
|
||||||
|
def test_get_boot_device(self, mock_glcv, mock_gnbl, mock_client_pywsman):
|
||||||
|
controller_version = '2.1.5.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
|
mock_gnbl.return_value = {'instance_id': 'OneTime',
|
||||||
'is_next': drac_mgmt.ONE_TIME_BOOT}
|
'is_next': drac_mgmt.ONE_TIME_BOOT}
|
||||||
|
|
||||||
result_xml = test_utils.build_soap_xml(
|
result_xml = test_utils.build_soap_xml(
|
||||||
@ -211,14 +230,20 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
mock_pywsman.enumerate.assert_called_once_with(
|
mock_pywsman.enumerate.assert_called_once_with(
|
||||||
mock.ANY, mock.ANY, resource_uris.DCIM_BootSourceSetting)
|
mock.ANY, mock.ANY, resource_uris.DCIM_BootSourceSetting)
|
||||||
|
|
||||||
@mock.patch.object(drac_mgmt, '_get_next_boot_mode', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_get_next_boot_list', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_get_boot_device_persistent(self, mock_gnbm, mock_client_pywsman):
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
mock_gnbm.return_value = {'instance_id': 'IPL',
|
spec_set=True, autospec=True)
|
||||||
|
def test_get_boot_device_persistent(self, mock_glcv, mock_gnbl,
|
||||||
|
mock_client_pywsman):
|
||||||
|
controller_version = '2.1.5.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
|
mock_gnbl.return_value = {'instance_id': 'IPL',
|
||||||
'is_next': drac_mgmt.PERSISTENT}
|
'is_next': drac_mgmt.PERSISTENT}
|
||||||
|
|
||||||
result_xml = test_utils.build_soap_xml(
|
result_xml = test_utils.build_soap_xml(
|
||||||
[{'InstanceID': 'NIC'}], resource_uris.DCIM_BootSourceSetting)
|
[{'InstanceID': 'NIC', 'BootSourceType': 'IPL'}],
|
||||||
|
resource_uris.DCIM_BootSourceSetting)
|
||||||
|
|
||||||
mock_xml = test_utils.mock_wsman_root(result_xml)
|
mock_xml = test_utils.mock_wsman_root(result_xml)
|
||||||
mock_pywsman = mock_client_pywsman.Client.return_value
|
mock_pywsman = mock_client_pywsman.Client.return_value
|
||||||
@ -233,11 +258,15 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
|
|
||||||
@mock.patch.object(drac_client.Client, 'wsman_enumerate', spec_set=True,
|
@mock.patch.object(drac_client.Client, 'wsman_enumerate', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(drac_mgmt, '_get_next_boot_mode', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_get_next_boot_list', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_get_boot_device_client_error(self, mock_gnbm, mock_we,
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
|
spec_set=True, autospec=True)
|
||||||
|
def test_get_boot_device_client_error(self, mock_glcv, mock_gnbl, mock_we,
|
||||||
mock_client_pywsman):
|
mock_client_pywsman):
|
||||||
mock_gnbm.return_value = {'instance_id': 'OneTime',
|
controller_version = '2.1.5.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
|
mock_gnbl.return_value = {'instance_id': 'OneTime',
|
||||||
'is_next': drac_mgmt.ONE_TIME_BOOT}
|
'is_next': drac_mgmt.ONE_TIME_BOOT}
|
||||||
mock_we.side_effect = exception.DracClientError('E_FAKE')
|
mock_we.side_effect = exception.DracClientError('E_FAKE')
|
||||||
|
|
||||||
@ -247,18 +276,23 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
mock.ANY, resource_uris.DCIM_BootSourceSetting,
|
mock.ANY, resource_uris.DCIM_BootSourceSetting,
|
||||||
filter_query=mock.ANY)
|
filter_query=mock.ANY)
|
||||||
|
|
||||||
@mock.patch.object(drac_mgmt.DracManagement, 'get_boot_device',
|
@mock.patch.object(drac_mgmt, '_get_boot_device', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
spec_set=True, autospec=True)
|
spec_set=True, autospec=True)
|
||||||
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(drac_mgmt, '_create_config_job', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_create_config_job', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_set_boot_device(self, mock_ccj, mock_cfcj, mock_gbd,
|
def test_set_boot_device(self, mock_ccj, mock_cfcj, mock_glcv, mock_gbd,
|
||||||
mock_client_pywsman):
|
mock_client_pywsman):
|
||||||
|
controller_version = '2.1.5.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
||||||
'persistent': True}
|
'persistent': True}
|
||||||
result_xml_enum = test_utils.build_soap_xml(
|
result_xml_enum = test_utils.build_soap_xml(
|
||||||
[{'InstanceID': 'NIC'}], resource_uris.DCIM_BootSourceSetting)
|
[{'InstanceID': 'NIC', 'BootSourceType': 'IPL'}],
|
||||||
|
resource_uris.DCIM_BootSourceSetting)
|
||||||
result_xml_invk = test_utils.build_soap_xml(
|
result_xml_invk = test_utils.build_soap_xml(
|
||||||
[{'ReturnValue': drac_client.RET_SUCCESS}],
|
[{'ReturnValue': drac_client.RET_SUCCESS}],
|
||||||
resource_uris.DCIM_BootConfigSetting)
|
resource_uris.DCIM_BootConfigSetting)
|
||||||
@ -280,22 +314,28 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
mock_pywsman.invoke.assert_called_once_with(
|
mock_pywsman.invoke.assert_called_once_with(
|
||||||
mock.ANY, resource_uris.DCIM_BootConfigSetting,
|
mock.ANY, resource_uris.DCIM_BootConfigSetting,
|
||||||
'ChangeBootOrderByInstanceID', None)
|
'ChangeBootOrderByInstanceID', None)
|
||||||
mock_gbd.assert_called_once_with(self.driver, task)
|
mock_glcv.assert_called_once_with(self.node)
|
||||||
|
mock_gbd.assert_called_once_with(self.node, controller_version)
|
||||||
mock_cfcj.assert_called_once_with(self.node)
|
mock_cfcj.assert_called_once_with(self.node)
|
||||||
mock_ccj.assert_called_once_with(self.node)
|
mock_ccj.assert_called_once_with(self.node)
|
||||||
|
|
||||||
@mock.patch.object(drac_mgmt.DracManagement, 'get_boot_device',
|
@mock.patch.object(drac_mgmt, '_get_boot_device', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
spec_set=True, autospec=True)
|
spec_set=True, autospec=True)
|
||||||
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(drac_mgmt, '_create_config_job', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_create_config_job', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_set_boot_device_fail(self, mock_ccj, mock_cfcj, mock_gbd,
|
def test_set_boot_device_fail(self, mock_ccj, mock_cfcj, mock_glcv,
|
||||||
mock_client_pywsman):
|
mock_gbd, mock_client_pywsman):
|
||||||
|
controller_version = '2.1.5.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
||||||
'persistent': True}
|
'persistent': True}
|
||||||
result_xml_enum = test_utils.build_soap_xml(
|
result_xml_enum = test_utils.build_soap_xml(
|
||||||
[{'InstanceID': 'NIC'}], resource_uris.DCIM_BootSourceSetting)
|
[{'InstanceID': 'NIC', 'BootSourceType': 'IPL'}],
|
||||||
|
resource_uris.DCIM_BootSourceSetting)
|
||||||
result_xml_invk = test_utils.build_soap_xml(
|
result_xml_invk = test_utils.build_soap_xml(
|
||||||
[{'ReturnValue': drac_client.RET_ERROR, 'Message': 'E_FAKE'}],
|
[{'ReturnValue': drac_client.RET_ERROR, 'Message': 'E_FAKE'}],
|
||||||
resource_uris.DCIM_BootConfigSetting)
|
resource_uris.DCIM_BootConfigSetting)
|
||||||
@ -317,19 +357,24 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
mock_pywsman.invoke.assert_called_once_with(
|
mock_pywsman.invoke.assert_called_once_with(
|
||||||
mock.ANY, resource_uris.DCIM_BootConfigSetting,
|
mock.ANY, resource_uris.DCIM_BootConfigSetting,
|
||||||
'ChangeBootOrderByInstanceID', None)
|
'ChangeBootOrderByInstanceID', None)
|
||||||
mock_gbd.assert_called_once_with(self.driver, task)
|
mock_glcv.assert_called_once_with(self.node)
|
||||||
|
mock_gbd.assert_called_once_with(self.node, controller_version)
|
||||||
mock_cfcj.assert_called_once_with(self.node)
|
mock_cfcj.assert_called_once_with(self.node)
|
||||||
self.assertFalse(mock_ccj.called)
|
self.assertFalse(mock_ccj.called)
|
||||||
|
|
||||||
@mock.patch.object(drac_mgmt.DracManagement, 'get_boot_device',
|
@mock.patch.object(drac_mgmt, '_get_boot_device', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
spec_set=True, autospec=True)
|
spec_set=True, autospec=True)
|
||||||
@mock.patch.object(drac_client.Client, 'wsman_enumerate', spec_set=True,
|
@mock.patch.object(drac_client.Client, 'wsman_enumerate', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_set_boot_device_client_error(self, mock_cfcj, mock_we,
|
def test_set_boot_device_client_error(self, mock_cfcj, mock_we, mock_glcv,
|
||||||
mock_gbd,
|
mock_gbd,
|
||||||
mock_client_pywsman):
|
mock_client_pywsman):
|
||||||
|
controller_version = '2.1.5.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
||||||
'persistent': True}
|
'persistent': True}
|
||||||
mock_we.side_effect = exception.DracClientError('E_FAKE')
|
mock_we.side_effect = exception.DracClientError('E_FAKE')
|
||||||
@ -339,17 +384,22 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
self.assertRaises(exception.DracClientError,
|
self.assertRaises(exception.DracClientError,
|
||||||
self.driver.set_boot_device, task,
|
self.driver.set_boot_device, task,
|
||||||
boot_devices.PXE)
|
boot_devices.PXE)
|
||||||
mock_gbd.assert_called_once_with(self.driver, task)
|
mock_glcv.assert_called_once_with(self.node)
|
||||||
|
mock_gbd.assert_called_once_with(self.node, controller_version)
|
||||||
mock_we.assert_called_once_with(
|
mock_we.assert_called_once_with(
|
||||||
mock.ANY, resource_uris.DCIM_BootSourceSetting,
|
mock.ANY, resource_uris.DCIM_BootSourceSetting,
|
||||||
filter_query=mock.ANY)
|
filter_query=mock.ANY)
|
||||||
|
|
||||||
@mock.patch.object(drac_mgmt.DracManagement, 'get_boot_device',
|
@mock.patch.object(drac_mgmt, '_get_boot_device', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
spec_set=True, autospec=True)
|
spec_set=True, autospec=True)
|
||||||
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_set_boot_device_noop(self, mock_cfcj, mock_gbd,
|
def test_set_boot_device_noop(self, mock_cfcj, mock_glcv, mock_gbd,
|
||||||
mock_client_pywsman):
|
mock_client_pywsman):
|
||||||
|
controller_version = '2.1.5.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
||||||
'persistent': False}
|
'persistent': False}
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
@ -357,9 +407,53 @@ class DracManagementTestCase(db_base.DbTestCase):
|
|||||||
task.node = self.node
|
task.node = self.node
|
||||||
result = self.driver.set_boot_device(task, boot_devices.PXE)
|
result = self.driver.set_boot_device(task, boot_devices.PXE)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
mock_gbd.assert_called_once_with(self.driver, task)
|
mock_glcv.assert_called_once_with(self.node)
|
||||||
|
mock_gbd.assert_called_once_with(self.node, controller_version)
|
||||||
self.assertFalse(mock_cfcj.called)
|
self.assertFalse(mock_cfcj.called)
|
||||||
|
|
||||||
def test_get_sensors_data(self, mock_client_pywsman):
|
def test_get_sensors_data(self, mock_client_pywsman):
|
||||||
self.assertRaises(NotImplementedError,
|
self.assertRaises(NotImplementedError,
|
||||||
self.driver.get_sensors_data, self.task)
|
self.driver.get_sensors_data, self.task)
|
||||||
|
|
||||||
|
@mock.patch.object(drac_mgmt, '_get_boot_device', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(drac_mgmt, '_get_lifecycle_controller_version',
|
||||||
|
spec_set=True, autospec=True)
|
||||||
|
@mock.patch.object(drac_mgmt, '_check_for_config_job', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
@mock.patch.object(drac_mgmt, '_create_config_job', spec_set=True,
|
||||||
|
autospec=True)
|
||||||
|
def test_set_boot_device_11g(self, mock_ccj, mock_cfcj, mock_glcv,
|
||||||
|
mock_gbd, mock_client_pywsman):
|
||||||
|
controller_version = '1.5.0.0'
|
||||||
|
mock_glcv.return_value = controller_version
|
||||||
|
mock_gbd.return_value = {'boot_device': boot_devices.PXE,
|
||||||
|
'persistent': True}
|
||||||
|
result_xml_enum = test_utils.build_soap_xml(
|
||||||
|
[{'InstanceID': 'NIC'}],
|
||||||
|
resource_uris.DCIM_BootSourceSetting)
|
||||||
|
result_xml_invk = test_utils.build_soap_xml(
|
||||||
|
[{'ReturnValue': drac_client.RET_SUCCESS}],
|
||||||
|
resource_uris.DCIM_BootConfigSetting)
|
||||||
|
|
||||||
|
mock_xml_enum = test_utils.mock_wsman_root(result_xml_enum)
|
||||||
|
mock_xml_invk = test_utils.mock_wsman_root(result_xml_invk)
|
||||||
|
mock_pywsman = mock_client_pywsman.Client.return_value
|
||||||
|
mock_pywsman.enumerate.return_value = mock_xml_enum
|
||||||
|
mock_pywsman.invoke.return_value = mock_xml_invk
|
||||||
|
|
||||||
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
|
shared=False) as task:
|
||||||
|
task.node = self.node
|
||||||
|
result = self.driver.set_boot_device(task, boot_devices.PXE)
|
||||||
|
|
||||||
|
self.assertIsNone(result)
|
||||||
|
mock_pywsman.enumerate.assert_called_once_with(
|
||||||
|
mock.ANY, mock.ANY, resource_uris.DCIM_BootSourceSetting)
|
||||||
|
mock_pywsman.invoke.assert_called_once_with(
|
||||||
|
mock.ANY, resource_uris.DCIM_BootConfigSetting,
|
||||||
|
'ChangeBootOrderByInstanceID', None)
|
||||||
|
mock_glcv.assert_called_once_with(self.node)
|
||||||
|
mock_gbd.assert_called_once_with(self.node, controller_version)
|
||||||
|
mock_cfcj.assert_called_once_with(self.node)
|
||||||
|
mock_ccj.assert_called_once_with(self.node)
|
||||||
|
Loading…
Reference in New Issue
Block a user