summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs
diff options
context:
space:
mode:
authorSri Vignesh <sselvan@redhat.com>2020-05-19 17:21:37 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-05-27 11:14:50 +0000
commit56105c6e292093bb84f417ffcaa35e0c187fb6d3 (patch)
tree828649087c1e81ff6c831e51ac180f9a2bb1f735 /openshift-storage-libs/openshiftstoragelibs
parent99778b09839f5d8b149a27e8337cf1fb953abf3e (diff)
[LibFix] Add command output validation in lib 'validate_multipath_pod'
Library 'validate_multipath_pod' execute command to get host name by providing pod name, in case it returns blank next steps will fail due to blank hostname. Change-Id: Iac329204bd9ea17b019fb40edca43db72e8c3bb8 Signed-off-by: Sri Vignesh <sselvan@redhat.com>
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_storage_libs.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_storage_libs.py b/openshift-storage-libs/openshiftstoragelibs/openshift_storage_libs.py
index c8f2372..d17edb5 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_storage_libs.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_storage_libs.py
@@ -10,6 +10,8 @@ from openshiftstoragelibs.exceptions import (
ExecutionError,
NotSupportedException,
)
+from openshiftstoragelibs.openshift_ops import (
+ oc_get_custom_resource)
from openshiftstoragelibs.openshift_version import get_openshift_version
from openshiftstoragelibs import waiter
@@ -30,9 +32,13 @@ def validate_multipath_pod(hostname, podname, hacount, mpath):
bool: True if successful, otherwise raises exception
"""
- cmd = "oc get pods -o wide | grep %s | awk '{print $7}'" % podname
- pod_nodename = cmd_run(cmd, hostname)
+ pod_nodename_list = oc_get_custom_resource(
+ hostname, 'pod', custom=':.spec.nodeName', name=podname)
+ if not pod_nodename_list:
+ raise ExecutionError(
+ "Failed to get ip for pod from hostname {}".format(hostname))
+ pod_nodename = pod_nodename_list[0]
active_node_count, enable_node_count = (1, hacount - 1)
cmd = "multipath -ll %s | grep 'status=active' | wc -l" % mpath
active_count = int(cmd_run(cmd, pod_nodename))