Product SiteDocumentation Site

3.4.7. getURI

The getURI method can be used to obtain the URI for the current connection. While this is typically the same string that was passed into the open call, the underlying driver can sometimes canonicalize the string. This method will return the canonical version. If successful, it returns a URI string. If an error occurred, None will be returned instead. The following code demonstrates the use of getURI:

Example 3.18. Using virConnectGetURI

#!/usr/bin/env python3
import sys
import libvirt

conn = None
    conn ="qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)

uri = conn.getURI()
print('Canonical URI: '+uri)