libvirt_kvm.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:paws 作者: rhpit 项目源码 文件源码
def get_connection(self):
        """ Get connection with libvirt using QEMU driver and system
        context

        :return conn: connection with libvirt
        :rtype conn: libvirt connection
        """
        creds = self.args.credentials

        if 'username' in creds:
            auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT],
                    creds['username'], None]
            conn = libvirt.openAuth(creds['qemu_instance'], auth, 0)
        else:
            conn = libvirt.open(creds['qemu_instance'])

        if conn == None:
            LOG.error('Failed to open connection to %s',
                      creds['qemu_instance'])
            LOG.warn('check PAWS documentation %s' % LIBVIRT_AUTH_HELP)
            raise PawsPreTaskError

        LOG.debug("connected successfully to %s" % creds['qemu_instance'])

        return conn
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号