Perform automatic shutdown/stop on VM disable
Instead of requiring the VM to already be stopped, instead allow disable state changes to perform a shutdown first. Also add a force option which will do a hard stop instead of a shutdown. References #148
This commit is contained in:
@ -1868,6 +1868,7 @@ class API_VM_State(Resource):
|
||||
"helptext": "A valid state must be specified",
|
||||
"required": True,
|
||||
},
|
||||
{"name": "force"},
|
||||
{"name": "wait"},
|
||||
]
|
||||
)
|
||||
@ -1890,6 +1891,10 @@ class API_VM_State(Resource):
|
||||
- stop
|
||||
- restart
|
||||
- disable
|
||||
- in: query
|
||||
name: force
|
||||
type: boolean
|
||||
description: Whether to force stop instead of shutdown VM during disable
|
||||
- in: query
|
||||
name: wait
|
||||
type: boolean
|
||||
@ -1907,6 +1912,7 @@ class API_VM_State(Resource):
|
||||
id: Message
|
||||
"""
|
||||
state = reqargs.get("state", None)
|
||||
force = bool(strtobool(reqargs.get("force", "false")))
|
||||
wait = bool(strtobool(reqargs.get("wait", "false")))
|
||||
|
||||
if state == "start":
|
||||
@ -1918,7 +1924,7 @@ class API_VM_State(Resource):
|
||||
if state == "restart":
|
||||
return api_helper.vm_restart(vm, wait)
|
||||
if state == "disable":
|
||||
return api_helper.vm_disable(vm)
|
||||
return api_helper.vm_disable(vm, force)
|
||||
abort(400)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user