From 2b73438e795f7a45d34c4df764bcfc178469b79c Mon Sep 17 00:00:00 2001 From: "Martin, Paul" Date: Thu, 22 Feb 2024 17:04:42 +0000 Subject: [PATCH 1/4] added configurable timout value to setup and initialization --- PyU4V.conf.example | 3 ++- PyU4V/rest_requests.py | 7 +++++-- PyU4V/univmax_conn.py | 11 +++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/PyU4V.conf.example b/PyU4V.conf.example index 4a779a58..4efe21c4 100644 --- a/PyU4V.conf.example +++ b/PyU4V.conf.example @@ -9,7 +9,8 @@ array=00012345678 ; remote_array=00012345679 ; verify=True verify=/path-to-file/server_hostname.pem - +;overrides default timeout on REST calls for specificed value in seconds +;timeout=500 ; log configuration [loggers] keys=root,PyU4V diff --git a/PyU4V/rest_requests.py b/PyU4V/rest_requests.py index 1b4c4714..d8c0d4bf 100644 --- a/PyU4V/rest_requests.py +++ b/PyU4V/rest_requests.py @@ -51,7 +51,7 @@ class RestRequests(object): """RestRequests.""" def __init__(self, username, password, verify, base_url, interval, retries, - application_type=None, proxies=None): + application_type=None, proxies=None, timeout=None): """__init__.""" self.username = username self.password = password @@ -61,12 +61,15 @@ def __init__(self, username, password, verify, base_url, interval, retries, ACCEPT: APP_JSON, USER_AGENT: ua_details, APP_TYPE: application_type} - self.timeout = 120 + # if timeout is not none set self.timeout to timeout + # value or set to 120 + self.timeout = timeout or 120 self.interval = interval self.proxies = proxies self.retries = retries self.session = self.establish_rest_session() + def establish_rest_session(self, headers=None): """Establish a REST session. diff --git a/PyU4V/univmax_conn.py b/PyU4V/univmax_conn.py index e31ddd05..e601c5ac 100644 --- a/PyU4V/univmax_conn.py +++ b/PyU4V/univmax_conn.py @@ -61,12 +61,13 @@ def __init__(self, username=None, password=None, server_ip=None, u4v_version=constants.UNISPHERE_VERSION, interval=5, retries=200, array_id=None, application_type=app_type, remote_array=None, - remote_array_2=None, proxies=None): + remote_array_2=None, proxies=None, timeout=None): """__init__.""" config = config_handler.set_logger_and_config(file_path) self.end_date = int(round(time.time() * 1000)) self.start_date = (self.end_date - 3600000) self.array_id = array_id + self.timeout = timeout if timeout is not None else 120 # Set array ID if not self.array_id: try: @@ -96,6 +97,9 @@ def __init__(self, username=None, password=None, server_ip=None, self.remote_array_2 = config.get(SETUP, R_ARRAY_2) else: self.remote_array_2 = None + if config.has_option(SETUP, 'timeout') and timeout is None: + self.timeout = int(config.get(SETUP, 'timeout')) + # Set verification if verify is None: @@ -112,13 +116,12 @@ def __init__(self, username=None, password=None, server_ip=None, # Initialise REST session base_url = f'https://{server_ip}:{port}/univmax/restapi' enhanced_api_url = f'https://{server_ip}:{port}/univmax/rest' - self.rest_client = RestRequests( username, password, verify, base_url, interval, retries, - application_type, proxies=proxies) + application_type, proxies=proxies, timeout=self.timeout) self.enhanced_rest_client = RestRequests( username, password, verify, enhanced_api_url, interval, retries, - application_type, proxies=proxies) + application_type, proxies=proxies, timeout=self.timeout) self.request = self.rest_client.rest_request self.common = CommonFunctions(self.rest_client) self.validate_unisphere() From dd86b303c4b207fa8df3766d8073e6cf939ce61f Mon Sep 17 00:00:00 2001 From: "Martin, Paul" Date: Fri, 23 Feb 2024 09:37:52 +0000 Subject: [PATCH 2/4] incremented version to 10.1.2 --- ChangeLog | 5 +++++ PyU4V/__init__.py | 2 +- PyU4V/utils/constants.py | 2 +- README.rst | 2 +- docs/source/conf.py | 2 +- docs/source/index.rst | 2 +- docs/source/installation.rst | 2 +- index.rst | 6 +++--- setup.py | 2 +- 9 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8217ffcb..5804b374 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ PyU4V Change Log ================ +Version 10.1.0.2 and backport to Version 10.0.0.20 +==================================== +added timeout parameter to connection to make configurable. PyU4V.conf also +can take new setup value for timeout to override 120s value. + Version 10.1.0.1 ==================================== Bug fix for Github Issue #174 restart_unisphere_application has wrong payload. diff --git a/PyU4V/__init__.py b/PyU4V/__init__.py index a04d39fc..05ce05dd 100644 --- a/PyU4V/__init__.py +++ b/PyU4V/__init__.py @@ -23,7 +23,7 @@ from .univmax_conn import U4VConn # noqa: F401 __title__ = 'pyu4v' -__version__ = '10.1.0.1' +__version__ = '10.1.0.2' __author__ = 'Dell EMC or its subsidiaries' __license__ = 'Apache 2.0' __copyright__ = 'Copyright 2021 Dell EMC Inc' diff --git a/PyU4V/utils/constants.py b/PyU4V/utils/constants.py index a37abc0f..68da2d77 100644 --- a/PyU4V/utils/constants.py +++ b/PyU4V/utils/constants.py @@ -39,7 +39,7 @@ APP_MPART = 'multipart/form-data' # Unisphere REST URI constants -PYU4V_VERSION = '10.1.0.1' +PYU4V_VERSION = '10.1.0.2' UNISPHERE_VERSION = '101' ENHANCED_API_VERSION = 'v1' UCODE_6079 = '6079' diff --git a/README.rst b/README.rst index 2472fa1e..dd10b2be 100644 --- a/README.rst +++ b/README.rst @@ -26,7 +26,7 @@ PyU4V Version 10.1 +-------------------------------+----------------------------+ | **Author** | Dell EMC | +-------------------------------+----------------------------+ -| **PyU4V Version** | 10.1.0.1 | +| **PyU4V Version** | 10.1.0.2 | +-------------------------------+----------------------------+ | **Minimum Unisphere Version** | 10.1.0.0 | +-------------------------------+----------------------------+ diff --git a/docs/source/conf.py b/docs/source/conf.py index 853d5161..491ed403 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -26,7 +26,7 @@ # The short X.Y version. version = u'10.1' # The full version, including alpha/beta/rc tags -release = '10.1.0.1' +release = '10.1.0.2' # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: diff --git a/docs/source/index.rst b/docs/source/index.rst index faaa1de9..4e5df13a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -35,7 +35,7 @@ Supported PyU4V Versions ------------------------ +-------------------------------+----------------------------------------+ -| **PyU4V Version** | 10.1.0.1 | +| **PyU4V Version** | 10.1.0.2 | +-------------------------------+----------------------------------------+ | **Minimum Unisphere Version** | 10.1 | +-------------------------------+----------------------------------------+ diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 43c673bf..9eb07157 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -5,7 +5,7 @@ Requirements ------------ +-------------------------------+----------------------------------------+ -| **PyU4V Version** | 10.1.0.1 | +| **PyU4V Version** | 10.1.0.2 | +-------------------------------+----------------------------------------+ | **Minimum Unisphere Version** | 10.1 | +-------------------------------+----------------------------------------+ diff --git a/index.rst b/index.rst index afb2885b..ce5e7cac 100644 --- a/index.rst +++ b/index.rst @@ -35,9 +35,9 @@ Supported PyU4V Versions ------------------------ +-------------------------------+----------------------------------------+ -| **PyU4V Version** | 10.0.0.19 | +| **PyU4V Version** | 10.1.0.2 | +-------------------------------+----------------------------------------+ -| **Minimum Unisphere Version** | 10.0 | +| **Minimum Unisphere Version** | 10.1 | +-------------------------------+----------------------------------------+ | **Array Model** | VMAX-3, VMAX AFA, PowerMax | +-------------------------------+----------------------------------------+ @@ -123,7 +123,7 @@ PyU4V docs offline. Disclaimer ---------- -PyU4V 9.2 is distributed under the Apache 2.0 License. Unless required by +PyU4V 10.1 is distributed under the Apache 2.0 License. Unless required by applicable law or agreed to in writing, software distributed under the Apache 2.0 License is distributed on an **"as is" basis, without warranties or** **conditions of any kind**, either express or implied. See the License for the diff --git a/setup.py b/setup.py index af246efb..5c0608d5 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setuptools.setup( name='PyU4V', - version='10.1.0.1', + version='10.1.0.2', url='https://github.com/dell/PyU4V/', author='Dell Inc. or its subsidiaries', author_email='helen.walsh@dell.com', From 65bdf909cc1c14fa1aa22cddf0119faa10bdf41b Mon Sep 17 00:00:00 2001 From: "Martin, Paul" Date: Wed, 28 Feb 2024 16:44:50 +0000 Subject: [PATCH 3/4] pep8 --- PyU4V/univmax_conn.py | 1 - 1 file changed, 1 deletion(-) diff --git a/PyU4V/univmax_conn.py b/PyU4V/univmax_conn.py index e601c5ac..4129efcb 100644 --- a/PyU4V/univmax_conn.py +++ b/PyU4V/univmax_conn.py @@ -100,7 +100,6 @@ def __init__(self, username=None, password=None, server_ip=None, if config.has_option(SETUP, 'timeout') and timeout is None: self.timeout = int(config.get(SETUP, 'timeout')) - # Set verification if verify is None: try: From 9d580715e61f6fec4c5c2c1b86b7229f3b134531 Mon Sep 17 00:00:00 2001 From: "Martin, Paul" Date: Wed, 28 Feb 2024 16:45:31 +0000 Subject: [PATCH 4/4] pep8 --- PyU4V/rest_requests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/PyU4V/rest_requests.py b/PyU4V/rest_requests.py index d8c0d4bf..98e33df4 100644 --- a/PyU4V/rest_requests.py +++ b/PyU4V/rest_requests.py @@ -69,7 +69,6 @@ def __init__(self, username, password, verify, base_url, interval, retries, self.retries = retries self.session = self.establish_rest_session() - def establish_rest_session(self, headers=None): """Establish a REST session.