summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
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/openshift_ops.py
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/openshift_ops.py')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py8
1 files changed, 6 insertions, 2 deletions
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