Support to disable iscsi boot option in iLO
This commit adds changes to disable iscsi boot option in iLO. Change-Id: Ia8946e196002f51c0e00d6273b474d030671bc1a Closes-Bug: #1647537
This commit is contained in:
parent
dfff9e6564
commit
6364db9d72
|
@ -48,6 +48,7 @@ SUPPORTED_RIS_METHODS = [
|
|||
'set_secure_boot_mode',
|
||||
'get_server_capabilities',
|
||||
'set_iscsi_boot_info',
|
||||
'unset_iscsi_boot_info',
|
||||
'set_vm_status',
|
||||
'update_firmware',
|
||||
'update_persistent_boot',
|
||||
|
@ -141,6 +142,16 @@ class IloClient(operations.IloOperations):
|
|||
ip_address, port, auth_method, username,
|
||||
password)
|
||||
|
||||
def unset_iscsi_boot_info(self, mac):
|
||||
"""Disable iscsi boot option of the system in uefi boot mode.
|
||||
|
||||
:param mac: MAC address of initiator.
|
||||
:raises: IloError, on an error from iLO.
|
||||
:raises: IloCommandNotSupportedInBiosError, if the system is
|
||||
in the bios boot mode.
|
||||
"""
|
||||
return self._call_method('unset_iscsi_boot_info', mac)
|
||||
|
||||
def get_one_time_boot(self):
|
||||
"""Retrieves the current setting for the one time boot."""
|
||||
return self._call_method('get_one_time_boot')
|
||||
|
|
|
@ -86,6 +86,16 @@ class IloOperations(object):
|
|||
"""
|
||||
raise exception.IloCommandNotSupportedError(ERRMSG)
|
||||
|
||||
def unset_iscsi_boot_info(self, mac):
|
||||
"""Disable iscsi boot option of the system in uefi boot mode.
|
||||
|
||||
:param mac: MAC address of initiator.
|
||||
:raises: IloError, on an error from iLO.
|
||||
:raises: IloCommandNotSupportedError, if the system is
|
||||
in the bios boot mode.
|
||||
"""
|
||||
raise exception.IloCommandNotSupportedError(ERRMSG)
|
||||
|
||||
def get_one_time_boot(self):
|
||||
"""Retrieves the current setting for the one time boot."""
|
||||
raise exception.IloCommandNotSupportedError(ERRMSG)
|
||||
|
|
|
@ -623,7 +623,6 @@ class RISOperations(operations.IloOperations):
|
|||
iscsi_info['iSCSIBootAttemptName'] = nic
|
||||
iscsi_info['iSCSINicSource'] = nic
|
||||
iscsi_info['iSCSIBootAttemptInstance'] = 1
|
||||
iscsi_info['iSCSIBootEnable'] = 'Enabled'
|
||||
patch_data = {'iSCSIBootSources': [iscsi_info]}
|
||||
status, headers, response = self._rest_patch(iscsi_uri,
|
||||
None, patch_data)
|
||||
|
@ -903,6 +902,7 @@ class RISOperations(operations.IloOperations):
|
|||
iscsi_info['iSCSITargetIpAddress'] = ip_address
|
||||
iscsi_info['iSCSITargetTcpPort'] = int(port)
|
||||
iscsi_info['iSCSITargetInfoViaDHCP'] = False
|
||||
iscsi_info['iSCSIBootEnable'] = 'Enabled'
|
||||
if (auth_method == 'CHAP'):
|
||||
iscsi_info['iSCSIAuthenticationMethod'] = 'Chap'
|
||||
iscsi_info['iSCSIChapUsername'] = username
|
||||
|
@ -912,6 +912,21 @@ class RISOperations(operations.IloOperations):
|
|||
msg = 'iscsi boot is not supported in the BIOS boot mode'
|
||||
raise exception.IloCommandNotSupportedInBiosError(msg)
|
||||
|
||||
def unset_iscsi_boot_info(self, mac):
|
||||
"""Disable iscsi boot option in uefi boot mode.
|
||||
|
||||
:param mac: MAC address of initiator.
|
||||
:raises: IloError, on an error from iLO.
|
||||
:raises: IloCommandNotSupportedInBiosError, if the system is
|
||||
in the bios boot mode.
|
||||
"""
|
||||
if(self._is_boot_mode_uefi() is True):
|
||||
iscsi_info = {'iSCSIBootEnable': 'Disabled'}
|
||||
self._change_iscsi_settings(mac.upper(), iscsi_info)
|
||||
else:
|
||||
msg = 'iscsi boot is not supported in the BIOS boot mode'
|
||||
raise exception.IloCommandNotSupportedInBiosError(msg)
|
||||
|
||||
def get_current_boot_mode(self):
|
||||
"""Retrieves the current boot mode of the server.
|
||||
|
||||
|
|
|
@ -1863,7 +1863,6 @@ GET_ISCSI_PATCH = """
|
|||
{
|
||||
"iSCSIBootAttemptInstance": 1,
|
||||
"iSCSIBootAttemptName": "NicBoot1",
|
||||
"iSCSIBootEnable": "Enabled",
|
||||
"iSCSIBootLUN": "1",
|
||||
"iSCSINicSource": "NicBoot1",
|
||||
"iSCSITargetIpAddress": "10.10.1.30",
|
||||
|
|
|
@ -88,6 +88,11 @@ class IloClientTestCase(testtools.TestCase):
|
|||
'1', '10.10.1.23', '3260',
|
||||
'CHAP', 'user', 'password')
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
def test_unset_iscsi_boot_info(self, call_mock):
|
||||
self.client.unset_iscsi_boot_info('c456')
|
||||
call_mock.assert_called_once_with('unset_iscsi_boot_info', 'c456')
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
def test_get_product_name(self, call_mock):
|
||||
self.client.get_product_name()
|
||||
|
|
|
@ -111,6 +111,7 @@ class IloRisTestCase(testtools.TestCase):
|
|||
'iSCSITargetName': 'iqn.2011-07.com.example.server:test1',
|
||||
'iSCSITargetInfoViaDHCP': False,
|
||||
'iSCSIBootLUN': '1',
|
||||
'iSCSIBootEnable': 'Enabled',
|
||||
'iSCSITargetIpAddress': '10.10.1.30',
|
||||
'iSCSITargetTcpPort': 3260}
|
||||
self.client.set_iscsi_boot_info(
|
||||
|
@ -121,6 +122,25 @@ class IloRisTestCase(testtools.TestCase):
|
|||
change_iscsi_settings_mock.assert_called_once_with('C4346BB7EF30',
|
||||
iscsi_variables)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_change_iscsi_settings')
|
||||
@mock.patch.object(ris.RISOperations, '_is_boot_mode_uefi')
|
||||
def test_unset_iscsi_boot_info_uefi(self, _uefi_boot_mode_mock,
|
||||
change_iscsi_settings_mock):
|
||||
_uefi_boot_mode_mock.return_value = True
|
||||
iscsi_variables = {'iSCSIBootEnable': 'Disabled'}
|
||||
self.client.unset_iscsi_boot_info('C4346BB7EF30')
|
||||
_uefi_boot_mode_mock.assert_called_once_with()
|
||||
change_iscsi_settings_mock.assert_called_once_with('C4346BB7EF30',
|
||||
iscsi_variables)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_is_boot_mode_uefi')
|
||||
def test_unset_iscsi_boot_info_bios(self, _uefi_boot_mode_mock):
|
||||
_uefi_boot_mode_mock.return_value = False
|
||||
mac = 'C4346BB7EF30'
|
||||
self.assertRaises(exception.IloCommandNotSupportedInBiosError,
|
||||
self.client.unset_iscsi_boot_info, mac)
|
||||
_uefi_boot_mode_mock.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_is_boot_mode_uefi')
|
||||
def test_set_iscsi_boot_info_bios(self, _uefi_boot_mode_mock):
|
||||
_uefi_boot_mode_mock.return_value = False
|
||||
|
|
Loading…
Reference in New Issue