Apply more granular timeout formatting
We don't need to wait forever if state changes aren't waiting or disable (which does a shutdown before returning).
This commit is contained in:
parent
87ec31c023
commit
21b4bbe51a
|
@ -377,13 +377,18 @@ def vm_state(config, vm, target_state, force=False, wait=False):
|
||||||
API arguments: state={state}, wait={wait}
|
API arguments: state={state}, wait={wait}
|
||||||
API schema: {"message":"{data}"}
|
API schema: {"message":"{data}"}
|
||||||
"""
|
"""
|
||||||
|
if wait or target_state == "disable":
|
||||||
|
timeout = 300
|
||||||
|
else:
|
||||||
|
timeout = 3
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
"state": target_state,
|
"state": target_state,
|
||||||
"force": str(force).lower(),
|
"force": str(force).lower(),
|
||||||
"wait": str(wait).lower(),
|
"wait": str(wait).lower(),
|
||||||
}
|
}
|
||||||
response = call_api(
|
response = call_api(
|
||||||
config, "post", "/vm/{vm}/state".format(vm=vm), params=params, timeout=120
|
config, "post", "/vm/{vm}/state".format(vm=vm), params=params, timeout=timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
|
Loading…
Reference in New Issue