summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-09-28 05:52:36 -0400
committerAmar Tumballi <amarts@redhat.com>2018-10-02 05:48:31 +0000
commitd06bbb617ee9449759cd069141a085c313524298 (patch)
treef02df77651b5efa12a3b5c41c21ab22877140c15 /geo-replication
parentf7a81f4be38bd3e1859268d09306918fa303a82c (diff)
georep: python2 and python3 compat - bytes-str
1. Fix fdopen used for pid file 2. Fix sha256 checksum calculation Updates: #411 Change-Id: Ic173d104a73822c29aca260ba6de872cd8d23f86 Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'geo-replication')
-rw-r--r--geo-replication/syncdaemon/syncdutils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
index 27b548c9d52..cbb169c6c96 100644
--- a/geo-replication/syncdaemon/syncdutils.py
+++ b/geo-replication/syncdaemon/syncdutils.py
@@ -160,7 +160,8 @@ def setup_ssh_ctl(ctld, remote_addr, resource_url):
rconf.ssh_ctl_dir = ctld
content = "SLAVE_HOST=%s\nSLAVE_RESOURCE_URL=%s" % (remote_addr,
resource_url)
- content_sha256 = sha256hex(content)
+ encoded_content = content.encode()
+ content_sha256 = sha256hex(encoded_content)
"""
The length of ctl_path for ssh connection should not be > 108.
ssh fails with ctl_path too long if it is so. But when rsync
@@ -172,7 +173,7 @@ def setup_ssh_ctl(ctld, remote_addr, resource_url):
fname = os.path.join(rconf.ssh_ctl_dir,
"%s.mft" % content_sha256)
- create_manifest(fname, content)
+ create_manifest(fname, encoded_content)
ssh_ctl_path = os.path.join(rconf.ssh_ctl_dir,
"%s.sock" % content_sha256)
rconf.ssh_ctl_args = ["-oControlMaster=auto", "-S", ssh_ctl_path]
@@ -185,7 +186,7 @@ def grabfile(fname, content=None):
"""
# damn those messy open() mode codes
fd = os.open(fname, os.O_CREAT | os.O_RDWR)
- f = os.fdopen(fd, 'r+b', 0)
+ f = os.fdopen(fd, 'r+')
try:
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
@@ -199,6 +200,7 @@ def grabfile(fname, content=None):
try:
f.truncate()
f.write(content)
+ f.flush()
except:
f.close()
raise