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
评论列表
文章目录