summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/node_ops.py5
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py15
2 files changed, 12 insertions, 8 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/node_ops.py b/openshift-storage-libs/openshiftstoragelibs/node_ops.py
index 5811e15..74e6799 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:
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 4e668d6..249a1b5 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -712,7 +712,8 @@ def scale_dcs_pod_amount_and_wait(hostname, dc_names, pod_amount=1,
"dc_name_n": ["pod_name_n_1", "pod_name_n_2", ..., "pod_name_n_n"],
}
"""
- dc_names = dc_names if hasattr(dc_names, '__iter__') else [dc_names]
+ dc_names = (
+ [dc_names] if isinstance(dc_names, six.string_types) else dc_names)
dc_and_pod_names = {}
namespace_arg = "--namespace=%s" % namespace if namespace else ""
scale_cmd = "oc scale %s --replicas=%d dc/%s" % (
@@ -1827,8 +1828,10 @@ def oc_annotate(hostname, rtype, rname, annotations):
Raises:
AssertionError: In case adding annotations to resource fails.
"""
- annotations = annotations if hasattr(
- annotations, '__iter__') else [annotations]
+ annotations = (
+ [annotations]
+ if isinstance(annotations, six.string_types)
+ else annotations)
for annotation in annotations:
cmd = 'oc annotate %s %s %s --overwrite' % (rtype, rname, annotation)
command.cmd_run(cmd, hostname=hostname)
@@ -1885,9 +1888,9 @@ def oc_create_service_monitor(hostname, sm_name="heketi",
ep_namespace_selector_matchnames if ep_namespace_selector_matchnames
else ['glusterfs'])
ep_namespace_selector_matchnames = (
- ep_namespace_selector_matchnames
- if hasattr(ep_namespace_selector_matchnames, '__iter__')
- else [ep_namespace_selector_matchnames])
+ [ep_namespace_selector_matchnames]
+ if isinstance(ep_namespace_selector_matchnames, six.string_types)
+ else ep_namespace_selector_matchnames)
ep_matchlabels = (
ep_matchlabels if ep_matchlabels else {"heketi": "storage-service"})
sm_data = json.dumps({