Up timeout when setting VM state
Ensures the API won't time out immediately especially during a wait-flagged or disable action.
This commit is contained in:
		@@ -116,16 +116,20 @@ class ErrorResponse(requests.Response):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def call_api(
 | 
			
		||||
    config, operation, request_uri, headers={}, params=None, data=None, files=None
 | 
			
		||||
    config,
 | 
			
		||||
    operation,
 | 
			
		||||
    request_uri,
 | 
			
		||||
    headers={},
 | 
			
		||||
    params=None,
 | 
			
		||||
    data=None,
 | 
			
		||||
    files=None,
 | 
			
		||||
    timeout=3,
 | 
			
		||||
):
 | 
			
		||||
    # Craft the URI
 | 
			
		||||
    uri = "{}://{}{}{}".format(
 | 
			
		||||
        config["api_scheme"], config["api_host"], config["api_prefix"], request_uri
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # Default timeout is 3 seconds
 | 
			
		||||
    timeout = 3
 | 
			
		||||
 | 
			
		||||
    # Craft the authentication header if required
 | 
			
		||||
    if config["api_key"]:
 | 
			
		||||
        headers["X-Api-Key"] = config["api_key"]
 | 
			
		||||
 
 | 
			
		||||
@@ -382,7 +382,9 @@ def vm_state(config, vm, target_state, force=False, wait=False):
 | 
			
		||||
        "force": str(force).lower(),
 | 
			
		||||
        "wait": str(wait).lower(),
 | 
			
		||||
    }
 | 
			
		||||
    response = call_api(config, "post", "/vm/{vm}/state".format(vm=vm), params=params)
 | 
			
		||||
    response = call_api(
 | 
			
		||||
        config, "post", "/vm/{vm}/state".format(vm=vm), params=params, timeout=120
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    if response.status_code == 200:
 | 
			
		||||
        retstatus = True
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user