@@ -481,26 +481,25 @@ def pool_has_vm(self, vm_uuid: str, vm_type: str = 'vm') -> bool:
481481 return self .xe ('vm-list' , {'uuid' : vm_uuid }, minimal = True ) == vm_uuid
482482
483483 def get_system_uuid (self ) -> str :
484- """Return system uuid of current host.
484+ """Get system uuid of current host.
485485
486- Intended for driving current host from its "parent host" in a **nested context** .
486+ In case host is nested, it uses `system-serial-number` instead of `system-uuid` .
487487
488- .. note::
489- If the current host is nested, it means it is not a physical host. It is a VM living inside a real host.::
490-
491- [PH: Physical Host] -> [VM: emulation of an XCP-ng host] -> [vm: a vm inside nested host]
492- | current working host |
493-
494- So we need system-uuid of current working host (`VM`) which is
495- the uuid seen in physical host's (`PH`) scope.
488+ If command result is empty or None, it raises an Error.
496489
497490 Performs the following command::
498491
499- dmidecode -s system-uuid
492+ dmidecode -s [ system-uuid|system-serial-number]
500493
501494 ref: `dmidecode(8) <https://man.archlinux.org/man/dmidecode.8.en#s>__`
502495 """
503- return self .ssh ("dmidecode -s system-uuid" ).lower ().strip ()
496+ # TODO: This workaround is tracked in XCPNG-2775
497+ dmi_key = "system-serial-number" if self .is_nested else "system-uuid"
498+ system_uuid = self .ssh (f"dmidecode -s { dmi_key } " ).lower ().strip ()
499+ if not system_uuid :
500+ raise ValueError (f"The system uuid '{ system_uuid } ' is incorrect." )
501+
502+ return system_uuid
504503
505504 def yum_clean_metadata (self ) -> str :
506505 """Quietly removes cached metadata on target.
0 commit comments