LibvirtClient.py 文件源码

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

项目:katprep 作者: stdevel 项目源码 文件源码
def get_vm_ips(self):
        """
        Returns a list of VMs and their IPs available through the current 
        connection.
        """
        try:
            #get all VMs
            vms = self.SESSION.listDefinedDomains()
            result = []

            #scan _all_ the VMs
            for vm in vms:
                #get VM and lookup hostname
                target_vm = self.SESSION.lookupByName(vm)
                target_hostname = target_vm.hostname()
                #lookup IP
                target_ip = socket.gethostbyname(target_hostname)
                result.append(
                    {"hostname": target_hostname, "ip": target_ip}
                )
            return result
        except libvirt.libvirtError as err:
            raise SessionException("Unable to get VM IP information: '{}'".format(err))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号