summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs
diff options
context:
space:
mode:
authorSri Vignesh <sselvan@redhat.com>2020-05-29 16:39:51 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-06-01 11:57:27 +0000
commitf58761cbe59c30237a55938322b2d9f553e9fce4 (patch)
tree75f3393d45f79e9eb2bc469b73b52d1b4b03592b /openshift-storage-libs/openshiftstoragelibs
parent38d6106c7d5bbda02a08bef57efb72dc5892a62f (diff)
[LibFix] Add parameter 'overwrite' in 'oc_label' library
Change-Id: I7f765605ae032f9054937ca9ed5a5db06bc73464 Signed-off-by: Sri Vignesh <sselvan@redhat.com>
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/baseclass.py3
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py8
2 files changed, 8 insertions, 3 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
index d05fb2c..2d6ba69 100644
--- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py
+++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py
@@ -544,7 +544,8 @@ class BaseClass(unittest.TestCase):
gluster_host_label = "glusterfs=storage-host"
gluster_pod_label = "glusterfs=storage-pod"
oc_label(
- self.ocp_client[0], "node", storage_hostname, gluster_host_label)
+ self.ocp_client[0], "node", storage_hostname, gluster_host_label,
+ overwrite=True)
self.addCleanup(
wait_for_pods_be_ready,
self.ocp_client[0], len(self.gluster_servers),
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 531e9d9..93bd847 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -612,17 +612,21 @@ def oc_get_all_pvs(ocp_node):
return oc_get_yaml(ocp_node, 'pv', None)
-def oc_label(hostname, rtype, rname, label):
+def oc_label(hostname, rtype, rname, label, overwrite=False):
"""Add label for given resource
Args:
hostname (str): Node where we want to run our commands.
rtype (str): Type of resource.
rname (str): Name of resource.
+ overwrite(bool): True if glusterfs already has a value.
+ False by default.
Raises:
AssertionError: In case adding label to resource fails.
"""
- cmd = "oc label %s %s %s" % (rtype, rname, label)
+ cmd = "oc label {} {} {}".format(rtype, rname, label)
+ if overwrite:
+ cmd += " --overwrite"
out = command.cmd_run(cmd, hostname=hostname)
return out