ILO: Update get_persistent_boot for UEFI
This commit is to add 'get_persistent_boot_device' function to return consistent data for both BIOS and UEFI boot mode. Change-Id: I4a32bef3efb3b404a45fd9434219028ac8251e08
This commit is contained in:
@@ -387,6 +387,22 @@ class RIBCLOperations(operations.IloOperations):
|
||||
if data is not None:
|
||||
return data['PERSISTENT_BOOT']['DEVICE']
|
||||
|
||||
def get_persistent_boot_device(self):
|
||||
"""Get the current persistent boot device set for the host."""
|
||||
result = self.get_persistent_boot()
|
||||
boot_mode = self._check_boot_mode(result)
|
||||
|
||||
if boot_mode == 'bios':
|
||||
return result[0]['value']
|
||||
|
||||
value = result[0]['DESCRIPTION']
|
||||
if 'NIC' in value:
|
||||
return 'NETWORK'
|
||||
elif self._isDisk(value):
|
||||
return 'HDD'
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_persistent_boot(self, values=[]):
|
||||
"""Configures a boot from a specific device."""
|
||||
|
||||
|
||||
@@ -669,3 +669,91 @@ RESET_ILO_CREDENTIAL_FAIL_XML = """
|
||||
/>
|
||||
</RIBCL>
|
||||
"""
|
||||
|
||||
GET_PERSISTENT_BOOT_DEVICE_HDD_UEFI_XML = """
|
||||
<?xml version="1.0"?>
|
||||
<RIBCL VERSION="2.23">
|
||||
<RESPONSE
|
||||
STATUS="0x0000"
|
||||
MESSAGE='No error'
|
||||
/>
|
||||
<PERSISTENT_BOOT>
|
||||
<DEVICE value="Boot0007"
|
||||
DESCRIPTION="Embedded SAS : Smart Array P830i Controller - 279.367 GB,
|
||||
RAID 1 Logical Drive(Target:0, Lun:0)"/>
|
||||
<DEVICE value="Boot000B"
|
||||
DESCRIPTION="iLO Virtual USB 2 : HP iLO Virtual USB CD/DVD ROM"/>
|
||||
<DEVICE value="Boot000A"
|
||||
DESCRIPTION="iLO Virtual USB 1 : HP iLO Virtual USB Key"/>
|
||||
<DEVICE value="Boot0009"
|
||||
DESCRIPTION="Embedded FlexibleLOM 1 Port 1 :HP Ethernet 1Gb
|
||||
4-port 331FLR Adapter - NIC (IPv4) "/>
|
||||
<DEVICE value="Boot0008"
|
||||
DESCRIPTION="Embedded FlexibleLOM 1 Port 1 :HP Ethernet 1Gb
|
||||
4-port 331FLR Adapter - NIC (IPv6) "/>
|
||||
</PERSISTENT_BOOT>
|
||||
</RIBCL>
|
||||
<?xml version="1.0"?>
|
||||
<RIBCL VERSION="2.23">
|
||||
<RESPONSE
|
||||
STATUS="0x0000"
|
||||
MESSAGE='No error'
|
||||
/>
|
||||
</RIBCL>
|
||||
"""
|
||||
|
||||
GET_PERSISTENT_BOOT_DEVICE_NIC_UEFI_XML = """
|
||||
<?xml version="1.0"?>
|
||||
<RIBCL VERSION="2.23">
|
||||
<RESPONSE
|
||||
STATUS="0x0000"
|
||||
MESSAGE='No error'
|
||||
/>
|
||||
<PERSISTENT_BOOT>
|
||||
<DEVICE value="Boot0009"
|
||||
DESCRIPTION="Embedded FlexibleLOM 1 Port 1 :HP Ethernet 1Gb
|
||||
4-port 331FLR Adapter - NIC (IPv4) "/>
|
||||
<DEVICE value="Boot0007"
|
||||
DESCRIPTION="Embedded SAS : Smart Array P830i Controller - 279.367 GB,
|
||||
RAID 1 Logical Drive(Target:0, Lun:0)"/>
|
||||
<DEVICE value="Boot000B"
|
||||
DESCRIPTION="iLO Virtual USB 2 : HP iLO Virtual USB CD/DVD ROM"/>
|
||||
<DEVICE value="Boot000A"
|
||||
DESCRIPTION="iLO Virtual USB 1 : HP iLO Virtual USB Key"/>
|
||||
<DEVICE value="Boot0008"
|
||||
DESCRIPTION="Embedded FlexibleLOM 1 Port 1 :HP Ethernet 1Gb
|
||||
4-port 331FLR Adapter - NIC (IPv6) "/>
|
||||
</PERSISTENT_BOOT>
|
||||
</RIBCL>
|
||||
<?xml version="1.0"?>
|
||||
<RIBCL VERSION="2.23">
|
||||
<RESPONSE
|
||||
STATUS="0x0000"
|
||||
MESSAGE='No error'
|
||||
/>
|
||||
</RIBCL>
|
||||
"""
|
||||
|
||||
GET_PERSISTENT_BOOT_DEVICE_BIOS_XML = """
|
||||
<?xml version="1.0"?>
|
||||
<RIBCL VERSION="2.23">
|
||||
<RESPONSE
|
||||
STATUS="0x0000"
|
||||
MESSAGE='No error'
|
||||
/>
|
||||
<PERSISTENT_BOOT>
|
||||
<DEVICE value="CDROM"/>
|
||||
<DEVICE value="NETWORK"/>
|
||||
<DEVICE value="USB"/>
|
||||
<DEVICE value="FLOPPY"/>
|
||||
<DEVICE value="HDD"/>
|
||||
</PERSISTENT_BOOT>
|
||||
</RIBCL>
|
||||
<?xml version="1.0"?>
|
||||
<RIBCL VERSION="2.23">
|
||||
<RESPONSE
|
||||
STATUS="0x0000"
|
||||
MESSAGE='No error'
|
||||
/>
|
||||
</RIBCL>
|
||||
"""
|
||||
|
||||
@@ -172,6 +172,30 @@ class IloRibclTestCase(unittest.TestCase):
|
||||
self.ilo.reset_ilo_credential, "fake")
|
||||
self.assertTrue(request_ilo_mock.called)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, '_request_ilo')
|
||||
def test_get_persistent_boot_device_HDD_uefi(self, request_ilo_mock):
|
||||
xml = constants.GET_PERSISTENT_BOOT_DEVICE_HDD_UEFI_XML
|
||||
request_ilo_mock.return_value = xml
|
||||
result = self.ilo.get_persistent_boot_device()
|
||||
self.assertEqual(result, 'HDD')
|
||||
self.assertTrue(request_ilo_mock.called)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, '_request_ilo')
|
||||
def test_get_persistent_boot_device_NIC_uefi(self, request_ilo_mock):
|
||||
xml = constants.GET_PERSISTENT_BOOT_DEVICE_NIC_UEFI_XML
|
||||
request_ilo_mock.return_value = xml
|
||||
result = self.ilo.get_persistent_boot_device()
|
||||
self.assertEqual(result, 'NETWORK')
|
||||
self.assertTrue(request_ilo_mock.called)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, '_request_ilo')
|
||||
def test_get_persistent_boot_device_bios(self, request_ilo_mock):
|
||||
xml = constants.GET_PERSISTENT_BOOT_DEVICE_BIOS_XML
|
||||
request_ilo_mock.return_value = xml
|
||||
result = self.ilo.get_persistent_boot_device()
|
||||
self.assertEqual(result, 'CDROM')
|
||||
self.assertTrue(request_ilo_mock.called)
|
||||
|
||||
|
||||
class IloRibclTestCaseBeforeRisSupport(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user