1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(instances): Guest Info fits the tab, reads odd agent answers and says when usage is unknown

Audit and review (Codex, agy) of the file system list:
- the table had a side margin on a full-width table and ran past the tab's
  edge (on a phone its Used column was cut off); it now sits in a box that
  scrolls a long mount point, and on a phone the labels above it wrap by word;
- an agent answer that is not a list, an entry that is not an object, a
  negative, boolean or oversized size, or a null mount point or type no longer
  fails the tab or shows "None"; a "filesystems" key of another command is not
  taken for the list; the total is the whole file system's when the agent
  tells it (total-bytes-privileged), so used no longer passes it;
- when the agent does not give the file systems, a note says so;
- Turkish labels: "Kernel Version" was "Çekirdek Sürümü" like "Kernel Release",
  "OS Pretty-Name" read as a short name, "Timezone / Offset" as a location;
- the bulk migration live test's name no longer claims two at once, which its
  unit test checks.
This commit is contained in:
catborise 2026-11-20 10:11:54 +03:00
parent 10607a7063
commit 79f3b906dd
10 changed files with 249 additions and 214 deletions

View file

@ -790,19 +790,29 @@ class wvmInstance(wvmConnect):
for command in ("guest-get-timezone", "guest-get-host-name"):
with contextlib.suppress(libvirtError):
info.update(agent_command(self.instance, command))
info.pop("filesystems", None) # only guest_filesystems' own
with contextlib.suppress(libvirtError):
info["filesystems"] = self.guest_filesystems()
return info
def guest_filesystems(self):
"""The guest's mounted file systems the agent gives both sizes of (not
pseudo ones), by mount point: [{"mountpoint", "type", "used", "total"}], bytes."""
pseudo ones), by mount point: [{"mountpoint", "type", "used", "total"}], bytes.
The total is the whole file system's when the agent tells it (total-bytes-privileged),
root's reserved space included; an entry the agent garbles is left out."""
def size(value): # a uint64 of the agent's, not a bool
return value if type(value) is int and 0 <= value < 2**64 else None
answer = agent_command(self.instance, "guest-get-fsinfo")
filesystems = []
for fs in agent_command(self.instance, "guest-get-fsinfo") or []:
used, total = (fs or {}).get("used-bytes"), (fs or {}).get("total-bytes")
if isinstance(used, int) and isinstance(total, int) and total > 0:
filesystems.append({"mountpoint": str(fs.get("mountpoint", "")), "type": str(fs.get("type", "")),
"used": used, "total": total})
for fs in answer if isinstance(answer, list) else []:
if not isinstance(fs, dict):
continue
used, total = size(fs.get("used-bytes")), size(fs.get("total-bytes-privileged")) or size(fs.get("total-bytes"))
mountpoint = fs.get("mountpoint")
if used is not None and total and isinstance(mountpoint, str) and mountpoint:
filesystems.append({"mountpoint": mountpoint, "type": str(fs.get("type") or ""), "used": used,
"total": total})
return sorted(filesystems, key=lambda fs: fs["mountpoint"])
def start(self, flags=0):