@staticmethod
def _connect(uri, read_only):
    auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_ECHOPROMPT, libvirt.VIR_CRED_REALM, libvirt.VIR_CRED_PASSPHRASE, libvirt.VIR_CRED_NOECHOPROMPT, libvirt.VIR_CRED_EXTERNAL], LibvirtDriver._connect_auth_cb, None]
    try:
        flags = 0
        if read_only:
            flags = libvirt.VIR_CONNECT_RO
        return tpool.proxy_call((libvirt.virDomain, libvirt.virConnect), libvirt.openAuth, uri, auth, flags)
    except libvirt.libvirtError as ex:
        LOG.exception(_LE('Connection to libvirt failed: %s'), ex)
        payload = dict(ip=LibvirtDriver.get_host_ip_addr(), method='_connect', reason=ex)
        rpc.get_notifier('compute').error(nova_context.get_admin_context(), 'compute.libvirt.error', payload)
        raise exception.HypervisorUnavailable(host=CONF.host)
@staticmethod
def _connect(uri, read_only):
    auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_ECHOPROMPT, libvirt.VIR_CRED_REALM, libvirt.VIR_CRED_PASSPHRASE, libvirt.VIR_CRED_NOECHOPROMPT, libvirt.VIR_CRED_EXTERNAL], LibvirtDriver._connect_auth_cb, None]
    try:
        flags = 0
        if read_only:
            flags = libvirt.VIR_CONNECT_RO
        return tpool.proxy_call((libvirt.virDomain, libvirt.virConnect), libvirt.openAuth, uri, auth, flags)
    except libvirt.libvirtError as ex:
        LOG.exception(_LE('Connection to libvirt failed: %s'), ex)
        payload = dict(ip=LibvirtDriver.get_host_ip_addr(), method='_connect', reason=ex)
        rpc.get_notifier('compute').error(nova_context.get_admin_context(), 'compute.libvirt.error', payload)
        raise exception.HypervisorUnavailable(host=CONF.host)