summaryrefslogtreecommitdiffstats
path: root/geo-replication/src
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2018-07-02 08:18:54 -0400
committerAmar Tumballi <amarts@redhat.com>2018-07-09 03:38:36 +0000
commit55d1b0531a0b322a1b851fc921fd6fdf25d26331 (patch)
treef3d8c84e4d27fb8894a9c921a9a4ed06257cf80e /geo-replication/src
parentdab12ce093628860bf43c3e0c7eaf9099cf7a78f (diff)
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, https://review.gluster.org/#/c/20104/, https://review.gluster.org/#/c/20162/, https://review.gluster.org/#/c/20185/, https://review.gluster.org/#/c/20207/, https://review.gluster.org/#/c/20227/, https://review.gluster.org/#/c/20307/, https://review.gluster.org/#/c/20320/, https://review.gluster.org/#/c/20332/, and https://review.gluster.org/#/c/20364/ Fixes glupy.py python2isms, iteritems -> items, and some overlooked print() in georep/peer_mountbroker.in Note: Fedora packaging guidelines and SUSE rpmlint require explicit shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, has_key, idioms, map, numliterals, raise, set_literal, types, urllib, and zip have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: Idda031c1ec975417c79323aea33e7b694e752b2a updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'geo-replication/src')
-rw-r--r--geo-replication/src/peer_mountbroker.in21
-rw-r--r--geo-replication/src/peer_mountbroker.py.in7
2 files changed, 16 insertions, 12 deletions
diff --git a/geo-replication/src/peer_mountbroker.in b/geo-replication/src/peer_mountbroker.in
index 89bb0c0ba6f..5d19db88b80 100644
--- a/geo-replication/src/peer_mountbroker.in
+++ b/geo-replication/src/peer_mountbroker.in
@@ -1,11 +1,12 @@
#!/usr/bin/python2
+from __future__ import print_function
+
import os
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import json
import sys
-
PROG_DESCRIPTION = """
GlusterFS Mountbroker user management
"""
@@ -15,19 +16,19 @@ args = None
def ok(message=""):
if (not args and "-j" in sys.argv) or (args and args.json):
- print json.dumps({"ok": True, "message": message})
+ print(json.dumps({"ok": True, "message": message}))
else:
if message:
- print message
+ print(message)
sys.exit(0)
def notok(message=""):
if (not args and "-j" in sys.argv) or (args and args.json):
- print json.dumps({"ok": False, "message": message})
+ print(json.dumps({"ok": False, "message": message}))
else:
- print "error: %s" % message
+ print("error: %s" % message)
# Always return zero due to limitation while executing
# as `gluster system:: execute`
@@ -65,7 +66,7 @@ class MountbrokerUserMgmt(object):
def _get_write_data(self):
op = "volume management\n"
op += " type mgmt/glusterd\n"
- for k, v in self._options.iteritems():
+ for k, v in self._options.items():
op += " option %s %s\n" % (k, v)
for line in self.commented_lines:
op += " %s\n" % line
@@ -88,7 +89,7 @@ class MountbrokerUserMgmt(object):
def add_user(self, user, volumes):
vols = set()
- for k, v in self._options.iteritems():
+ for k, v in self._options.items():
if k.startswith("mountbroker-geo-replication.") \
and user == k.split(".")[-1]:
vols.update(v.split(","))
@@ -99,7 +100,7 @@ class MountbrokerUserMgmt(object):
def remove_volume(self, user, volumes):
vols = set()
- for k, v in self._options.iteritems():
+ for k, v in self._options.items():
if k.startswith("mountbroker-geo-replication.") \
and user == k.split(".")[-1]:
vols.update(v.split(","))
@@ -119,7 +120,7 @@ class MountbrokerUserMgmt(object):
def info(self):
data = {"users": []}
- for k, v in self._options.iteritems():
+ for k, v in self._options.items():
if k.startswith("mountbroker-geo-replication."):
data["users"].append(
{"name": k.split(".")[-1], "volumes": v.split(",")}
@@ -133,7 +134,7 @@ class MountbrokerUserMgmt(object):
def format_info(data):
op = "%s %s\n" % ("Option".ljust(50), "Value".ljust(50))
op += ("-" * 101) + "\n"
- for key, value in data.iteritems():
+ for key, value in data.items():
if key != "users":
op += "%s %s\n" % (key.ljust(50), value)
diff --git a/geo-replication/src/peer_mountbroker.py.in b/geo-replication/src/peer_mountbroker.py.in
index 8f2367b7d49..d101de561e4 100644
--- a/geo-replication/src/peer_mountbroker.py.in
+++ b/geo-replication/src/peer_mountbroker.py.in
@@ -1,4 +1,7 @@
#!/usr/bin/python2
+
+from __future__ import print_function
+
import os
from errno import EEXIST, ENOENT
@@ -48,7 +51,7 @@ class MountbrokerUserMgmt(object):
if line.startswith("#"):
self.commented_lines.append(line)
- for k, v in self._options.iteritems():
+ for k, v in self._options.items():
if k.startswith("mountbroker-geo-replication."):
user = k.split(".")[-1]
self.user_volumes[user] = set(v.split(","))
@@ -59,7 +62,7 @@ class MountbrokerUserMgmt(object):
def _get_write_data(self):
op = "volume management\n"
op += " type mgmt/glusterd\n"
- for k, v in self._options.iteritems():
+ for k, v in self._options.items():
if k.startswith("mountbroker-geo-replication."):
# Users will be added seperately
continue