diff --git a/proliantutils/ilo/client.py b/proliantutils/ilo/client.py index 3d3ca9c..a13e92a 100644 --- a/proliantutils/ilo/client.py +++ b/proliantutils/ilo/client.py @@ -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') diff --git a/proliantutils/ilo/operations.py b/proliantutils/ilo/operations.py index 9d45c95..c9c8f7e 100644 --- a/proliantutils/ilo/operations.py +++ b/proliantutils/ilo/operations.py @@ -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) diff --git a/proliantutils/ilo/ris.py b/proliantutils/ilo/ris.py index 38da276..a5c111c 100755 --- a/proliantutils/ilo/ris.py +++ b/proliantutils/ilo/ris.py @@ -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. diff --git a/proliantutils/tests/ilo/ris_sample_outputs.py b/proliantutils/tests/ilo/ris_sample_outputs.py index 232eff7..f5c1599 100755 --- a/proliantutils/tests/ilo/ris_sample_outputs.py +++ b/proliantutils/tests/ilo/ris_sample_outputs.py @@ -1863,7 +1863,6 @@ GET_ISCSI_PATCH = """ { "iSCSIBootAttemptInstance": 1, "iSCSIBootAttemptName": "NicBoot1", - "iSCSIBootEnable": "Enabled", "iSCSIBootLUN": "1", "iSCSINicSource": "NicBoot1", "iSCSITargetIpAddress": "10.10.1.30", diff --git a/proliantutils/tests/ilo/test_client.py b/proliantutils/tests/ilo/test_client.py index 9a3a303..57930e0 100644 --- a/proliantutils/tests/ilo/test_client.py +++ b/proliantutils/tests/ilo/test_client.py @@ -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() diff --git a/proliantutils/tests/ilo/test_ris.py b/proliantutils/tests/ilo/test_ris.py index f70b3fb..e0f09f7 100755 --- a/proliantutils/tests/ilo/test_ris.py +++ b/proliantutils/tests/ilo/test_ris.py @@ -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