summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/lib_utils.py
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/gluster/lib_utils.py
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/gluster/lib_utils.py')
-rwxr-xr-xglustolibs-gluster/glustolibs/gluster/lib_utils.py24
1 files changed, 12 insertions, 12 deletions
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