Skip to content

Commit c5a18ea

Browse files
committed
lib/host: add method to get system uuid
System uuid is the uuid of the host scoped into its physical parent host. It is used in a context of nested hosts. Signed-off-by: Olivier Hoareau <olivier.hoareau@vates.tech>
1 parent aa06890 commit c5a18ea

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

lib/host.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,31 @@ def pool_has_vm(self, vm_uuid: str, vm_type: str = 'vm') -> bool:
449449
else:
450450
return self.xe('vm-list', {'uuid': vm_uuid}, minimal=True) == vm_uuid
451451

452+
def get_system_uuid(self) -> str:
453+
"""Return system uuid of current host.
454+
455+
Intended for driving current host from its "parent host" in a **nested context**.
456+
457+
.. note::
458+
If the current host is nested, it means it is not a physical host. It is a VM living inside a real host.::
459+
460+
[PH: Physical Host] -> [VM: emulation of an XCP-ng host] -> [vm: a vm inside nested host]
461+
| current working host |
462+
463+
So we need system-uuid of current working host (`VM`) which is
464+
the uuid seen in physical host's (`PH`) scope.
465+
466+
Performs the following command::
467+
468+
dmidecode -s system-uuid
469+
470+
ref: `dmidecode(8) <https://man.archlinux.org/man/dmidecode.8.en#s>__`
471+
"""
472+
ssh_result = self.ssh_with_result("dmidecode -s system-uuid")
473+
system_uuid = str(ssh_result.stdout)
474+
475+
return system_uuid.lower().rstrip('\n')
476+
452477
def yum_clean_metadata(self) -> str:
453478
"""Quietly removes cached metadata on target.
454479

0 commit comments

Comments
 (0)