virtualbox.py 文件源码

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

项目:AerisCloud 作者: AerisCloud 项目源码 文件源码
def vm_ip(name, id):
    """
    Return a running VMs IP for the given VM name and interface id,
    returns None if not running or the id does not exists
    :param name: str
    :param id: int
    :return: None|str
    """
    try:
        prop = '/VirtualBox/GuestInfo/Net/%d/V4/IP' % (id)
        value = str(VBoxManage('guestproperty', 'get',
                    name, prop))
        if value == 'No value set!':
            return None
        return value[7:].strip()
    except ErrorReturnCode_1 as e:
        # if the VM was not found
        if 'VBOX_E_OBJECT_NOT_FOUND' in e.stderr:
            raise VMNotFound(name)
        # something else happened, just let it go
        raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号