diff options
author | Claudiu Belu <cbelu@cloudbasesolutions.com> | 2020-09-18 19:07:52 +0300 |
---|---|---|
committer | Claudiu Belu <cbelu@cloudbasesolutions.com> | 2020-09-21 14:57:42 +0300 |
commit | 48123d63211a2446ddaf12f8ef692e3c67f09c7d (patch) | |
tree | 85eb01ee1cade217fd2c715b3a2a965d6ae84038 | |
parent | cf26d1863163a2dbdfaad012ffa4af7be827a0af (diff) | |
download | nova-48123d63211a2446ddaf12f8ef692e3c67f09c7d.tar.gz |
hyperv: Configures chassis asset tags for VMs.
The Msvm_VirtualSystemSettingData object associated with a VM has a
field named "ChassisAssetTag". The value set in this field is reflected
in Linux VMs in /sys/class/dmi/id/chassis-asset-tag. This value is
checked by cloud-init in order to figure out if it is currently running
inside an OpenStack VM.
The verification above has been introduced in cloud-init [1] in order to
avoid costly metadata probes that aren't needed in non-OpenStack VMs.
Setting the ChassisAssetTag will allow us to pass these checks. The
value we are setting is similar to what libvirt is setting in the
LibvirtConfigGuestSysinfo.
[1] https://github.com/canonical/cloud-init/commit/1efa8a0a030794cec68197100f31a856d0d264ab
Partially-Fixes: #1895976
Change-Id: Ibe6aff4edeb32208bc9865e9216a7432caddab2b
Depends-On: 33e6c07dab4b46442bf0fbb838d59516112899b9
-rw-r--r-- | nova/tests/unit/virt/hyperv/test_vmops.py | 5 | ||||
-rw-r--r-- | nova/virt/hyperv/vmops.py | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/nova/tests/unit/virt/hyperv/test_vmops.py b/nova/tests/unit/virt/hyperv/test_vmops.py index 6bd139d025..47e8d1dd48 100644 --- a/nova/tests/unit/virt/hyperv/test_vmops.py +++ b/nova/tests/unit/virt/hyperv/test_vmops.py @@ -533,6 +533,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): events = self._vmops._get_neutron_events(network_info) self.assertEqual([], events) + @mock.patch.object(vmops.version, 'product_string') @mock.patch.object(vmops.VMOps, '_attach_pci_devices') @mock.patch.object(vmops.VMOps, '_requires_secure_boot') @mock.patch.object(vmops.VMOps, '_requires_certificate') @@ -554,6 +555,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): mock_requires_certificate, mock_requires_secure_boot, mock_attach_pci_devices, + mock_product_string, enable_instance_metrics, vm_gen=constants.VM_GEN_1, vnuma_enabled=False, @@ -604,7 +606,8 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): mock_instance.name, mock_instance.flavor.memory_mb, mem_per_numa, mock_instance.flavor.vcpus, cpus_per_numa, CONF.hyperv.limit_cpu_features, dynamic_memory_ratio, - host_shutdown_action=host_shutdown_action) + host_shutdown_action=host_shutdown_action, + chassis_asset_tag=mock_product_string.return_value) mock_configure_remotefx.assert_called_once_with(mock_instance, vm_gen) mock_create_scsi_ctrl = self._vmops._vmutils.create_scsi_controller diff --git a/nova/virt/hyperv/vmops.py b/nova/virt/hyperv/vmops.py index 6b30a39211..169cebefa5 100644 --- a/nova/virt/hyperv/vmops.py +++ b/nova/virt/hyperv/vmops.py @@ -41,6 +41,7 @@ from nova import exception from nova.i18n import _ from nova import objects from nova.objects import fields +from nova import version from nova.virt import configdrive from nova.virt import hardware from nova.virt.hyperv import block_device_manager @@ -395,7 +396,8 @@ class VMOps(object): cpus_per_numa_node, CONF.hyperv.limit_cpu_features, dynamic_memory_ratio, - host_shutdown_action=host_shutdown_action) + host_shutdown_action=host_shutdown_action, + chassis_asset_tag=version.product_string()) self._configure_remotefx(instance, vm_gen) |