From 390cfa18d31415948e890891dc27174adefedd4c Mon Sep 17 00:00:00 2001 From: Evgeny Sinelnikov Date: Sat, 18 Sep 2021 07:09:15 +0400 Subject: [PATCH] proxmoxer: replace patches in single patch --- ...ded_timeout_settings_for_auth_request.diff | 31 -------------- nix/proxmoxer/default.nix | 4 +- ...ion_more_than_5.3.diff => proxmoxer.patch} | 40 ++++++++++++++++--- nix/proxmoxer/show_reason_on_exceptions.patch | 11 ----- 4 files changed, 36 insertions(+), 50 deletions(-) delete mode 100644 nix/proxmoxer/added_timeout_settings_for_auth_request.diff rename nix/proxmoxer/{fix_pvesh_output_format_for_version_more_than_5.3.diff => proxmoxer.patch} (56%) delete mode 100644 nix/proxmoxer/show_reason_on_exceptions.patch diff --git a/nix/proxmoxer/added_timeout_settings_for_auth_request.diff b/nix/proxmoxer/added_timeout_settings_for_auth_request.diff deleted file mode 100644 index b9b8605..0000000 --- a/nix/proxmoxer/added_timeout_settings_for_auth_request.diff +++ /dev/null @@ -1,31 +0,0 @@ -commit 81b160cc62c7699badd06dba9c072dfa3fbe219d -Author: James Lin -Date: Thu Nov 14 10:24:58 2019 +1300 - - added timeout settings for auth request - -diff --git a/proxmoxer/backends/https.py b/proxmoxer/backends/https.py -index ad76a47..e96b822 100644 ---- a/proxmoxer/backends/https.py -+++ b/proxmoxer/backends/https.py -@@ -38,9 +38,10 @@ class AuthenticationError(Exception): - - - class ProxmoxHTTPAuth(AuthBase): -- def __init__(self, base_url, username, password, verify_ssl=False): -+ def __init__(self, base_url, username, password, verify_ssl=False, timeout=5): - response_data = requests.post(base_url + "/access/ticket", - verify=verify_ssl, -+ timeout=timeout, - data={"username": username, "password": password}).json()["data"] - if response_data is None: - raise AuthenticationError("Couldn't authenticate user: {0} to {1}".format(username, base_url + "/access/ticket")) -@@ -122,7 +123,7 @@ class Backend(object): - if auth_token is not None: - self.auth = ProxmoxHTTPTokenAuth(auth_token, csrf_token) - else: -- self.auth = ProxmoxHTTPAuth(self.base_url, user, password, verify_ssl) -+ self.auth = ProxmoxHTTPAuth(self.base_url, user, password, verify_ssl, timeout) - self.verify_ssl = verify_ssl - self.mode = mode - self.timeout = timeout diff --git a/nix/proxmoxer/default.nix b/nix/proxmoxer/default.nix index 9f8cb19..f7d16fc 100644 --- a/nix/proxmoxer/default.nix +++ b/nix/proxmoxer/default.nix @@ -11,9 +11,7 @@ python27.pkgs.buildPythonPackage rec { sha256 = "145hvphvlzvwq6sn31ldnin0ii50blsapxz0gv2zx3grzp6x9hvh"; }; - patches = [ ./show_reason_on_exceptions.patch ]; - patches = [ ./added_timeout_settings_for_auth_request.diff ]; - patches = [ ./fix_pvesh_output_format_for_version_more_than_5.3.diff ]; + patches = [ ./proxmoxer.patch ]; doCheck = false; meta = { diff --git a/nix/proxmoxer/fix_pvesh_output_format_for_version_more_than_5.3.diff b/nix/proxmoxer/proxmoxer.patch similarity index 56% rename from nix/proxmoxer/fix_pvesh_output_format_for_version_more_than_5.3.diff rename to nix/proxmoxer/proxmoxer.patch index 4bb979c..8f1739a 100644 --- a/nix/proxmoxer/fix_pvesh_output_format_for_version_more_than_5.3.diff +++ b/nix/proxmoxer/proxmoxer.patch @@ -1,9 +1,39 @@ -commit 60662c4891859ca1b6cf87d7068958d4f9dc7f21 -Author: timansky -Date: Wed Dec 18 16:04:56 2019 +0600 - - Fix pvesh output format for version > 5.3 +--- a/proxmoxer/core.py 1970-01-01 04:00:01.000000000 +0400 ++++ b/proxmoxer/core.py 2018-10-29 15:21:20.241881023 +0400 +@@ -76,7 +76,7 @@ + + if resp.status_code >= 400: + raise ResourceException("{0} {1}: {2}".format(resp.status_code, httplib.responses[resp.status_code], +- resp.content)) ++ resp.reason)) + elif 200 <= resp.status_code <= 299: + return self._store["serializer"].loads(resp) +diff --git a/proxmoxer/backends/https.py b/proxmoxer/backends/https.py +index ad76a47..e96b822 100644 +--- a/proxmoxer/backends/https.py ++++ b/proxmoxer/backends/https.py +@@ -38,9 +38,10 @@ class AuthenticationError(Exception): + + + class ProxmoxHTTPAuth(AuthBase): +- def __init__(self, base_url, username, password, verify_ssl=False): ++ def __init__(self, base_url, username, password, verify_ssl=False, timeout=5): + response_data = requests.post(base_url + "/access/ticket", + verify=verify_ssl, ++ timeout=timeout, + data={"username": username, "password": password}).json()["data"] + if response_data is None: + raise AuthenticationError("Couldn't authenticate user: {0} to {1}".format(username, base_url + "/access/ticket")) +@@ -122,7 +123,7 @@ class Backend(object): + if auth_token is not None: + self.auth = ProxmoxHTTPTokenAuth(auth_token, csrf_token) + else: +- self.auth = ProxmoxHTTPAuth(self.base_url, user, password, verify_ssl) ++ self.auth = ProxmoxHTTPAuth(self.base_url, user, password, verify_ssl, timeout) + self.verify_ssl = verify_ssl + self.mode = mode + self.timeout = timeout diff --git a/proxmoxer/backends/base_ssh.py b/proxmoxer/backends/base_ssh.py index da624d9..b3ba1b3 100644 --- a/proxmoxer/backends/base_ssh.py diff --git a/nix/proxmoxer/show_reason_on_exceptions.patch b/nix/proxmoxer/show_reason_on_exceptions.patch deleted file mode 100644 index 85cfb08..0000000 --- a/nix/proxmoxer/show_reason_on_exceptions.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/proxmoxer/core.py 1970-01-01 04:00:01.000000000 +0400 -+++ b/proxmoxer/core.py 2018-10-29 15:21:20.241881023 +0400 -@@ -76,7 +76,7 @@ - - if resp.status_code >= 400: - raise ResourceException("{0} {1}: {2}".format(resp.status_code, httplib.responses[resp.status_code], -- resp.content)) -+ resp.reason)) - elif 200 <= resp.status_code <= 299: - return self._store["serializer"].loads(resp) -