Merge "libvirt: Report secure boot support to scheduler"

This commit is contained in:
Zuul 2021-03-16 11:47:43 +00:00 committed by Gerrit Code Review
commit 27521c8106
2 changed files with 27 additions and 2 deletions

View File

@ -864,6 +864,21 @@ class LibvirtConnTestCase(test.NoDBTestCase,
"'swtpm_enabled=True'"
)
@mock.patch.object(
libvirt_driver.LibvirtDriver, '_register_instance_machine_type',
new=mock.Mock())
@mock.patch.object(
host.Host, 'supports_secure_boot', new_callable=mock.PropertyMock)
def test_driver_capabilities_secure_boot(self, mock_supports):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
drvr.init_host("dummyhost")
self.assertTrue(
drvr.capabilities['supports_secure_boot'],
"Driver capabilities for 'supports_secure_boot' is invalid when "
"host should support this feature"
)
mock_supports.assert_called_once_with()
def test_driver_raises_on_non_linux_platform(self):
with utils.temporary_mutation(sys, platform='darwin'):
self.assertRaises(
@ -2447,8 +2462,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
test_init_host()
# NOTE(dkliban): Will fail if get_host_capabilities is called before
# registerErrorHandler
self.assertEqual(['fake_registerErrorHandler',
'fake_get_host_capabilities'], calls)
self.assertEqual('fake_registerErrorHandler', calls[0])
self.assertEqual('fake_get_host_capabilities', calls[1])
def test_sanitize_log_to_xml(self):
# setup fake data

View File

@ -688,6 +688,8 @@ class LibvirtDriver(driver.ComputeDriver):
def init_host(self, host):
self._host.initialize()
self._update_host_specific_capabilities()
self._check_cpu_set_configuration()
self._do_quality_warnings()
@ -785,6 +787,14 @@ class LibvirtDriver(driver.ComputeDriver):
self._register_instance_machine_type()
def _update_host_specific_capabilities(self) -> None:
"""Update driver capabilities based on capabilities of the host."""
# TODO(stephenfin): We should also be reporting e.g. SEV functionality
# or UEFI bootloader support in this manner
self.capabilities.update({
'supports_secure_boot': self._host.supports_secure_boot,
})
def _register_instance_machine_type(self):
"""Register the machine type of instances on this host