From 1cf8706a52409f7c91e09d2cde2fb8d6e5c6ae03 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 6 Nov 2021 04:15:10 -0400 Subject: [PATCH] Up timeout when setting VM state Ensures the API won't time out immediately especially during a wait-flagged or disable action. --- client-cli/pvc/cli_lib/common.py | 12 ++++++++---- client-cli/pvc/cli_lib/vm.py | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client-cli/pvc/cli_lib/common.py b/client-cli/pvc/cli_lib/common.py index fcba8d2c..dbdc954f 100644 --- a/client-cli/pvc/cli_lib/common.py +++ b/client-cli/pvc/cli_lib/common.py @@ -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"] diff --git a/client-cli/pvc/cli_lib/vm.py b/client-cli/pvc/cli_lib/vm.py index c8c75ad5..ba51fec0 100644 --- a/client-cli/pvc/cli_lib/vm.py +++ b/client-cli/pvc/cli_lib/vm.py @@ -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