VMware: add support for different firmwares
Add support for explicitly requiring UEFI or BIOS firmware from images by taking hw_firmware_type metadata into account. blueprint vmware-boot-uefi Change-Id: Ibfb57c55569e430a846003472a49a536e94e6a48
This commit is contained in:
parent
fa3f2e4796
commit
fc0c6d2f9a
@ -874,6 +874,48 @@ class VMwareVMUtilTestCase(test.NoDBTestCase):
|
||||
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_get_vm_create_spec_with_firmware(self):
|
||||
extra_specs = vm_util.ExtraSpecs(firmware='efi')
|
||||
fake_factory = fake.FakeFactory()
|
||||
result = vm_util.get_vm_create_spec(fake_factory,
|
||||
self._instance,
|
||||
'fake-datastore', [],
|
||||
extra_specs)
|
||||
expected = fake_factory.create('ns0:VirtualMachineConfigSpec')
|
||||
expected.name = self._instance.uuid
|
||||
expected.instanceUuid = self._instance.uuid
|
||||
expected.deviceChange = []
|
||||
expected.numCPUs = 2
|
||||
|
||||
expected.version = None
|
||||
expected.memoryMB = 2048
|
||||
expected.guestId = 'otherGuest'
|
||||
expected.firmware = 'efi'
|
||||
expected.extraConfig = []
|
||||
|
||||
extra_config = fake_factory.create("ns0:OptionValue")
|
||||
extra_config.value = self._instance.uuid
|
||||
extra_config.key = 'nvp.vm-uuid'
|
||||
expected.extraConfig.append(extra_config)
|
||||
extra_config = fake_factory.create("ns0:OptionValue")
|
||||
extra_config.value = True
|
||||
extra_config.key = 'disk.EnableUUID'
|
||||
expected.extraConfig.append(extra_config)
|
||||
expected.files = fake_factory.create('ns0:VirtualMachineFileInfo')
|
||||
expected.files.vmPathName = '[fake-datastore]'
|
||||
|
||||
expected.managedBy = fake_factory.create('ns0:ManagedByInfo')
|
||||
expected.managedBy.extensionKey = 'org.openstack.compute'
|
||||
expected.managedBy.type = 'instance'
|
||||
|
||||
expected.tools = fake_factory.create('ns0:ToolsConfigInfo')
|
||||
expected.tools.afterPowerOn = True
|
||||
expected.tools.afterResume = True
|
||||
expected.tools.beforeGuestReboot = True
|
||||
expected.tools.beforeGuestShutdown = True
|
||||
expected.tools.beforeGuestStandby = True
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_create_vm(self):
|
||||
|
||||
def fake_call_method(module, method, *args, **kwargs):
|
||||
|
@ -92,7 +92,7 @@ class ExtraSpecs(object):
|
||||
def __init__(self, cpu_limits=None, hw_version=None,
|
||||
storage_policy=None, cores_per_socket=None,
|
||||
memory_limits=None, disk_io_limits=None,
|
||||
vif_limits=None):
|
||||
vif_limits=None, firmware=None):
|
||||
"""ExtraSpecs object holds extra_specs for the instance."""
|
||||
self.cpu_limits = cpu_limits or Limits()
|
||||
self.memory_limits = memory_limits or Limits()
|
||||
@ -101,6 +101,7 @@ class ExtraSpecs(object):
|
||||
self.hw_version = hw_version
|
||||
self.storage_policy = storage_policy
|
||||
self.cores_per_socket = cores_per_socket
|
||||
self.firmware = firmware
|
||||
|
||||
|
||||
def vm_refs_cache_reset():
|
||||
@ -243,6 +244,9 @@ def get_vm_create_spec(client_factory, instance, data_store_name,
|
||||
client_factory, extra_specs.memory_limits,
|
||||
'ns0:ResourceAllocationInfo')
|
||||
|
||||
if extra_specs.firmware:
|
||||
config_spec.firmware = extra_specs.firmware
|
||||
|
||||
devices = []
|
||||
for vif_info in vif_infos:
|
||||
vif_spec = _create_vif_spec(client_factory, vif_info,
|
||||
|
@ -46,6 +46,7 @@ from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova import network
|
||||
from nova import objects
|
||||
from nova.objects import fields
|
||||
from nova import utils
|
||||
from nova import version
|
||||
from nova.virt import configdrive
|
||||
@ -317,6 +318,11 @@ class VMwareVMOps(object):
|
||||
extra_specs.memory_limits.validate()
|
||||
extra_specs.disk_io_limits.validate()
|
||||
extra_specs.vif_limits.validate()
|
||||
hw_firmware_type = image_meta.properties.get('hw_firmware_type')
|
||||
if hw_firmware_type == fields.FirmwareType.UEFI:
|
||||
extra_specs.firmware = 'efi'
|
||||
elif hw_firmware_type == fields.FirmwareType.BIOS:
|
||||
extra_specs.firmware = 'bios'
|
||||
hw_version = flavor.extra_specs.get('vmware:hw_version')
|
||||
extra_specs.hw_version = hw_version
|
||||
if CONF.vmware.pbm_enabled:
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The VMware vCenter compute driver now supports booting from images
|
||||
which specify they require UEFI or BIOS firmware, using the
|
||||
``hw_firmware_type`` image metadata.
|
Loading…
Reference in New Issue
Block a user