main.py 文件源码

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

项目:sushy-tools 作者: openstack 项目源码 文件源码
def system_reset_action(identity):
    reset_type = flask.request.json.get('ResetType')
    with libvirt_open(LIBVIRT_URI) as conn:
        domain = get_libvirt_domain(conn, identity)
        try:
            if reset_type in ('On', 'ForceOn'):
                if not domain.isActive():
                    domain.create()
            elif reset_type == 'ForceOff':
                if domain.isActive():
                    domain.destroy()
            elif reset_type == 'GracefulShutdown':
                if domain.isActive():
                    domain.shutdown()
            elif reset_type == 'GracefulRestart':
                if domain.isActive():
                    domain.reboot()
            elif reset_type == 'ForceRestart':
                if domain.isActive():
                    domain.reset()
            elif reset_type == 'Nmi':
                if domain.isActive():
                    domain.injectNMI()
        except libvirt.libvirtError:
            flask.abort(500)

    return '', 204
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号