1. This will throw an error:
[...].lookupByUUID(machine_uuid)
2. This will work properly:
[...].lookupByUUID(machine_uuid.bytes)
Secondly, in the newest version of libvirt-python (12.5.0) the expected argument type of function lookupByUUID has been changed to str. This causes Python interpreter to highlight all occurrences of lookupByUUID and show errors:
Argument of type "bytes" cannot be assigned to parameter "uuid" of type "str" in function "lookupByUUID"
"bytes" is not assignable to "str"
Weirdly enough, no actual runtime error is thrown and the lookups work perfectly fine. However if the argument is actually casted to str the lookup fails with virDomainLookupByUUIDString() failed error.
More importantly - this change in the argument type makes absolutely no sense, since now the function lookupByUUID requires exactly the same argument as lookupByUUIDString - I suppose these functions were supposed to do different things but now they work exactly the same.
def lookupByUUID(self, uuid: "str") -> "virDomain":
"""Try to lookup a domain on the given hypervisor based on its UUID. """
ret = libvirtmod.virDomainLookupByUUID(self._o, uuid)
if ret is None:
raise libvirtError('virDomainLookupByUUID() failed')
__tmp = virDomain(self, _obj=ret)
return __tmp
def lookupByUUIDString(self, uuidstr: "str") -> "virDomain":
"""Try to lookup a domain on the given hypervisor based on its UUID
virDomainFree should be used to free the resources after the
domain object is no longer needed. """
ret = libvirtmod.virDomainLookupByUUIDString(self._o, uuidstr)
if ret is None:
raise libvirtError('virDomainLookupByUUIDString() failed')
__tmp = virDomain(self, _obj=ret)
return __tmp
Best regards, Krzysztoff