virtualbox.py 文件源码

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

项目:AerisCloud 作者: AerisCloud 项目源码 文件源码
def list_vms(running=False):
    """
    Return the list of VM in for the form name => uuid, when the running bool
    is set to true, only return running VMs
    :param running: bool
    :return: dict[str,str]
    """
    try:
        LIST_PARSER = re.compile(r'"(?P<name>[^"]+)" \{(?P<uuid>[^\}]+)\}')
        vms = {}
        list = running and 'runningvms' or 'vms'
        for line in VBoxManage('list', list, _iter=True):
            res = re.match(LIST_PARSER, line)
            if res:
                vms[res.group('name')] = res.group('uuid')
        return vms
    except CommandNotFound:
        return {}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号