From 3c9632b27423eeebbac5cc70d5de20a28bf5abc5 Mon Sep 17 00:00:00 2001 From: Olivier Hoareau Date: Mon, 8 Jun 2026 10:44:04 +0200 Subject: [PATCH 1/2] tools/update: use nested attribute to simplify code Signed-off-by: Olivier Hoareau --- lib/tools/tasks/update.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/tools/tasks/update.py b/lib/tools/tasks/update.py index 7117a35ac..433f2de1b 100644 --- a/lib/tools/tasks/update.py +++ b/lib/tools/tasks/update.py @@ -36,11 +36,10 @@ def update_pools(inventory: Inventory) -> None: pools.append(p) hosting_pool = inventory_hosts[host]["hosting_pool"] if hosting_pool is not None: - # we assume all hosts are nested, not only master if nested_hosts.get(hosting_pool) is not None: - nested_hosts[hosting_pool].extend(p.hosts) + nested_hosts[hosting_pool].extend([h for h in p.hosts if h.is_nested]) else: - nested_hosts[hosting_pool] = p.hosts + nested_hosts[hosting_pool] = [h for h in p.hosts if h.is_nested] except NotAMasterHostError: logger.warning(f"[{host}] Skipping: not a master host") From 6baaf5508203626f312ac6d2e0c3bf76b470e955 Mon Sep 17 00:00:00 2001 From: Olivier Hoareau Date: Mon, 8 Jun 2026 11:05:39 +0200 Subject: [PATCH 2/2] tools/update: use system-serial-number with dmidecode for nested hosts Sometimes, the command dmidecode with the dmi key `system-uuid` works with unexpected results (bits are shifted). For nested hosts, we need to use dmi key `system-serial-number`. Take a look at https://github.com/xcp-ng/xcp-ng-tests/pull/567#discussion_r3356172811 Signed-off-by: Olivier Hoareau --- lib/host.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/host.py b/lib/host.py index 7b7f78f40..a8a984933 100644 --- a/lib/host.py +++ b/lib/host.py @@ -481,26 +481,25 @@ def pool_has_vm(self, vm_uuid: str, vm_type: str = 'vm') -> bool: return self.xe('vm-list', {'uuid': vm_uuid}, minimal=True) == vm_uuid def get_system_uuid(self) -> str: - """Return system uuid of current host. + """Get system uuid of current host. - Intended for driving current host from its "parent host" in a **nested context**. + In case host is nested, it uses `system-serial-number` instead of `system-uuid`. - .. note:: - If the current host is nested, it means it is not a physical host. It is a VM living inside a real host.:: - - [PH: Physical Host] -> [VM: emulation of an XCP-ng host] -> [vm: a vm inside nested host] - | current working host | - - So we need system-uuid of current working host (`VM`) which is - the uuid seen in physical host's (`PH`) scope. + If command result is empty or None, it raises an Error. Performs the following command:: - dmidecode -s system-uuid + dmidecode -s [system-uuid|system-serial-number] ref: `dmidecode(8) __` """ - return self.ssh("dmidecode -s system-uuid").lower().strip() + # TODO: This workaround is tracked in XCPNG-2775 + dmi_key = "system-serial-number" if self.is_nested else "system-uuid" + system_uuid = self.ssh(f"dmidecode -s {dmi_key}").lower().strip() + if not system_uuid: + raise ValueError(f"The system uuid '{system_uuid}' is incorrect.") + + return system_uuid def yum_clean_metadata(self) -> str: """Quietly removes cached metadata on target.