fix list_guest_directory for varying guest OS attributes
FileInfo attributes (owner, modificationTime, size, type) vary across guest OS types. Use getattr with defaults to prevent AttributeError when these optional fields are missing.
This commit is contained in:
parent
7918a78bfa
commit
d771db2e1d
@ -308,16 +308,17 @@ class GuestOpsMixin(MCPMixin):
|
|||||||
except vim.fault.FileNotFound:
|
except vim.fault.FileNotFound:
|
||||||
raise ValueError(f"Directory not found: {guest_path}") from None
|
raise ValueError(f"Directory not found: {guest_path}") from None
|
||||||
|
|
||||||
return [
|
results = []
|
||||||
{
|
for f in listing.files:
|
||||||
|
mod_time = getattr(f, "modificationTime", None)
|
||||||
|
results.append({
|
||||||
"name": f.path,
|
"name": f.path,
|
||||||
"size": f.size,
|
"size": getattr(f, "size", None),
|
||||||
"type": f.type,
|
"type": getattr(f, "type", None),
|
||||||
"owner": f.owner,
|
"owner": getattr(f, "owner", None),
|
||||||
"modified": f.modificationTime.isoformat() if f.modificationTime else None,
|
"modified": mod_time.isoformat() if mod_time else None,
|
||||||
}
|
})
|
||||||
for f in listing.files
|
return results
|
||||||
]
|
|
||||||
|
|
||||||
@mcp_tool(
|
@mcp_tool(
|
||||||
name="create_guest_directory",
|
name="create_guest_directory",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user