summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-08-30 18:58:22 +0530
committervponomar <vponomar@redhat.com>2019-09-03 12:29:39 +0000
commitf711a5f1dd6df3e661d31b723792e5682e900773 (patch)
treee0fc7bc168ea2afbd40660e7a95875045a6958ed /openshift-storage-libs/openshiftstoragelibs
parent5c2f44b77449f47c5c9f437d580c2c6a73e27af0 (diff)
Fix pep8 errors in the files of the 'openshift-storage-libs' dir
Change-Id: Iaa7deca275958d4de68601dc16d1920f3dab85f2
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/baseclass.py14
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/command.py4
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/gluster_ops.py6
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/heketi_ops.py28
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/heketi_version.py6
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py28
6 files changed, 43 insertions, 43 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
index e55ef84c..60875a2c 100644
--- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py
+++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
@@ -109,8 +109,8 @@ class BaseClass(unittest.TestCase):
g.log.info(msg)
def setUp(self):
- if (BaseClass.STOP_ON_FIRST_FAILURE and
- BaseClass.ERROR_OR_FAILURE_EXISTS):
+ if (BaseClass.STOP_ON_FIRST_FAILURE
+ and BaseClass.ERROR_OR_FAILURE_EXISTS):
self.skipTest("Test is skipped, because of the restriction "
"to one test case failure.")
@@ -306,9 +306,9 @@ class BaseClass(unittest.TestCase):
return True
def doCleanups(self):
- if (BaseClass.STOP_ON_FIRST_FAILURE and (
- self.ERROR_OR_FAILURE_EXISTS or
- self._is_error_or_failure_exists())):
+ if (BaseClass.STOP_ON_FIRST_FAILURE
+ and (self.ERROR_OR_FAILURE_EXISTS
+ or self._is_error_or_failure_exists())):
while self._cleanups:
(func, args, kwargs) = self._cleanups.pop()
msg = ("Found test case failure. Avoiding run of scheduled "
@@ -319,8 +319,8 @@ class BaseClass(unittest.TestCase):
@classmethod
def doClassCleanups(cls):
- if (BaseClass.STOP_ON_FIRST_FAILURE and
- BaseClass.ERROR_OR_FAILURE_EXISTS):
+ if (BaseClass.STOP_ON_FIRST_FAILURE
+ and BaseClass.ERROR_OR_FAILURE_EXISTS):
while cls._class_cleanups:
(func, args, kwargs) = cls._class_cleanups.pop()
msg = ("Found test case failure. Avoiding run of scheduled "
diff --git a/openshift-storage-libs/openshiftstoragelibs/command.py b/openshift-storage-libs/openshiftstoragelibs/command.py
index c164d4c0..90b669a7 100644
--- a/openshift-storage-libs/openshiftstoragelibs/command.py
+++ b/openshift-storage-libs/openshiftstoragelibs/command.py
@@ -13,8 +13,8 @@ def cmd_run(cmd, hostname, raise_on_error=True):
str: Stripped shell command's stdout value if not None.
"""
ret, out, err = g.run(hostname, cmd, "root")
- if ("no ssh connection" in err.lower() or
- "tls handshake timeout" in err.lower()):
+ if ("no ssh connection" in err.lower()
+ or "tls handshake timeout" in err.lower()):
g.ssh_close_connection(hostname)
ret, out, err = g.run(hostname, cmd, "root")
msg = ("Failed to execute command '%s' on '%s' node. Got non-zero "
diff --git a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
index 950fd077..d6f0e665 100644
--- a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
@@ -136,7 +136,7 @@ def restart_gluster_vol_brick_processes(ocp_client_node, file_vol,
if w.expired:
error_msg = ("Process ID '%s' still exists on '%s' after waiting "
"for it 60 seconds to get killed." % (
- pid, gluster_node))
+ pid, gluster_node))
g.log.error(error_msg)
raise exceptions.ExecutionError(error_msg)
@@ -229,8 +229,8 @@ def match_heketi_and_gluster_block_volumes_by_prefix(
err_msg = "Gluster and Heketi Block volume list match failed"
err_msg += "\nGluster Volumes: %s, " % gluster_vol_block_list
err_msg += "\nBlock volumes %s" % heketi_block_volumes
- err_msg += "\nDifference: %s" % (set(gluster_vol_block_list) ^
- set(heketi_block_volumes))
+ err_msg += "\nDifference: %s" % (
+ set(gluster_vol_block_list) ^ set(heketi_block_volumes))
raise AssertionError(err_msg)
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
index 78c2e073..489b8e9c 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
@@ -63,8 +63,8 @@ def heketi_cmd_run(hostname, cmd, raise_on_error=True):
g.log.error(
'Failed to run "%s" command on the "%s" host. '
'Got following error:\n%s' % (cmd, hostname, e))
- if ('connection refused' in six.text_type(e).lower() or
- 'operation timed out' in six.text_type(e).lower()):
+ if ('connection refused' in six.text_type(e).lower()
+ or 'operation timed out' in six.text_type(e).lower()):
time.sleep(1)
out = cmd_run_on_heketi_pod(cmd, raise_on_error=raise_on_error)
else:
@@ -75,8 +75,9 @@ def heketi_cmd_run(hostname, cmd, raise_on_error=True):
def _set_heketi_global_flags(heketi_server_url, **kwargs):
"""Helper function to set heketi-cli global flags."""
- heketi_server_url = (heketi_server_url if heketi_server_url else ("http:" +
- "//heketi-storage-project.cloudapps.mystorage.com"))
+ heketi_server_url = (
+ heketi_server_url if heketi_server_url else (
+ "http://heketi-storage-project.cloudapps.mystorage.com"))
json = kwargs.get("json")
secret = kwargs.get("secret")
user = kwargs.get("user")
@@ -145,8 +146,9 @@ def heketi_volume_create(heketi_client_node, heketi_server_url, size,
if heketi_cli_key is not None:
kwargs['secret'] = heketi_cli_key
- heketi_server_url = (heketi_server_url if heketi_server_url else ("http:" +
- "//heketi-storage-project.cloudapps.mystorage.com"))
+ heketi_server_url = (
+ heketi_server_url if heketi_server_url else (
+ "http://heketi-storage-project.cloudapps.mystorage.com"))
block_arg = "--block" if kwargs.get("block") else ""
clusters_arg = ("--clusters %s" % kwargs.get("clusters")
@@ -423,8 +425,8 @@ def hello_heketi(heketi_client_node, heketi_server_url, **kwargs):
g.log.error(
'Failed to run "%s" command on the "%s" host. '
'Got following error:\n%s' % (cmd, heketi_client_node, e))
- if ('connection refused' in six.text_type(e).lower() or
- 'operation timed out' in six.text_type(e).lower()):
+ if ('connection refused' in six.text_type(e).lower()
+ or 'operation timed out' in six.text_type(e).lower()):
time.sleep(1)
cmd_run_on_heketi_pod(
"curl --max-time 10 http://localhost:8080/hello")
@@ -1003,8 +1005,8 @@ def heketi_blockvolume_create(heketi_client_node, heketi_server_url, size,
auth = clusters = ha = name = None
if heketi_server_url is None:
- heketi_server_url = ("http://" +
- "heketi-storage-project.cloudapps.mystorage.com")
+ heketi_server_url = (
+ "http://heketi-storage-project.cloudapps.mystorage.com")
if 'auth' in kwargs:
auth = kwargs['auth']
@@ -1140,7 +1142,7 @@ def verify_volume_name_prefix(hostname, prefix, namespace, pvc_name,
heketi_server_url, json_arg, admin_key, user = _set_heketi_global_flags(
heketi_server_url, **kwargs)
- heketi_vol_name_prefix = "%s_%s_%s_" % (prefix, namespace, pvc_name)
+ heketi_vol_name_prefix = "%s_%s_%s_" % (prefix, namespace, pvc_name)
cmd = "heketi-cli -s %s volume list %s %s %s | grep %s" % (
heketi_server_url, json_arg, admin_key, user, heketi_vol_name_prefix)
cmd = TIMEOUT_PREFIX + cmd
@@ -1346,8 +1348,8 @@ def get_heketi_metrics(heketi_client_node, heketi_server_url,
g.log.error(
'Failed to run "%s" command on the "%s" host. '
'Got following error:\n%s' % (cmd, heketi_client_node, e))
- if ('connection refused' in six.text_type(e).lower() or
- 'operation timed out' in six.text_type(e).lower()):
+ if ('connection refused' in six.text_type(e).lower()
+ or 'operation timed out' in six.text_type(e).lower()):
time.sleep(1)
out = cmd_run_on_heketi_pod(
"curl --max-time 10 http://localhost:8080/metrics")
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_version.py b/openshift-storage-libs/openshiftstoragelibs/heketi_version.py
index c199d9cf..4b6631da 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_version.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_version.py
@@ -88,9 +88,9 @@ def _get_heketi_server_version_str(ocp_client_node=None):
err_msg = ""
for heketi_pod_line in heketi_pods.split("\n"):
heketi_pod_data = heketi_pod_line.split()
- if ("-deploy" in heketi_pod_data[0] or
- heketi_pod_data[1].lower() != "1/1" or
- heketi_pod_data[2].lower() != "running"):
+ if ("-deploy" in heketi_pod_data[0]
+ or heketi_pod_data[1].lower() != "1/1"
+ or heketi_pod_data[2].lower() != "running"):
continue
try:
pod_cmd = "oc exec %s -- %s" % (
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 6677bb86..d3cd1724 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -655,11 +655,10 @@ def get_gluster_host_ips_by_pvc_name(ocp_node, pvc_name):
]
elif sp == "gluster.org/glusterblock":
get_gluster_pod_node_ip_cmd = (
- r"""oc get pv --template '{{range .items}}""" +
- r"""{{if eq .spec.claimRef.name "%s"}}""" +
- r"""{{.spec.iscsi.targetPortal}}{{" "}}""" +
- r"""{{.spec.iscsi.portals}}{{end}}{{end}}'""") % (
- pvc_name)
+ r"""oc get pv --template '{{range .items}}"""
+ + r"""{{if eq .spec.claimRef.name "%s"}}"""
+ + r"""{{.spec.iscsi.targetPortal}}{{" "}}"""
+ + r"""{{.spec.iscsi.portals}}{{end}}{{end}}'""") % pvc_name
node_ips_raw = command.cmd_run(
get_gluster_pod_node_ip_cmd, hostname=ocp_node)
node_ips_raw = node_ips_raw.replace(
@@ -1120,8 +1119,7 @@ def get_pv_name_from_pvc(hostname, pvc_name):
cmd = ("oc get pvc %s -o=custom-columns=:."
"spec.volumeName" % pvc_name)
pv_name = command.cmd_run(cmd, hostname=hostname)
- g.log.info("pv name is %s for pvc %s" % (
- pv_name, pvc_name))
+ g.log.info("pv name is %s for pvc %s" % (pv_name, pvc_name))
return pv_name
@@ -1301,8 +1299,8 @@ def match_pv_and_heketi_block_volumes(
err_msg = "PV block volumes and Heketi Block volume list match failed"
err_msg += "\nPV Block Volumes: %s, " % pv_block_volumes
err_msg += "\nHeketi Block volumes %s" % heketi_block_volumes
- err_msg += "\nDifference: %s" % (set(pv_block_volumes) ^
- set(heketi_block_volumes))
+ err_msg += "\nDifference: %s" % (
+ set(pv_block_volumes) ^ set(heketi_block_volumes))
raise AssertionError(err_msg)
@@ -1336,8 +1334,8 @@ def check_service_status_on_pod(
for line in out.splitlines():
status_match = re.search(SERVICE_STATUS_REGEX, line)
- if (status_match and status_match.group(1) == status and
- status_match.group(2) == state):
+ if (status_match and status_match.group(1) == status
+ and status_match.group(2) == state):
return True
if w.expired:
@@ -1373,8 +1371,8 @@ def wait_for_service_status_on_gluster_pod_or_node(
raise_on_error=raise_on_error)
for line in out.splitlines():
status_match = re.search(SERVICE_STATUS_REGEX, line)
- if (status_match and status_match.group(1) == status and
- status_match.group(2) == state):
+ if (status_match and status_match.group(1) == status
+ and status_match.group(2) == state):
return True
if w.expired:
g.log.error(err_msg)
@@ -1479,8 +1477,8 @@ def get_default_block_hosting_volume_size(hostname, heketi_dc_name):
g.log.error(msg)
raise exceptions.ExecutionError(msg)
- if ('glusterfs' in out.keys() and
- 'block_hosting_volume_size' in out['glusterfs'].keys()):
+ if ('glusterfs' in out.keys()
+ and 'block_hosting_volume_size' in out['glusterfs'].keys()):
return int(out['glusterfs']['block_hosting_volume_size'])
msg = ("Not able to get the value of "
"out['glusterfs']['block_hosting_volume_size'] from out:\n" % out)