summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorNitin Goyal <nigoyal@redhat.com>2020-11-17 11:20:34 +0530
committerNitin Goyal <nigoyal@redhat.com>2020-12-08 11:41:03 +0530
commit245d04454acd4e95640c0f9ca598ac53d340181f (patch)
treeff6e59da697a6bb472cf2019b382d00c8f0cce48 /openshift-storage-libs
parentd6eaf768798f7e0069350cb33ff71433958dd73c (diff)
[Lib] Add lib is_job_complete
Lib will check the job completion status Change-Id: Ifbcdc9f18e4d3af5b290982eb4a084459877f91b Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index b91b7fc..0ed293d 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -2124,3 +2124,23 @@ def oc_create_offline_block_volume_expand_job(
oc_create(hostname, job_data, 'stdin')
return job_name
+
+
+def is_job_complete(hostname, job_name, namespace=""):
+ """Check job completion status
+
+ Args:
+ hostname (str): Hostname on which we want to run command
+ job_name (str): k8s job name
+ namespace (str): k8s namespace name
+ Return:
+ bool
+ """
+
+ cmd = ['oc', 'get', 'jobs', '-o=custom-columns=:.status.succeeded',
+ '--no-headers', job_name]
+
+ cmd += ['-n', namespace] if namespace else []
+
+ out = command.cmd_run(cmd, hostname=hostname)
+ return out == "1"