libvirt_utils.py 文件源码

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

项目:daisy 作者: opnfv 项目源码 文件源码
def reboot_vm(vm_name, boot_devs=None):
    LI('Begin to reboot VM %s', vm_name)
    conn = libvirt.open('qemu:///system')
    try:
        vm = conn.lookupByName(vm_name)
    except libvirt.libvirtError as e:
        LE(e)
        err_exit('VM %s is not found: ' % vm_name)

    if boot_devs:
        if vm.isActive():
            vm.destroy()
            LI('Destroy VM %s' % vm_name)

        root = ET.fromstring(vm.XMLDesc())
        LI('Modify the boot order %s' % boot_devs)
        modify_vm_boot_order(root, boot_devs)

        LI('Re-define and start the VM %s' % vm_name)
        vm.undefine()
        vm = conn.defineXML(ET.tostring(root))
        vm.create()
        vm.setAutostart(1)
    else:
        vm.reset()

    conn.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号