From 3de3cde07ee9968c9ef9e5aa5fc9d3846ef6d49c Mon Sep 17 00:00:00 2001 From: Sri Vignesh Date: Tue, 7 Jan 2020 16:25:39 +0530 Subject: [py2to3] Fix file gluster_init.py - Use 'list' object type in comparisons instead of 'str'. Because it is differently treated in py2 and py3. Example: # In py2 isinstance(u'foo', str) is False # In py3 isinstance(u'foo', str) is True Change-Id: Ic0a5c1469e9951ee9b2472714004b05e2c5fdc94 Signed-off-by: Sri Vignesh --- glustolibs-gluster/glustolibs/gluster/gluster_init.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'glustolibs-gluster/glustolibs') diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_init.py b/glustolibs-gluster/glustolibs/gluster/gluster_init.py index 10812c289..7467479b4 100644 --- a/glustolibs-gluster/glustolibs/gluster/gluster_init.py +++ b/glustolibs-gluster/glustolibs/gluster/gluster_init.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2015-2016 Red Hat, Inc. +# Copyright (C) 2015-2020 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 @@ -33,7 +33,7 @@ def start_glusterd(servers): bool : True if starting glusterd is successful on all servers. False otherwise. """ - if isinstance(servers, str): + if not isinstance(servers, list): servers = [servers] cmd = "pgrep glusterd || service glusterd start" @@ -62,7 +62,7 @@ def stop_glusterd(servers): bool : True if stopping glusterd is successful on all servers. False otherwise. """ - if isinstance(servers, str): + if not isinstance(servers, list): servers = [servers] cmd = "service glusterd stop" @@ -91,7 +91,7 @@ def restart_glusterd(servers): bool : True if restarting glusterd is successful on all servers. False otherwise. """ - if isinstance(servers, str): + if not isinstance(servers, list): servers = [servers] cmd = "service glusterd restart" @@ -122,7 +122,7 @@ def is_glusterd_running(servers): -1 : if glusterd not running and PID is alive """ - if isinstance(servers, str): + if not isinstance(servers, list): servers = [servers] cmd1 = "service glusterd status" @@ -157,7 +157,7 @@ def env_setup_servers(servers): False otherwise. """ - if isinstance(servers, str): + if not isinstance(servers, list): servers = [servers] g.log.info("The function isn't implemented fully") @@ -175,7 +175,7 @@ def get_glusterd_pids(nodes): return the process id's in dictionary format Args: - nodes ( str|list ) : Node/Nodes of the cluster + nodes (str|list) : Node(s) of the cluster Returns: tuple : Tuple containing two elements (ret, gluster_pids). @@ -190,7 +190,7 @@ def get_glusterd_pids(nodes): """ glusterd_pids = {} _rc = True - if isinstance(nodes, str): + if not isinstance(nodes, list): nodes = [nodes] cmd = "pidof glusterd" -- cgit