Change in vdsm[master]: moving kaxmlrpclib.py to lib
ybronhei at redhat.com
ybronhei at redhat.com
Mon Feb 29 10:12:02 UTC 2016
Yaniv Bronhaim has uploaded a new change for review.
Change subject: moving kaxmlrpclib.py to lib
......................................................................
moving kaxmlrpclib.py to lib
Change-Id: I43f5c41a343c07484e888e745b6651300362ea6e
Signed-off-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
M debian/vdsm-python.install
M debian/vdsm.install
M lib/vdsm/Makefile.am
M vdsm.spec.in
M vdsm/Makefile.am
D vdsm/kaxmlrpclib.py
6 files changed, 3 insertions(+), 150 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/54151/1
diff --git a/debian/vdsm-python.install b/debian/vdsm-python.install
index 5a464b5..a0bcb0d 100644
--- a/debian/vdsm-python.install
+++ b/debian/vdsm-python.install
@@ -16,6 +16,7 @@
./usr/lib/python2.7/dist-packages/vdsm/hooks.py
./usr/lib/python2.7/dist-packages/vdsm/ipwrapper.py
./usr/lib/python2.7/dist-packages/vdsm/jsonrpcvdscli.py
+./usr/lib/python2.7/dist-packages/vdsm/kaxmlrpclib.py
./usr/lib/python2.7/dist-packages/vdsm/kernelconfig.py
./usr/lib/python2.7/dist-packages/vdsm/libvirtconnection.py
./usr/lib/python2.7/dist-packages/vdsm/netconfpersistence.py
diff --git a/debian/vdsm.install b/debian/vdsm.install
index 2cbd273..f2b3ad9 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -47,7 +47,6 @@
./usr/share/vdsm/hooking.py
./usr/share/vdsm/hostdev.py
./usr/share/vdsm/jobs.py
-./usr/share/vdsm/kaxmlrpclib.py
./usr/share/vdsm/logUtils.py
./usr/share/vdsm/mk_sysprep_floppy
./usr/share/vdsm/mkimage.py
diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am
index 4d894e7..12f472e 100644
--- a/lib/vdsm/Makefile.am
+++ b/lib/vdsm/Makefile.am
@@ -39,6 +39,7 @@
ipwrapper.py \
jobs.py \
jsonrpcvdscli.py \
+ kaxmlrpclib.py \
kernelconfig.py \
libvirtconnection.py \
m2cutils.py \
diff --git a/vdsm.spec.in b/vdsm.spec.in
index feef3a4..7478e6c 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1028,7 +1028,6 @@
%{_datadir}/%{vdsm_name}/dumpStorageTable.py*
%{_datadir}/%{vdsm_name}/get-conf-item
-%{_datadir}/%{vdsm_name}/kaxmlrpclib.py*
%{_datadir}/%{vdsm_name}/momIF.py*
%{_datadir}/%{vdsm_name}/set-conf-item
%dir %{_datadir}/%{vdsm_name}/gluster
@@ -1100,6 +1099,7 @@
%{python_sitelib}/%{vdsm_name}/ipwrapper.py*
%{python_sitelib}/%{vdsm_name}/jobs.py*
%{python_sitelib}/%{vdsm_name}/jsonrpcvdscli.py*
+%{python_sitelib}/%{vdsm_name}/kaxmlrpclib.py*
%{python_sitelib}/%{vdsm_name}/kernelconfig.py*
%{python_sitelib}/%{vdsm_name}/libvirtconnection.py*
%{python_sitelib}/%{vdsm_name}/m2cutils.py*
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 2c3d5e9..1f31163 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -30,7 +30,6 @@
clientIF.py \
hooking.py \
hostdev.py \
- kaxmlrpclib.py \
logUtils.py \
mkimage.py \
momIF.py \
diff --git a/vdsm/kaxmlrpclib.py b/vdsm/kaxmlrpclib.py
deleted file mode 100644
index 3fdf61c..0000000
--- a/vdsm/kaxmlrpclib.py
+++ /dev/null
@@ -1,147 +0,0 @@
-#
-# Copyright 2008-2011 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# Refer to the README and COPYING files for full details of the license
-#
-
-"""xmlrpclib with a keep-alive transport.
-
-Throws a timeout exception to the client when the underlying
-TCP transport is broken.
-
-Inspired by Volodymyr Orlenko,
-http://blog.bjola.ca/2007/08/using-timeout-with-xmlrpclib.html
-
-Sets up an xmlrpc Server with a modified Transport
-(TcpkeepTransport) which uses TcpkeepHTTPConnection when it
-needs to set up a connection.
-"""
-from __future__ import print_function
-
-import xmlrpclib
-import httplib
-import socket
-
-# It would have been nicer to make these server-specific and not module-wide
-# constants. But it is not really important for us, so it should wait.
-KEEPIDLE = 60
-KEEPINTVL = 10
-KEEPCNT = 6
-
-CONNECTTIMEOUT = 160
-
-
-def Server(url, *args, **kwargs):
- kwargs['transport'] = TcpkeepTransport()
- server = xmlrpclib.Server(url, *args, **kwargs)
- return server
-
-ServerProxy = Server
-
-
-class TcpkeepTransport(xmlrpclib.Transport):
-
- def make_connection(self, host):
- return TcpkeepHTTPConnection(host)
-
-
-class TcpkeepHTTPConnection(httplib.HTTPConnection):
- def connect(self):
- """Connect to the host and port specified in __init__.
-
- taken from httplib.HTTPConnection.connect(), with few additions for
- connection timeout and keep-alive
-
- after TCP_KEEPIDLE seconds of silence, TCP_KEEPCNT probes would be
- sent, TCP_KEEPINTVL seconds apart of each other. If all of them
- fail, the socket is closed."""
-
- msg = "getaddrinfo returns an empty list"
- for res in socket.getaddrinfo(self.host, self.port, 0,
- socket.SOCK_STREAM):
- af, socktype, proto, canonname, sa = res
- try:
- self.sock = socket.socket(af, socktype, proto)
- if self.debuglevel > 0:
- print("connect: (%s, %s)" % (self.host, self.port))
-
- oldtimeout = self.sock.gettimeout() # added
- self.sock.settimeout(CONNECTTIMEOUT) # added
- self.sock.connect(sa)
- self.sock.settimeout(oldtimeout) # added
- except socket.error as msg:
- if self.debuglevel > 0:
- print('connect fail:', (self.host, self.port))
- if self.sock:
- self.sock.close()
- self.sock = None
- continue
- break
- if not self.sock:
- raise socket.error(msg)
- # beginning of added code
- self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
- self.sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, KEEPIDLE)
- self.sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, KEEPINTVL)
- self.sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, KEEPCNT)
- # end of added code
-
-
-###################
-# the same, for ssl
-from vdsm.sslcompat import sslutils
-import ssl
-
-
-def SslServer(url, ctx, *args, **kwargs):
- kwargs['transport'] = TcpkeepSafeTransport(ctx)
- server = xmlrpclib.Server(url, *args, **kwargs)
- return server
-
-SslServerProxy = SslServer
-
-
-class TcpkeepSafeTransport(sslutils.VerifyingSafeTransport):
-
- def make_connection(self, host):
- chost, self._extra_headers, x509 = self.get_host_info(host)
- return TcpkeepHTTPSConnection(
- chost, None, key_file=self.key_file, strict=None,
- timeout=CONNECTTIMEOUT,
- cert_file=self.cert_file, ca_certs=self.ca_certs,
- cert_reqs=self.cert_reqs)
-
-
-class TcpkeepHTTPSConnection(sslutils.VerifyingHTTPSConnection):
- def __init__(self, host, port=None, key_file=None, cert_file=None,
- strict=None, timeout=CONNECTTIMEOUT,
- ca_certs=None, cert_reqs=ssl.CERT_REQUIRED):
- sslutils.VerifyingHTTPSConnection.__init__(
- self, host, port=port, key_file=key_file, cert_file=cert_file,
- strict=strict, timeout=timeout,
- ca_certs=ca_certs, cert_reqs=cert_reqs)
-
- def connect(self):
- sslutils.VerifyingHTTPSConnection.connect(self)
-
- # after TCP_KEEPIDLE seconds of silence, TCP_KEEPCNT probes would be
- # sent, TCP_KEEPINTVL seconds apart of each other. If all of them fail,
- # the socket is closed.
- self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
- self.sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, KEEPIDLE)
- self.sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, KEEPINTVL)
- self.sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, KEEPCNT)
--
To view, visit https://gerrit.ovirt.org/54151
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I43f5c41a343c07484e888e745b6651300362ea6e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>
More information about the vdsm-patches
mailing list