summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
diff options
context:
space:
mode:
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 531e9d9b..93bd847a 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