Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In case host is nested, it uses `system-serial-number` instead of `system-uuid`.
In case host is nested, it uses `system-serial-number` instead of `system-uuid`.
(TODO: This workaround is tracked in XCPNG-2775 )

(ideally prefer an upstream bug id if any exists)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


.. 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) <https://man.archlinux.org/man/dmidecode.8.en#s>__`
"""
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.
Expand Down
5 changes: 2 additions & 3 deletions lib/tools/tasks/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Loading