Change in vdsm[master]: vdscli: allow a connection with a configurable timeout
ykaplan at redhat.com
ykaplan at redhat.com
Sun Mar 15 14:19:50 UTC 2015
Yeela Kaplan has uploaded a new change for review.
Change subject: vdscli: allow a connection with a configurable timeout
......................................................................
vdscli: allow a connection with a configurable timeout
Add an option to connect to vdscli with any configurable
timeout, to allow the user a larger timeout than the
default ssl 60 seconds.
Especially useful for long duration storage operations.
Change-Id: I10829e7491c1e3c917080664c0eea643f054247e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1190636
Signed-off-by: Yeela Kaplan <ykaplan at redhat.com>
---
M lib/vdsm/sslutils.py
M lib/vdsm/vdscli.py
2 files changed, 17 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/38751/1
diff --git a/lib/vdsm/sslutils.py b/lib/vdsm/sslutils.py
index 74555ee..3f0b818 100644
--- a/lib/vdsm/sslutils.py
+++ b/lib/vdsm/sslutils.py
@@ -26,6 +26,7 @@
DEFAULT_ACCEPT_TIMEOUT = 5
+SOCKET_DEFAULT_TIMEOUT = socket._GLOBAL_DEFAULT_TIMEOUT
# M2Crypto.threading needs initialization.
# See https://bugzilla.redhat.com/482420
@@ -174,7 +175,7 @@
class VerifyingHTTPSConnection(httplib.HTTPSConnection):
def __init__(self, host, port=None, key_file=None, cert_file=None,
- strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+ strict=None, timeout=SOCKET_DEFAULT_TIMEOUT,
ca_certs=None, cert_reqs=ssl.CERT_REQUIRED):
httplib.HTTPSConnection.__init__(self, host, port, key_file, cert_file,
strict, timeout)
@@ -196,12 +197,14 @@
class VerifyingSafeTransport(xmlrpclib.SafeTransport):
def __init__(self, use_datetime=0, key_file=None, cert_file=None,
- ca_certs=None, cert_reqs=ssl.CERT_REQUIRED):
+ ca_certs=None, cert_reqs=ssl.CERT_REQUIRED,
+ timeout=SOCKET_DEFAULT_TIMEOUT):
xmlrpclib.SafeTransport.__init__(self, use_datetime)
self.key_file = key_file
self.cert_file = cert_file
self.ca_certs = ca_certs
self.cert_reqs = cert_reqs
+ self._timeout = timeout
def make_connection(self, host):
"""Return VerifyingHTTPS object that is aware of ca_certs, and will
@@ -212,12 +215,14 @@
if hasattr(xmlrpclib.SafeTransport, "single_request"): # Python 2.7
return VerifyingHTTPSConnection(
chost, None, key_file=self.key_file, strict=None,
- cert_file=self.cert_file, ca_certs=self.ca_certs,
+ cert_file=self.cert_file, timeout=self._timeout,
+ ca_certs=self.ca_certs,
cert_reqs=self.cert_reqs)
else:
return VerifyingHTTPS(
chost, None, key_file=self.key_file,
- cert_file=self.cert_file, ca_certs=self.ca_certs,
+ cert_file=self.cert_file, timeout=self._timeout,
+ ca_certs=self.ca_certs,
cert_reqs=self.cert_reqs)
@@ -225,7 +230,8 @@
_connection_class = VerifyingHTTPSConnection
def __init__(self, host='', port=None, key_file=None, cert_file=None,
- strict=None, ca_certs=None, cert_reqs=ssl.CERT_REQUIRED):
+ strict=None, timeout=SOCKET_DEFAULT_TIMEOUT,
+ ca_certs=None, cert_reqs=ssl.CERT_REQUIRED):
"""A ca_cert-aware HTTPS object,
that creates a VerifyingHTTPSConnection
"""
@@ -236,6 +242,7 @@
port = None
self._setup(self._connection_class(host, port, key_file,
cert_file, strict,
+ timeout,
ca_certs=ca_certs,
cert_reqs=cert_reqs))
diff --git a/lib/vdsm/vdscli.py b/lib/vdsm/vdscli.py
index 2908775..38b1afc 100644
--- a/lib/vdsm/vdscli.py
+++ b/lib/vdsm/vdscli.py
@@ -93,7 +93,9 @@
def connect(hostPort=None, useSSL=None, tsPath=None,
- TransportClass=sslutils.VerifyingSafeTransport):
+ TransportClass=sslutils.VerifyingSafeTransport,
+ timeout=sslutils.SOCKET_DEFAULT_TIMEOUT):
+
hostPort = cannonizeHostPort(hostPort)
if useSSL is None:
useSSL = _USE_SSL
@@ -109,7 +111,8 @@
raise Exception("No permission to read file: %s" % f)
transport = TransportClass(key_file=KEYFILE,
- cert_file=CERTFILE, ca_certs=CACERT)
+ cert_file=CERTFILE, ca_certs=CACERT,
+ timeout=timeout)
server = xmlrpclib.ServerProxy('https://%s' % hostPort,
wrap_transport(transport))
else:
--
To view, visit https://gerrit.ovirt.org/38751
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I10829e7491c1e3c917080664c0eea643f054247e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan at redhat.com>
More information about the vdsm-patches
mailing list