summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-01-08 15:53:31 +0530
committerBala Konda Reddy M <bmekala@redhat.com>2020-01-09 06:34:21 +0000
commit86d16d2a98af540ba458721edc2ac8a530c01635 (patch)
tree87ed772c0cfa44807835df4e4bf81d9e0eaeb21d /glustolibs-gluster/glustolibs
parentb708cf61e66e810a9d6f1da8d3bbadcf8b38ee3b (diff)
[py2to3] Change str to list in isinstance()
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: I7663d42494bf59d74550ff4897379d35cc357db4 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/block_ops.py2
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brick_libs.py6
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_base_class.py2
-rwxr-xr-xglustolibs-gluster/glustolibs/gluster/heal_libs.py6
-rwxr-xr-xglustolibs-gluster/glustolibs/gluster/lib_utils.py24
-rw-r--r--glustolibs-gluster/glustolibs/gluster/peer_ops.py6
-rwxr-xr-xglustolibs-gluster/glustolibs/gluster/quota_libs.py2
-rw-r--r--glustolibs-gluster/glustolibs/gluster/snap_scheduler.py2
-rw-r--r--glustolibs-gluster/glustolibs/gluster/tiering_ops.py4
-rw-r--r--glustolibs-gluster/glustolibs/gluster/volume_libs.py6
-rw-r--r--glustolibs-gluster/glustolibs/gluster/volume_ops.py2
11 files changed, 31 insertions, 31 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/block_ops.py b/glustolibs-gluster/glustolibs/gluster/block_ops.py
index 8e6ff25..f51c3e4 100644
--- a/glustolibs-gluster/glustolibs/gluster/block_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/block_ops.py
@@ -56,7 +56,7 @@ def block_create(mnode, volname, blockname, servers, size=None,
block_create(mnode, volname, blockname, servers, size,
**block_args_info)
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
ha = auth = prealloc = storage = ring_buffer = ''
diff --git a/glustolibs-gluster/glustolibs/gluster/brick_libs.py b/glustolibs-gluster/glustolibs/gluster/brick_libs.py
index f840859..0ec9e87 100644
--- a/glustolibs-gluster/glustolibs/gluster/brick_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/brick_libs.py
@@ -179,10 +179,10 @@ def bring_bricks_offline(volname, bricks_list,
"""
if bring_bricks_offline_methods is None:
bring_bricks_offline_methods = ['service_kill']
- elif isinstance(bring_bricks_offline_methods, str):
+ elif not isinstance(bring_bricks_offline_methods, list):
bring_bricks_offline_methods = [bring_bricks_offline_methods]
- if isinstance(bricks_list, str):
+ if not isinstance(bricks_list, list):
bricks_list = [bricks_list]
node_list = []
@@ -281,7 +281,7 @@ def bring_bricks_online(mnode, volname, bricks_list,
if bring_bricks_online_methods is None:
bring_bricks_online_methods = ['glusterd_restart',
'volume_start_force']
- elif isinstance(bring_bricks_online_methods, str):
+ elif not isinstance(bring_bricks_online_methods, list):
bring_bricks_online_methods = [bring_bricks_online_methods]
g.log.info("Bringing bricks '%s' online with '%s'",
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
index 858741a..a8b737f 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
@@ -161,7 +161,7 @@ class GlusterBaseClass(TestCase):
list: List of IP's corresponding to the hostnames of nodes.
"""
nodes_ips = []
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
for node in nodes:
try:
diff --git a/glustolibs-gluster/glustolibs/gluster/heal_libs.py b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
index 8b7c3b4..2b0e9ed 100755
--- a/glustolibs-gluster/glustolibs/gluster/heal_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/heal_libs.py
@@ -341,7 +341,7 @@ def get_self_heal_daemon_pid(nodes):
"""
glustershd_pids = {}
_rc = True
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
cmd = r"pgrep -f glustershd | grep -v ^$$\$"
g.log.info("Executing cmd: %s on node %s" % (cmd, nodes))
@@ -447,7 +447,7 @@ def is_shd_daemonized(nodes, timeout=120):
"""
counter = 0
flag = 0
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
while counter < timeout:
ret, pids = get_self_heal_daemon_pid(nodes)
@@ -483,7 +483,7 @@ def bring_self_heal_daemon_process_offline(nodes):
bool : True on successfully bringing self-heal daemon process offline.
False otherwise
"""
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
failed_nodes = []
diff --git a/glustolibs-gluster/glustolibs/gluster/lib_utils.py b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
index f8b6cc7..e1a9182 100755
--- a/glustolibs-gluster/glustolibs/gluster/lib_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
@@ -308,7 +308,7 @@ def get_servers_bricks_dict(servers, servers_info):
get_servers_bricks_dict(g.config['servers'], g.config['servers_info'])
"""
servers_bricks_dict = OrderedDict()
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
for server in servers:
server_info = servers_info[server]
@@ -342,7 +342,7 @@ def get_servers_used_bricks_dict(mnode, servers):
get_servers_used_bricks_dict(g.config['servers'][0]['host'],
g.config['servers'])
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
servers_used_bricks_dict = OrderedDict()
@@ -389,7 +389,7 @@ def get_servers_unused_bricks_dict(mnode, servers, servers_info):
g.config['servers'],
g.config['servers_info'])
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
dict1 = get_servers_bricks_dict(servers, servers_info)
dict2 = get_servers_used_bricks_dict(mnode, servers)
@@ -429,7 +429,7 @@ def form_bricks_list(mnode, volname, number_of_bricks, servers, servers_info):
form_bricks_path(g.config['servers'](0), "testvol", 6,
g.config['servers'], g.config['servers_info'])
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
dict_index = 0
bricks_list = []
@@ -483,7 +483,7 @@ def is_rhel6(servers):
Returns:
bool:Returns True, if its RHEL-6 else returns false
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
results = g.run_parallel(servers, "cat /etc/redhat-release")
@@ -509,7 +509,7 @@ def is_rhel7(servers):
Returns:
bool:Returns True, if its RHEL-7 else returns false
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
results = g.run_parallel(servers, "cat /etc/redhat-release")
@@ -680,7 +680,7 @@ def install_epel(servers):
Example:
install_epel(["abc.com", "def.com"])
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
rt = True
@@ -734,7 +734,7 @@ def inject_msg_in_logs(nodes, log_msg, list_of_dirs=None, list_of_files=None):
Returns:
bool: True if successfully injected msg on all log files.
"""
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
if list_of_dirs is None:
@@ -858,10 +858,10 @@ def remove_service_from_firewall(nodes, firewall_service, permanent=False):
bool: True|False(Firewall removed or Failed)
"""
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
- if isinstance(firewall_service, str):
+ if not isinstance(firewall_service, list):
firewall_service = [firewall_service]
_rc = True
@@ -902,10 +902,10 @@ def add_services_to_firewall(nodes, firewall_service, permanent=False):
bool: True|False(Firewall Enabled or Failed)
"""
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
- if isinstance(firewall_service, str):
+ if not isinstance(firewall_service, list):
firewall_service = [firewall_service]
_rc = True
diff --git a/glustolibs-gluster/glustolibs/gluster/peer_ops.py b/glustolibs-gluster/glustolibs/gluster/peer_ops.py
index 55385e8..988a13c 100644
--- a/glustolibs-gluster/glustolibs/gluster/peer_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/peer_ops.py
@@ -139,7 +139,7 @@ def peer_probe_servers(mnode, servers, validate=True, time_delay=10):
Returns:
bool: True on success and False on failure.
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
else:
servers = servers[:]
@@ -195,7 +195,7 @@ def peer_detach_servers(mnode, servers, force=False, validate=True,
Returns:
bool: True on success and False on failure.
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
else:
servers = servers[:]
@@ -367,7 +367,7 @@ def is_peer_connected(mnode, servers):
bool : True on success (peer in cluster and connected), False on
failure.
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
else:
servers = servers[:]
diff --git a/glustolibs-gluster/glustolibs/gluster/quota_libs.py b/glustolibs-gluster/glustolibs/gluster/quota_libs.py
index 279b902..7462b69 100755
--- a/glustolibs-gluster/glustolibs/gluster/quota_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/quota_libs.py
@@ -97,7 +97,7 @@ def quota_fetch_daemon_pid(nodes):
"""
quotad_pids = {}
_rc = True
- if isinstance(nodes, str):
+ if not isinstance(nodes, list):
nodes = [nodes]
cmd = r"pgrep -f quotad | grep -v ^$$\$"
g.log.info("Executing cmd: %s on node %s" % (cmd, nodes))
diff --git a/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py b/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py
index 4493cf4..f0ccbf5 100644
--- a/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py
+++ b/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py
@@ -36,7 +36,7 @@ def scheduler_init(servers):
scheduler_init("abc.com")
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
cmd = "snap_scheduler.py init"
diff --git a/glustolibs-gluster/glustolibs/gluster/tiering_ops.py b/glustolibs-gluster/glustolibs/gluster/tiering_ops.py
index 7e48a48..357b3d4 100644
--- a/glustolibs-gluster/glustolibs/gluster/tiering_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/tiering_ops.py
@@ -48,7 +48,7 @@ def add_extra_servers_to_cluster(mnode, extra_servers):
add_extra_servers_to_cluster("abc.com", ['peer_node1','peer_node2'])
"""
- if isinstance(extra_servers, str):
+ if not isinstance(extra_servers, list):
extra_servers = [extra_servers]
ret = start_glusterd(servers=extra_servers)
@@ -97,7 +97,7 @@ def tier_attach(mnode, volname, num_bricks_to_add, extra_servers,
tier_attach("abc.com", testvol, '2', ['extra_server1','extra_server2'],
extra_server_info)
"""
- if isinstance(extra_servers, str):
+ if not isinstance(extra_servers, list):
extra_servers = [extra_servers]
replica = int(replica)
diff --git a/glustolibs-gluster/glustolibs/gluster/volume_libs.py b/glustolibs-gluster/glustolibs/gluster/volume_libs.py
index 36e1fc1..e5a4f4f 100644
--- a/glustolibs-gluster/glustolibs/gluster/volume_libs.py
+++ b/glustolibs-gluster/glustolibs/gluster/volume_libs.py
@@ -1143,7 +1143,7 @@ def enable_and_validate_volume_options(mnode, volname, volume_options_list,
bool: True when enabling and validating all volume options is
successful. False otherwise
"""
- if isinstance(volume_options_list, str):
+ if not isinstance(volume_options_list, list):
volume_options_list = [volume_options_list]
for option in volume_options_list:
@@ -1864,7 +1864,7 @@ def replace_brick_from_volume(mnode, volname, servers, all_servers_info,
bool: True if replacing brick from the volume is successful.
False otherwise.
"""
- if isinstance(servers, str):
+ if not isinstance(servers, list):
servers = [servers]
# Check if volume exists
@@ -2190,7 +2190,7 @@ def get_files_and_dirs_from_brick(brick_node, brick_path,
raise RuntimeError("Not specified object type to find dir/files")
skip_items = ["'.glusterfs'", "'.trashcan'"]
- if isinstance(skip, str):
+ if not isinstance(skip, list):
skip_items.append("'%s'" % skip)
exclude_pattern = ' '.join([' | grep -ve {}'.format(item)
diff --git a/glustolibs-gluster/glustolibs/gluster/volume_ops.py b/glustolibs-gluster/glustolibs/gluster/volume_ops.py
index 0b3c94b..9bc8649 100644
--- a/glustolibs-gluster/glustolibs/gluster/volume_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/volume_ops.py
@@ -573,7 +573,7 @@ def set_volume_options(mnode, volname, options):
# Check if group options are specified.
if 'group' in volume_options:
group_options = volume_options.pop('group')
- if isinstance(group_options, str):
+ if not isinstance(group_options, list):
group_options = [group_options]
for group_option in group_options:
cmd = ("gluster volume set %s group %s --mode=script" %