Add support to get iscsi initiator information
This commit adds support to get iscsi initiator information of iLO using RIS. Change-Id: I2040661c7cead33b06295f800661f436a98063c9
This commit is contained in:
parent
4ab023bfbe
commit
d6aa7eaf1b
|
@ -52,6 +52,7 @@ SUPPORTED_RIS_METHODS = [
|
|||
'set_secure_boot_mode',
|
||||
'set_iscsi_boot_info',
|
||||
'unset_iscsi_boot_info',
|
||||
'get_iscsi_initiator_info',
|
||||
'set_vm_status',
|
||||
'update_firmware',
|
||||
'update_persistent_boot',
|
||||
|
@ -299,6 +300,16 @@ class IloClient(operations.IloOperations):
|
|||
"""
|
||||
return self._call_method('unset_iscsi_boot_info', mac)
|
||||
|
||||
def get_iscsi_initiator_info(self):
|
||||
"""Returns iSCSI initiator information of iLO.
|
||||
|
||||
:returns: iSCSI initiator information.
|
||||
:raises: IloError, on an error from iLO.
|
||||
:raises: IloCommandNotSupportedInBiosError, if the system is
|
||||
in the bios boot mode.
|
||||
"""
|
||||
return self._call_method('get_iscsi_initiator_info')
|
||||
|
||||
def get_one_time_boot(self):
|
||||
"""Retrieves the current setting for the one time boot."""
|
||||
return self._call_method('get_one_time_boot')
|
||||
|
|
|
@ -96,6 +96,16 @@ class IloOperations(object):
|
|||
"""
|
||||
raise exception.IloCommandNotSupportedError(ERRMSG)
|
||||
|
||||
def get_iscsi_initiator_info(self):
|
||||
"""Give iSCSI initiator information of iLO.
|
||||
|
||||
:returns: iSCSI initiator information.
|
||||
: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)
|
||||
|
|
|
@ -957,6 +957,28 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
|
|||
msg = 'iscsi boot is not supported in the BIOS boot mode'
|
||||
raise exception.IloCommandNotSupportedInBiosError(msg)
|
||||
|
||||
def get_iscsi_initiator_info(self):
|
||||
"""Give iSCSI initiator information of iLO.
|
||||
|
||||
:returns: iSCSI initiator information.
|
||||
:raises: IloError, on an error from iLO.
|
||||
:raises: IloCommandNotSupportedError, if the system is
|
||||
in the bios boot mode.
|
||||
"""
|
||||
headers, bios_uri, bios_settings = self._check_bios_resource()
|
||||
if('links' in bios_settings and 'iScsi' in bios_settings['links']):
|
||||
iscsi_uri = bios_settings['links']['iScsi']['href']
|
||||
status, headers, iscsi_settings = self._rest_get(iscsi_uri)
|
||||
|
||||
if status != 200:
|
||||
msg = self._get_extended_error(iscsi_settings)
|
||||
raise exception.IloError(msg)
|
||||
return iscsi_settings['iSCSIInitiatorName']
|
||||
else:
|
||||
msg = ('"links/iScsi" section in bios '
|
||||
'does not exist')
|
||||
raise exception.IloCommandNotSupportedError(msg)
|
||||
|
||||
def get_current_boot_mode(self):
|
||||
"""Retrieves the current boot mode of the server.
|
||||
|
||||
|
|
|
@ -370,6 +370,11 @@ class IloClientTestCase(testtools.TestCase):
|
|||
'1', '10.10.1.23', '3260',
|
||||
'CHAP', 'user', 'password')
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
def test_get_iscsi_initiator_info(self, call_mock):
|
||||
self.client.get_iscsi_initiator_info()
|
||||
call_mock.assert_called_once_with('get_iscsi_initiator_info')
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
def test_unset_iscsi_boot_info(self, call_mock):
|
||||
self.client.unset_iscsi_boot_info('c456')
|
||||
|
|
|
@ -142,6 +142,47 @@ class IloRisTestCase(testtools.TestCase):
|
|||
self.client.unset_iscsi_boot_info, mac)
|
||||
_uefi_boot_mode_mock.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_rest_get')
|
||||
@mock.patch.object(ris.RISOperations, '_check_bios_resource')
|
||||
def test_get_iscsi_initiator_info(self, check_bios_mock,
|
||||
get_mock):
|
||||
bios_uri = '/rest/v1/systems/1/bios'
|
||||
settings = json.loads(ris_outputs.GET_BIOS_SETTINGS)
|
||||
check_bios_mock.return_value = (ris_outputs.GET_HEADERS,
|
||||
bios_uri, settings)
|
||||
iscsi_settings = json.loads(ris_outputs.GET_ISCSI_SETTINGS)
|
||||
get_mock.return_value = (200, ris_outputs.GET_HEADERS,
|
||||
iscsi_settings)
|
||||
ret = self.client.get_iscsi_initiator_info()
|
||||
self.assertEqual(ret, 'iqn.1986-03.com.hp:uefi-p89-mxq45006w5')
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_rest_get')
|
||||
@mock.patch.object(ris.RISOperations, '_check_bios_resource')
|
||||
def test_get_iscsi_initiator_info_failed(self, check_bios_mock,
|
||||
get_mock):
|
||||
bios_uri = '/rest/v1/systems/1/bios'
|
||||
settings = json.loads(ris_outputs.GET_BIOS_SETTINGS)
|
||||
check_bios_mock.return_value = (ris_outputs.GET_HEADERS,
|
||||
bios_uri, settings)
|
||||
iscsi_uri = '/rest/v1/systems/1/bios/iScsi'
|
||||
iscsi_settings = json.loads(ris_outputs.GET_ISCSI_SETTINGS)
|
||||
get_mock.return_value = (202, ris_outputs.GET_HEADERS,
|
||||
iscsi_settings)
|
||||
self.assertRaises(exception.IloError,
|
||||
self.client.get_iscsi_initiator_info)
|
||||
check_bios_mock.assert_called_once_with()
|
||||
get_mock.assert_called_once_with(iscsi_uri)
|
||||
|
||||
@mock.patch.object(ris.RISOperations, '_check_bios_resource')
|
||||
def test_get_iscsi_initiator_info_not_found(self, check_bios_mock):
|
||||
bios_uri = '/rest/v1/systems/1/bios'
|
||||
settings = json.loads(ris_outputs.GET_BASE_CONFIG)
|
||||
check_bios_mock.return_value = (ris_outputs.GET_HEADERS,
|
||||
bios_uri, settings)
|
||||
self.assertRaises(exception.IloCommandNotSupportedError,
|
||||
self.client.get_iscsi_initiator_info)
|
||||
check_bios_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