]> git.proxmox.com Git - pve-esxi-import-tools.git/commitdiff
listvms.py: actually don't use Path for the types
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 27 Mar 2024 09:27:17 +0000 (10:27 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 27 Mar 2024 09:27:17 +0000 (10:27 +0100)
we just want to pass whatever we get onward to perl & rust and not
place restrictions on it

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
listvms.py

index 90b27bfd71caded55055d9e151e7c1f0fc3ccad6..6981facc36f0ea95535c0be891a1ad19daf803ce 100755 (executable)
@@ -111,14 +111,14 @@ def connect_to_esxi_host(
 @dataclass
 class VmVmxInfo:
     datastore: str
-    path: Path
+    path: str
     checksum: str
 
 
 @dataclass
 class VmDiskInfo:
     datastore: str
-    path: Path
+    path: str
     capacity: int
 
 
@@ -139,10 +139,6 @@ def json_dump_helper(obj: Any) -> Any:
     if dataclasses.is_dataclass(obj):
         return dataclasses.asdict(obj)
 
-    match obj:
-        case Path():
-            return str(obj)
-
     raise TypeError(
         f"Can't make object of type {type(obj)} JSON-serializable: {repr(obj)}"
     )
@@ -171,11 +167,11 @@ def list_vms(service_instance: vim.ServiceInstance) -> list[vim.VirtualMachine]:
     return vms
 
 
-def parse_file_path(path) -> tuple[str, Path]:
+def parse_file_path(path) -> tuple[str, str]:
     """Parse a path of the form '[datastore] file/path'"""
     datastore_name, relative_path = path.split("] ", 1)
     datastore_name = datastore_name.strip("[")
-    return (datastore_name, Path(relative_path))
+    return (datastore_name, relative_path)
 
 
 def get_vm_vmx_info(vm: vim.VirtualMachine) -> VmVmxInfo: