forked from saratov/infra
proxmoxer: update with fixes from next release
This commit is contained in:
parent
34de85486e
commit
970efb4b99
31
nix/proxmoxer/added_timeout_settings_for_auth_request.diff
Normal file
31
nix/proxmoxer/added_timeout_settings_for_auth_request.diff
Normal file
@ -0,0 +1,31 @@
|
||||
commit 81b160cc62c7699badd06dba9c072dfa3fbe219d
|
||||
Author: James Lin <jlin@Jamess-MacBook-Pro-2.local>
|
||||
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
|
@ -12,10 +12,12 @@ python27.pkgs.buildPythonPackage rec {
|
||||
};
|
||||
|
||||
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 ];
|
||||
doCheck = false;
|
||||
|
||||
meta = {
|
||||
homepage = "https://github.com/swayf/proxmoxer";
|
||||
homepage = "https://github.com/proxmoxer/proxmoxer";
|
||||
description = "Proxmoxer is a wrapper around the Proxmox REST API v2";
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
commit 60662c4891859ca1b6cf87d7068958d4f9dc7f21
|
||||
Author: timansky <timansky@kolesa.team>
|
||||
Date: Wed Dec 18 16:04:56 2019 +0600
|
||||
|
||||
Fix pvesh output format for version > 5.3
|
||||
|
||||
diff --git a/proxmoxer/backends/base_ssh.py b/proxmoxer/backends/base_ssh.py
|
||||
index da624d9..b3ba1b3 100644
|
||||
--- a/proxmoxer/backends/base_ssh.py
|
||||
+++ b/proxmoxer/backends/base_ssh.py
|
||||
@@ -41,7 +41,7 @@ class ProxmoxBaseSSHSession(object):
|
||||
data['tmpfilename'] = tmp_filename
|
||||
|
||||
translated_data = ' '.join(["-{0} {1}".format(k, v) for k, v in chain(data.items(), params.items())])
|
||||
- full_cmd = 'pvesh {0}'.format(' '.join(filter(None, (cmd, url, translated_data))))
|
||||
+ full_cmd = 'pvesh {0} --output-format json'.format(' '.join(filter(None, (cmd, url, translated_data))))
|
||||
|
||||
stdout, stderr = self._exec(full_cmd)
|
||||
match = lambda s: re.match('\d\d\d [a-zA-Z]', s)
|
||||
diff --git a/tests/base/base_ssh_suite.py b/tests/base/base_ssh_suite.py
|
||||
index 943b72f..ddb4bf3 100644
|
||||
--- a/tests/base/base_ssh_suite.py
|
||||
+++ b/tests/base/base_ssh_suite.py
|
||||
@@ -62,7 +62,7 @@ class BaseSSHSuite(object):
|
||||
}
|
||||
]""")
|
||||
result = self.proxmox.nodes('proxmox').storage('local').get()
|
||||
- eq_(self._get_called_cmd(), self._called_cmd('pvesh get /nodes/proxmox/storage/local'))
|
||||
+ eq_(self._get_called_cmd(), self._called_cmd('pvesh get /nodes/proxmox/storage/local --output-format json'))
|
||||
eq_(result[0]['subdir'], 'status')
|
||||
eq_(result[1]['subdir'], 'content')
|
||||
eq_(result[2]['subdir'], 'upload')
|
||||
@@ -71,13 +71,13 @@ class BaseSSHSuite(object):
|
||||
|
||||
def test_delete(self):
|
||||
self.proxmox.nodes('proxmox').openvz(100).delete()
|
||||
- eq_(self._get_called_cmd(), self._called_cmd('pvesh delete /nodes/proxmox/openvz/100'))
|
||||
+ eq_(self._get_called_cmd(), self._called_cmd('pvesh delete /nodes/proxmox/openvz/100 --output-format json'))
|
||||
self._set_stderr("200 OK")
|
||||
self.proxmox.nodes('proxmox').openvz('101').delete()
|
||||
- eq_(self._get_called_cmd(), self._called_cmd('pvesh delete /nodes/proxmox/openvz/101'))
|
||||
+ eq_(self._get_called_cmd(), self._called_cmd('pvesh delete /nodes/proxmox/openvz/101 --output-format json'))
|
||||
self._set_stderr("200 OK")
|
||||
self.proxmox.nodes('proxmox').openvz.delete('102')
|
||||
- eq_(self._get_called_cmd(), self._called_cmd('pvesh delete /nodes/proxmox/openvz/102'))
|
||||
+ eq_(self._get_called_cmd(), self._called_cmd('pvesh delete /nodes/proxmox/openvz/102 --output-format json'))
|
||||
|
||||
def test_post(self):
|
||||
self._set_stderr("200 OK")
|
Loading…
Reference in New Issue
Block a user