summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs/node_ops.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-11-28 17:57:44 +0530
committerValerii Ponomarov <vponomar@redhat.com>2019-11-28 19:04:08 +0530
commit0a86502c92a4be3818b8b6abe3601af02b949cc6 (patch)
tree926b565c394dde88f264bacd13d5e8f76f7420e9 /openshift-storage-libs/openshiftstoragelibs/node_ops.py
parent985cc6bf7bfa25ee8aba0735770583a89a7f9319 (diff)
Fix str/list/tuple distinguishing in library functions to support py3
We try to distinguish strings from other iterable object types in several our library functions and now it is not compatible with py3. The problem is that in py2 strings don't have "__iter__" method, but it exists in case of py3. So, fix it by using py2/3 compatible check for string types. Change-Id: I3f833b5e79f1563a3ae6a2bb9ae43d8919d82c30
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/node_ops.py')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/node_ops.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/node_ops.py b/openshift-storage-libs/openshiftstoragelibs/node_ops.py
index 5811e157..74e67998 100644
--- a/openshift-storage-libs/openshiftstoragelibs/node_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/node_ops.py
@@ -2,6 +2,7 @@ import time
from glustolibs.gluster.exceptions import ExecutionError
from glusto.core import Glusto as g
+import six
from openshiftstoragelibs.cloundproviders.vmware import VmWare
from openshiftstoragelibs import command
@@ -194,7 +195,7 @@ def node_add_iptables_rules(node, chain, rules, raise_on_error=True):
AssertionError: In case command fails to execute and
raise_on_error set to True
"""
- rules = rules if hasattr(rules, '__iter__') else [rules]
+ rules = [rules] if isinstance(rules, six.string_types) else rules
add_iptables_rule_cmd = "iptables --append %s %s"
check_iptables_rule_cmd = "iptables --check %s %s"
@@ -221,7 +222,7 @@ def node_delete_iptables_rules(node, chain, rules, raise_on_error=True):
AssertionError: In case command fails to execute and
raise_on_error set to True
"""
- rules = rules if hasattr(rules, '__iter__') else [rules]
+ rules = [rules] if isinstance(rules, six.string_types) else rules
delete_iptables_rule_cmd = "iptables --delete %s %s"
for rule in rules: