From 32a46037e9e50fd9f1f7740fff700c1d5b59b952 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Fri, 25 Sep 2020 23:54:17 -0700 Subject: [PATCH] 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: Ib9f605f68c79ff41d3959c7a1662a9e644fde946 Depends-On: 33e6c07dab4b46442bf0fbb838d59516112899b9 --- compute_hyperv/nova/vmops.py | 4 +++- compute_hyperv/tests/unit/test_vmops.py | 5 ++++- lower-constraints.txt | 2 +- requirements.txt | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compute_hyperv/nova/vmops.py b/compute_hyperv/nova/vmops.py index abc1f292..581d5d06 100644 --- a/compute_hyperv/nova/vmops.py +++ b/compute_hyperv/nova/vmops.py @@ -30,6 +30,7 @@ from nova import exception from nova import objects from nova.objects import fields from nova import utils +from nova import version from nova.virt import configdrive from nova.virt import event as virtevent from nova.virt import hardware @@ -470,7 +471,8 @@ class VMOps(object): dynamic_memory_ratio, configuration_root_dir=instance_path, host_shutdown_action=host_shutdown_action, - vnuma_enabled=vnuma_enabled) + vnuma_enabled=vnuma_enabled, + chassis_asset_tag=version.product_string()) self._set_instance_disk_qos_specs(instance, is_resize) self._attach_pci_devices(instance, is_resize) diff --git a/compute_hyperv/tests/unit/test_vmops.py b/compute_hyperv/tests/unit/test_vmops.py index 769e9d88..fa1ccefe 100644 --- a/compute_hyperv/tests/unit/test_vmops.py +++ b/compute_hyperv/tests/unit/test_vmops.py @@ -722,6 +722,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): mock_update_vm_resources.assert_called_once_with( mock_instance, mock.sentinel.vm_gen, mock.sentinel.image_meta) + @mock.patch.object(vmops.version, 'product_string') @mock.patch.object(vmops.VMOps, '_attach_pci_devices') @mock.patch.object(vmops.VMOps, '_set_instance_disk_qos_specs') @mock.patch.object(vmops.VMOps, '_get_instance_dynamic_memory_ratio') @@ -732,6 +733,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): mock_get_dynamic_memory_ratio, mock_set_qos_specs, mock_attach_pci_devices, + mock_product_string, pci_requests=None, instance_automatic_shutdown=False): self.flags(instance_automatic_shutdown=instance_automatic_shutdown, @@ -768,7 +770,8 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase): dynamic_memory_ratio, configuration_root_dir=mock.sentinel.instance_path, host_shutdown_action=host_shutdown_action, - vnuma_enabled=True) + vnuma_enabled=True, + chassis_asset_tag=mock_product_string.return_value) mock_set_qos_specs.assert_called_once_with(mock_instance, mock.sentinel.is_resize) mock_attach_pci_devices.assert_called_once_with( diff --git a/lower-constraints.txt b/lower-constraints.txt index 58efbdb4..f3c4065a 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -33,7 +33,7 @@ netifaces==0.10.6 openstackdocstheme==2.2.1 os-brick==2.2.0 os-client-config==1.29.0 -os-win==3.0.0 +os-win==5.2.0 oslo.concurrency==3.26.0 oslo.config==5.2.0 oslo.context==2.20.0 diff --git a/requirements.txt b/requirements.txt index 0dd938a9..34c1730b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 Babel!=2.4.0,>=2.3.4 # BSD os-brick>=2.2.0 # Apache-2.0 -os-win>=3.0.0 # Apache-2.0 +os-win>=5.2.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0 oslo.log>=3.36.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0