From 4279ee0622db5654cbbb7479cbcf21747b29780c Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Mon, 14 Oct 2019 18:54:31 +0200 Subject: [PATCH] Fix `BootSourceOverrideMode` enumeration Fixes one of the allowed values for ``BootSourceOverrideMode`` element - Redfish specification requires UEFI boot mode to be indicated as ``UEFI``, not ``Uefi`` as the dynamic Redfish emulator erroneously adopted. Change-Id: Ie7c743f27c005a92f500c17dcbb25320747cee4b --- doc/source/admin/emulator.conf | 2 +- .../notes/fix-boot-mode-constant-71e6a7ec6b010273.yaml | 7 +++++++ sushy_tools/emulator/resources/systems/base.py | 4 ++-- .../emulator/resources/systems/libvirtdriver.py | 10 +++++----- sushy_tools/emulator/resources/systems/novadriver.py | 6 +++--- .../unit/emulator/resources/systems/test_libvirt.py | 6 +++--- 6 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/fix-boot-mode-constant-71e6a7ec6b010273.yaml diff --git a/doc/source/admin/emulator.conf b/doc/source/admin/emulator.conf index c6d22eff..39c47a75 100644 --- a/doc/source/admin/emulator.conf +++ b/doc/source/admin/emulator.conf @@ -22,7 +22,7 @@ SUSHY_EMULATOR_LIBVIRT_URI = u'qemu:///system' # The map of firmware loaders dependant on the boot mode and # system architecture SUSHY_EMULATOR_BOOT_LOADER_MAP = { - u'Uefi': { + u'UEFI': { u'x86_64': u'/usr/share/OVMF/OVMF_CODE.fd', u'aarch64': u'/usr/share/AAVMF/AAVMF_CODE.fd' }, diff --git a/releasenotes/notes/fix-boot-mode-constant-71e6a7ec6b010273.yaml b/releasenotes/notes/fix-boot-mode-constant-71e6a7ec6b010273.yaml new file mode 100644 index 00000000..ca45929b --- /dev/null +++ b/releasenotes/notes/fix-boot-mode-constant-71e6a7ec6b010273.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes one of the allowed values for ``BootSourceOverrideMode`` + element - Redfish specification requires UEFI boot mode to be indicated + as ``UEFI``, not ``Uefi`` as the dynamic Redfish emulator erroneously + adopted. diff --git a/sushy_tools/emulator/resources/systems/base.py b/sushy_tools/emulator/resources/systems/base.py index bf7a4638..db40533d 100644 --- a/sushy_tools/emulator/resources/systems/base.py +++ b/sushy_tools/emulator/resources/systems/base.py @@ -103,7 +103,7 @@ class AbstractSystemsDriver(DriverBase): def get_boot_mode(self, identity): """Get computer system boot mode. - :returns: either *Uefi* or *Legacy* as `str` or `None` if + :returns: either *UEFI* or *Legacy* as `str` or `None` if current boot mode can't be determined """ @@ -111,7 +111,7 @@ class AbstractSystemsDriver(DriverBase): """Set computer system boot mode. :param boot_mode: string literal requesting boot mode - change on the system. Valid values are: *Uefi*, *Legacy*. + change on the system. Valid values are: *UEFI*, *Legacy*. :raises: `FishyError` if boot mode can't be set """ diff --git a/sushy_tools/emulator/resources/systems/libvirtdriver.py b/sushy_tools/emulator/resources/systems/libvirtdriver.py index e7fce7e0..fceff523 100644 --- a/sushy_tools/emulator/resources/systems/libvirtdriver.py +++ b/sushy_tools/emulator/resources/systems/libvirtdriver.py @@ -99,13 +99,13 @@ class LibvirtDriver(AbstractSystemsDriver): BOOT_MODE_MAP = { 'Legacy': 'rom', - 'Uefi': 'pflash' + 'UEFI': 'pflash' } BOOT_MODE_MAP_REV = {v: k for k, v in BOOT_MODE_MAP.items()} BOOT_LOADER_MAP = { - 'Uefi': { + 'UEFI': { 'x86_64': '/usr/share/OVMF/OVMF_CODE.fd', 'aarch64': '/usr/share/AAVMF/AAVMF_CODE.fd' }, @@ -441,7 +441,7 @@ class LibvirtDriver(AbstractSystemsDriver): def get_boot_mode(self, identity): """Get computer system boot mode. - :returns: either *Uefi* or *Legacy* as `str` or `None` if + :returns: either *UEFI* or *Legacy* as `str` or `None` if current boot mode can't be determined """ domain = self._get_domain(identity, readonly=True) @@ -462,7 +462,7 @@ class LibvirtDriver(AbstractSystemsDriver): """Set computer system boot mode. :param boot_mode: string literal requesting boot mode - change on the system. Valid values are: *Uefi*, *Legacy*. + change on the system. Valid values are: *UEFI*, *Legacy*. :raises: `error.FishyError` if boot mode can't be set """ @@ -785,7 +785,7 @@ class LibvirtDriver(AbstractSystemsDriver): inserted = (self.get_boot_device(identity) == constants.DEVICE_TYPE_CD) if inserted: - inserted = self.get_boot_mode(identity) == 'Uefi' + inserted = self.get_boot_mode(identity) == 'UEFI' return boot_image, read_only, inserted diff --git a/sushy_tools/emulator/resources/systems/novadriver.py b/sushy_tools/emulator/resources/systems/novadriver.py index 5dc02f96..c5fa45cd 100644 --- a/sushy_tools/emulator/resources/systems/novadriver.py +++ b/sushy_tools/emulator/resources/systems/novadriver.py @@ -47,7 +47,7 @@ class OpenStackDriver(AbstractSystemsDriver): BOOT_MODE_MAP = { 'Legacy': 'bios', - 'Uefi': 'uefi', + 'UEFI': 'uefi', } BOOT_MODE_MAP_REV = {v: k for k, v in BOOT_MODE_MAP.items()} @@ -246,7 +246,7 @@ class OpenStackDriver(AbstractSystemsDriver): def get_boot_mode(self, identity): """Get computer system boot mode. - :returns: either *Uefi* or *Legacy* as `str` or `None` if + :returns: either *UEFI* or *Legacy* as `str` or `None` if current boot mode can't be determined """ instance = self._get_instance(identity) @@ -261,7 +261,7 @@ class OpenStackDriver(AbstractSystemsDriver): """Set computer system boot mode. :param boot_mode: string literal requesting boot mode - change on the system. Valid values are: *Uefi*, *Legacy*. + change on the system. Valid values are: *UEFI*, *Legacy*. :raises: `error.FishyError` if boot mode can't be set """ diff --git a/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py b/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py index 1449e279..29c44250 100644 --- a/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py +++ b/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py @@ -282,7 +282,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data - self.test_driver.set_boot_mode(self.uuid, 'Uefi') + self.test_driver.set_boot_mode(self.uuid, 'UEFI') conn_mock = libvirt_rw_mock.return_value conn_mock.defineXML.assert_called_once_with(mock.ANY) @@ -297,7 +297,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data - self.test_driver.set_boot_mode(self.uuid, 'Uefi') + self.test_driver.set_boot_mode(self.uuid, 'UEFI') conn_mock = libvirt_rw_mock.return_value xml_document = conn_mock.defineXML.call_args[0][0] @@ -404,7 +404,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data - self.test_driver.set_boot_mode(self.uuid, 'Uefi') + self.test_driver.set_boot_mode(self.uuid, 'UEFI') conn_mock = libvirt_rw_mock.return_value xml_document = conn_mock.defineXML.call_args[0][0]