diff --git a/python/README.md b/python/README.md index 7146da6..fc5ff0e 100644 --- a/python/README.md +++ b/python/README.md @@ -62,6 +62,14 @@ set -a && source cluster.env && set +a > SSL verification is disabled by default to support environments that use > self-signed certificates. We recommend setting `ONTAP_VERIFY_SSL=true` > once CA-signed certificates are in place. +> +> The request timeout defaults to 30 seconds. Set `ONTAP_TIMEOUT` (in seconds) +> to adjust this for your environment: +> +> ```bash +> export ONTAP_TIMEOUT=10 # fail fast in CI +> export ONTAP_TIMEOUT=60 # allow extra time for slow clusters +> ``` --- diff --git a/python/ontap_client.py b/python/ontap_client.py index 1f9e41e..9a100af 100644 --- a/python/ontap_client.py +++ b/python/ontap_client.py @@ -110,7 +110,8 @@ def from_env(cls) -> OntapClient: Optional (with defaults): ``ONTAP_USER`` (default ``admin``), - ``ONTAP_VERIFY_SSL`` (default ``false``) + ``ONTAP_VERIFY_SSL`` (default ``false``), + ``ONTAP_TIMEOUT`` (default ``30`` seconds) """ host = os.environ.get("ONTAP_HOST", "") if not host: @@ -121,11 +122,14 @@ def from_env(cls) -> OntapClient: logger.error("ONTAP_PASS environment variable is required") sys.exit(1) + timeout = int(os.environ.get("ONTAP_TIMEOUT", str(_DEFAULT_TIMEOUT))) + return cls( host=host, username=os.environ.get("ONTAP_USER", "admin"), password=password, verify_ssl=os.environ.get("ONTAP_VERIFY_SSL", "false").lower() == "true", + timeout=timeout, ) # -- HTTP helpers -------------------------------------------------------