From 54ac17df94d7892ba073823ee73bb2eb95787e89 Mon Sep 17 00:00:00 2001 From: Anusha Ramineni Date: Mon, 23 Feb 2015 15:17:38 +0530 Subject: [PATCH] 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 --- proliantutils/ilo/ribcl.py | 16 +++++ proliantutils/tests/ilo/constants.py | 88 +++++++++++++++++++++++++++ proliantutils/tests/ilo/test_ribcl.py | 24 ++++++++ 3 files changed, 128 insertions(+) diff --git a/proliantutils/ilo/ribcl.py b/proliantutils/ilo/ribcl.py index d210ef8..85edb77 100644 --- a/proliantutils/ilo/ribcl.py +++ b/proliantutils/ilo/ribcl.py @@ -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.""" diff --git a/proliantutils/tests/ilo/constants.py b/proliantutils/tests/ilo/constants.py index 77451b6..b0701f3 100644 --- a/proliantutils/tests/ilo/constants.py +++ b/proliantutils/tests/ilo/constants.py @@ -669,3 +669,91 @@ RESET_ILO_CREDENTIAL_FAIL_XML = """ /> """ + +GET_PERSISTENT_BOOT_DEVICE_HDD_UEFI_XML = """ + + + + + + + + + + + + + + + +""" + +GET_PERSISTENT_BOOT_DEVICE_NIC_UEFI_XML = """ + + + + + + + + + + + + + + + +""" + +GET_PERSISTENT_BOOT_DEVICE_BIOS_XML = """ + + + + + + + + + + + + + + + +""" diff --git a/proliantutils/tests/ilo/test_ribcl.py b/proliantutils/tests/ilo/test_ribcl.py index 78930f0..1734882 100644 --- a/proliantutils/tests/ilo/test_ribcl.py +++ b/proliantutils/tests/ilo/test_ribcl.py @@ -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):