From 56105c6e292093bb84f417ffcaa35e0c187fb6d3 Mon Sep 17 00:00:00 2001 From: Sri Vignesh Date: Tue, 19 May 2020 17:21:37 +0530 Subject: [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 --- .../openshiftstoragelibs/openshift_storage_libs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'openshift-storage-libs/openshiftstoragelibs') diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_storage_libs.py b/openshift-storage-libs/openshiftstoragelibs/openshift_storage_libs.py index c8f2372a..d17edb5b 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)) -- cgit