diff -Nrup a/cts/CIB.py b/cts/CIB.py --- a/cts/CIB.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CIB.py 2020-01-29 13:30:42.000000000 +0100 @@ -30,7 +30,7 @@ class CibBase: else: self.kwargs.pop(key, None) -from cib_xml import * +from .cib_xml import * class ConfigBase: @@ -213,7 +213,7 @@ class CIB11(ConfigBase): try: (name, value) = string.split(entry, '=', 1) except ValueError: - print("Warning: skipping invalid fencing parameter: %s" % entry) + print(("Warning: skipping invalid fencing parameter: %s" % entry)) continue # Allow user to specify "all" as the node list, and expand it here @@ -275,7 +275,7 @@ class CIB11(ConfigBase): # create the attributes and a level for the attribute. if attr_nodes: stn = Nodes(self.Factory) - for (node_name, node_id) in attr_nodes.items(): + for (node_name, node_id) in list(attr_nodes.items()): stn.add_node(node_name, node_id, { "cts-fencing" : "levels-and" }) stl.level(1, None, "FencingPass,Fencing", "cts-fencing", "levels-and") @@ -536,12 +536,12 @@ class ConfigFactoryItem: if __name__ == '__main__': """ Unit test (pass cluster node names as command line arguments) """ - import CTS - import CM_ais + from . import CTS + from . import CM_ais import sys if len(sys.argv) < 2: - print("Usage: %s <node> ..." % sys.argv[0]) + print(("Usage: %s <node> ..." % sys.argv[0])) sys.exit(1) args = [ @@ -556,4 +556,4 @@ if __name__ == '__main__': cm = CM_ais.crm_mcp(env) CibFactory = ConfigFactory(cm) cib = CibFactory.createConfig("pacemaker-1.1") - print(cib.contents()) + print((cib.contents())) diff -Nrup a/cts/cib_xml.py b/cts/cib_xml.py --- a/cts/cib_xml.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/cib_xml.py 2020-01-29 13:30:46.000000000 +0100 @@ -56,7 +56,7 @@ class InstanceAttributes(XmlBase): XmlBase.__init__(self, Factory, "instance_attributes", name) # Create an <nvpair> for each attribute - for (attr, value) in attrs.items(): + for (attr, value) in list(attrs.items()): self.add_child(XmlBase(Factory, "nvpair", "%s-%s" % (name, attr), name=attr, value=value)) diff -Nrup a/cts/CM_ais.py b/cts/CM_ais.py --- a/cts/CM_ais.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CM_ais.py 2020-01-29 13:30:42.000000000 +0100 @@ -52,7 +52,7 @@ class crm_ais(crm_lha): def ais_components(self, extra={}): complist = [] - if not len(self.fullcomplist.keys()): + if not len(list(self.fullcomplist.keys())): for c in ["cib", "lrmd", "crmd", "attrd" ]: self.fullcomplist[c] = Process( self, c, diff -Nrup a/cts/CTSaudits.py b/cts/CTSaudits.py --- a/cts/CTSaudits.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CTSaudits.py 2020-01-29 13:30:44.000000000 +0100 @@ -22,7 +22,7 @@ Licensed under the GNU GPL. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. import time, re, uuid -from watcher import LogWatcher +from .watcher import LogWatcher class ClusterAudit: @@ -184,7 +184,7 @@ class DiskAudit(ClusterAudit): answer = "Y" else: try: - answer = raw_input('Continue? [nY]') + answer = input('Continue? [nY]') except EOFError as e: answer = "n" @@ -722,7 +722,7 @@ class PartitionAudit(ClusterAudit): self.NodeQuorum = {} def has_key(self, key): - return self.Stats.has_key(key) + return key in self.Stats def __setitem__(self, key, value): self.Stats[key] = value diff -Nrup a/cts/CTSlab.py b/cts/CTSlab.py --- a/cts/CTSlab.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CTSlab.py 2020-01-29 13:30:44.000000000 +0100 @@ -146,7 +146,7 @@ if __name__ == '__main__': LogFactory().log("Random Seed: %s" % Environment["RandSeed"]) LogFactory().log("Syslog variant: %s" % Environment["syslogd"].strip()) LogFactory().log("System log files: %s" % Environment["LogFileName"]) - if Environment.has_key("IPBase"): + if "IPBase" in Environment: LogFactory().log("Base IP for resources: %s" % Environment["IPBase"]) LogFactory().log("Cluster starts at boot: %d" % Environment["at-boot"]) diff -Nrup a/cts/CTS.py b/cts/CTS.py --- a/cts/CTS.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CTS.py 2020-01-29 13:30:43.000000000 +0100 @@ -157,7 +157,7 @@ class CtsLab: self.Env.dump() def has_key(self, key): - return key in self.Env.keys() + return key in list(self.Env.keys()) def __getitem__(self, key): return self.Env[key] @@ -245,7 +245,7 @@ class NodeStatus: answer = "Y" else: try: - answer = raw_input('Continue? [nY]') + answer = input('Continue? [nY]') except EOFError as e: answer = "n" if answer and answer == "n": @@ -305,14 +305,14 @@ class ClusterManager(UserDict): if key == "Name": return self.name - print("FIXME: Getting %s from %s" % (key, repr(self))) + print(("FIXME: Getting %s from %s" % (key, repr(self)))) if key in self.data: return self.data[key] return self.templates.get_patterns(self.Env["Name"], key) def __setitem__(self, key, value): - print("FIXME: Setting %s=%s on %s" % (key, value, repr(self))) + print(("FIXME: Setting %s=%s on %s" % (key, value, repr(self)))) self.data[key] = value def key_for_node(self, node): @@ -339,7 +339,7 @@ class ClusterManager(UserDict): def prepare(self): '''Finish the Initialization process. Prepare to test...''' - print(repr(self)+"prepare") + print((repr(self)+"prepare")) for node in self.Env["nodes"]: if self.StataCM(node): self.ShouldBeStatus[node] = "up" @@ -885,7 +885,7 @@ class ClusterManager(UserDict): self.rsh(host, '''bash %s %s delete''' % (log_stats_bin, log_stats_file)) fname = "cts-stats-%d-nodes-%s.csv" % (len(self.Env["nodes"]), host) - print("Extracted stats: %s" % fname) + print(("Extracted stats: %s" % fname)) fd = open(fname, "a") fd.writelines(lines) fd.close() diff -Nrup a/cts/CTSscenarios.py b/cts/CTSscenarios.py --- a/cts/CTSscenarios.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CTSscenarios.py 2020-01-29 13:30:44.000000000 +0100 @@ -1,6 +1,6 @@ -from CTS import * -from CTStests import CTSTest -from CTSaudits import ClusterAudit +from .CTS import * +from .CTStests import CTSTest +from .CTSaudits import ClusterAudit from cts.watcher import LogWatcher class ScenarioComponent: @@ -170,7 +170,7 @@ A partially set up scenario is torn down answer = "Y" else: try: - answer = raw_input('Continue? [nY]') + answer = input('Continue? [nY]') except EOFError as e: answer = "n" if answer and answer == "n": @@ -265,7 +265,7 @@ A partially set up scenario is torn down answer = "Y" else: try: - answer = raw_input('Big problems. Continue? [nY]') + answer = input('Big problems. Continue? [nY]') except EOFError as e: answer = "n" if answer and answer == "n": @@ -399,7 +399,7 @@ According to the manual page for ping: '''Start the PingFest!''' self.PingSize = 1024 - if "PingSize" in CM.Env.keys(): + if "PingSize" in list(CM.Env.keys()): self.PingSize = CM.Env["PingSize"] CM.log("Starting %d byte flood pings" % self.PingSize) @@ -562,7 +562,7 @@ Test a rolling upgrade between two versi return self.install(node, self.CM.Env["previous-version"]) def SetUp(self, CM): - print(repr(self)+"prepare") + print((repr(self)+"prepare")) CM.prepare() # Clear out the cobwebs diff -Nrup a/cts/CTStests.py b/cts/CTStests.py --- a/cts/CTStests.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CTStests.py 2020-01-29 13:30:46.000000000 +0100 @@ -2,7 +2,7 @@ """ # Pacemaker targets compatibility with Python 2.6+ and 3.2+ -from __future__ import print_function, unicode_literals, absolute_import, division + __copyright__ = """Copyright (C) 2000, 2001 Alan Robertson <alanr@unix.sh> Add RecourceRecover testcase Zhao Kai <zhaokai@cn.ibm.com> @@ -523,7 +523,7 @@ class StonithdTest(CTSTest): if not self.is_applicable_common(): return 0 - if "DoFencing" in self.Env.keys(): + if "DoFencing" in list(self.Env.keys()): return self.Env["DoFencing"] return 1 @@ -1568,7 +1568,7 @@ class SplitBrainTest(CTSTest): if not p in partitions: partitions[p] = [] partitions[p].append(node) - p_max = len(partitions.keys()) + p_max = len(list(partitions.keys())) if p_max > 1: break # else, try again @@ -1642,7 +1642,7 @@ class SplitBrainTest(CTSTest): answer = "Y" else: try: - answer = raw_input('Continue? [nY]') + answer = input('Continue? [nY]') except EOFError as e: answer = "n" if answer and answer == "n": @@ -2243,11 +2243,11 @@ class RollingUpgradeTest(CTSTest): if not self.is_applicable_common(): return None - if not "rpm-dir" in self.Env.keys(): + if not "rpm-dir" in list(self.Env.keys()): return None - if not "current-version" in self.Env.keys(): + if not "current-version" in list(self.Env.keys()): return None - if not "previous-version" in self.Env.keys(): + if not "previous-version" in list(self.Env.keys()): return None return 1 @@ -3078,7 +3078,7 @@ class RemoteStonithd(RemoteDriver): if not RemoteDriver.is_applicable(self): return False - if "DoFencing" in self.Env.keys(): + if "DoFencing" in list(self.Env.keys()): return self.Env["DoFencing"] return True diff -Nrup a/cts/environment.py b/cts/environment.py --- a/cts/environment.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/environment.py 2020-01-29 13:30:47.000000000 +0100 @@ -103,7 +103,7 @@ class Environment: self.logger.debug("Environment["+key+"]:\t"+str(self[key])) def keys(self): - return self.data.keys() + return list(self.data.keys()) def has_key(self, key): if key == "nodes": @@ -526,7 +526,7 @@ class Environment: f.close() else: - print("Unknown DSH group: %s" % args[i+1]) + print(("Unknown DSH group: %s" % args[i+1])) elif args[i] == "--syslog-facility" or args[i] == "--facility": skipthis=1 @@ -617,7 +617,7 @@ class Environment: skipthis=1 (name, value) = args[i+1].split('=') self[name] = value - print("Setting %s = %s" % (name, value)) + print(("Setting %s = %s" % (name, value))) elif args[i] == "--help": self.usage(args[i], 0) @@ -634,8 +634,8 @@ class Environment: def usage(self, arg, status=1): if status: - print("Illegal argument %s" % arg) - print("usage: " + sys.argv[0] +" [options] number-of-iterations") + print(("Illegal argument %s" % arg)) + print(("usage: " + sys.argv[0] +" [options] number-of-iterations")) print("\nCommon options: ") print("\t [--nodes 'node list'] list of cluster nodes separated by whitespace") print("\t [--group | -g 'name'] use the nodes listed in the named DSH group (~/.dsh/groups/$name)") diff -Nrup a/cts/logging.py b/cts/logging.py --- a/cts/logging.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/logging.py 2020-01-29 13:30:47.000000000 +0100 @@ -2,7 +2,7 @@ """ # Pacemaker targets compatibility with Python 2.6+ and 3.2+ -from __future__ import print_function, unicode_literals, absolute_import, division + __copyright__ = "Copyright (C) 2014-2016 Andrew Beekhof <andrew@beekhof.net>" __license__ = "GNU General Public License version 2 or later (GPLv2+) WITHOUT ANY WARRANTY" @@ -15,7 +15,7 @@ import time # Wrapper to detect a string under Python 2 or 3 try: - _StringType = basestring + _StringType = str except NameError: _StringType = str diff -Nrup a/cts/OCFIPraTest.py b/cts/OCFIPraTest.py --- a/cts/OCFIPraTest.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/OCFIPraTest.py 2020-01-29 13:30:46.000000000 +0100 @@ -28,13 +28,13 @@ from cts.CTSvars import * def usage(): - print("usage: " + sys.argv[0] \ + print(("usage: " + sys.argv[0] \ + " [-2]"\ + " [--ipbase|-i first-test-ip]"\ + " [--ipnum|-n test-ip-num]"\ + " [--help|-h]"\ + " [--perform|-p op]"\ - + " [number-of-iterations]") + + " [number-of-iterations]")) sys.exit(1) diff -Nrup a/cts/patterns.py b/cts/patterns.py --- a/cts/patterns.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/patterns.py 2020-01-29 13:30:47.000000000 +0100 @@ -72,7 +72,7 @@ class BasePatterns: def get_component(self, key): if key in self.components: return self.components[key] - print("Unknown component '%s' for %s" % (key, self.name)) + print(("Unknown component '%s' for %s" % (key, self.name))) return [] def get_patterns(self, key): @@ -95,7 +95,7 @@ class BasePatterns: elif key in self.search: return self.search[key] else: - print("Unknown template '%s' for %s" % (key, self.name)) + print(("Unknown template '%s' for %s" % (key, self.name))) return None class crm_lha(BasePatterns): @@ -498,7 +498,7 @@ class PatternSelector: def get_variant(self, variant): if variant in patternvariants: return patternvariants[variant] - print("defaulting to crm-base for %s" % variant) + print(("defaulting to crm-base for %s" % variant)) return self.base def get_patterns(self, variant, kind): @@ -539,7 +539,7 @@ if __name__ == '__main__': template = args[i+1] else: - print("Illegal argument " + args[i]) + print(("Illegal argument " + args[i])) - print(PatternSelector(kind)[template]) + print((PatternSelector(kind)[template])) diff -Nrup a/cts/remote.py b/cts/remote.py --- a/cts/remote.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/remote.py 2020-01-29 13:42:28.038641249 +0100 @@ -125,7 +125,7 @@ class RemoteExec: ''' def __init__(self, rsh, silent=False): - self.async = [] + #self.async = [] self.rsh = rsh self.silent = silent self.logger = LogFactory() diff -Nrup a/cts/watcher.py b/cts/watcher.py --- a/cts/watcher.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/watcher.py 2020-01-29 13:40:40.835797761 +0100 @@ -140,8 +140,8 @@ class SearchObj: self.logger.debug(message) def harvest(self, delegate=None): - async = self.harvest_async(delegate) - async.join() + async_task = self.harvest_async(delegate) + async_task.join() def harvest_async(self, delegate=None): self.log("Not implemented") diff -Nrup a/cts/CTSlab.py b/cts/CTSlab.py --- a/cts/CTSlab.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/CTSlab.py 2020-01-29 13:13:44.682342763 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 '''CTS: Cluster Testing System: Lab environment module ''' diff -Nrup a/cts/OCFIPraTest.py b/cts/OCFIPraTest.py --- a/cts/OCFIPraTest.py 2018-07-11 18:30:29.000000000 +0200 +++ b/cts/OCFIPraTest.py 2020-01-29 13:14:15.091542116 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 '''OCF IPaddr/IPaddr2 Resource Agent Test''' diff -Nrup a/fencing/fence_dummy b/fencing/fence_dummy --- a/fencing/fence_dummy 2018-07-11 18:30:29.000000000 +0200 +++ b/fencing/fence_dummy 2020-01-29 13:12:58.286040595 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 """Dummy fence agent for testing """ diff -Nrup a/fencing/regression.py.in b/fencing/regression.py.in --- a/fencing/regression.py.in 2018-07-11 18:30:29.000000000 +0200 +++ b/fencing/regression.py.in 2020-01-29 13:13:15.620153194 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 """ Regression tests for Pacemaker's stonithd """ diff -Nrup a/lrmd/regression.py.in b/lrmd/regression.py.in --- a/lrmd/regression.py.in 2018-07-11 18:30:29.000000000 +0200 +++ b/lrmd/regression.py.in 2020-01-29 13:14:44.697737130 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 """ Regression tests for Pacemaker's lrmd """