diff options
author | Nitin Goyal <nigoyal@redhat.com> | 2020-02-13 15:30:51 +0530 |
---|---|---|
committer | Nitin Goyal <nigoyal@redhat.com> | 2020-02-25 18:57:51 +0530 |
commit | 237e89c33fcea281b4190c11edc25896a578ab31 (patch) | |
tree | 824d07c2cfb6026da55607d30c730fc6c64c1240 /openshift-storage-libs/openshiftstoragelibs/openshift_ops.py | |
parent | b99a12c2b8b73efb71c2c83c52878fcb4fda6bec (diff) |
[Lib] Add arg label for labeling the DC
Change-Id: I28af35fdcc27e30957e02d83e19f0a7d4211f18b
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/openshift_ops.py')
-rw-r--r-- | openshift-storage-libs/openshiftstoragelibs/openshift_ops.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py index 07a527da..aaf384d1 100644 --- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py +++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py @@ -347,7 +347,7 @@ def oc_create_pvc(hostname, sc_name=None, pvc_name_prefix="autotests-pvc", def oc_create_app_dc_with_io( hostname, pvc_name, dc_name_prefix="autotests-dc-with-app-io", - replicas=1, space_to_use=1048576): + replicas=1, space_to_use=1048576, label=None): """Create DC with app PODs and attached PVC, constantly running I/O. Args: @@ -358,6 +358,7 @@ def oc_create_app_dc_with_io( random str. replicas (int): amount of application POD replicas. space_to_use (int): value in bytes which will be used for I/O. + label (dict): dict of keys and values to add labels in DC. """ dc_name = "%s-%s" % (dc_name_prefix, utils.get_random_str()) container_data = { @@ -385,6 +386,12 @@ def oc_create_app_dc_with_io( ]}, }, } + + labels = {"name": dc_name} + if label: + label.pop("name", None) + labels.update(label) + dc_data = json.dumps({ "kind": "DeploymentConfig", "apiVersion": "v1", @@ -395,7 +402,7 @@ def oc_create_app_dc_with_io( "paused": False, "revisionHistoryLimit": 2, "template": { - "metadata": {"labels": {"name": dc_name}}, + "metadata": {"labels": labels}, "spec": { "restartPolicy": "Always", "volumes": [{ |