summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorvamahaja <vamahaja@redhat.com>2019-09-06 17:08:46 +0530
committervponomar <vponomar@redhat.com>2019-09-11 11:26:18 +0000
commit8c2db5c9894c4f7b90704143cdc97c919c4fe961 (patch)
tree8aa42a5123ff15c3039db1d1147676ca715c9ec0 /openshift-storage-libs
parentb8164531b9e1ab559db362b6305b953ec79940d3 (diff)
Add test cases to perform heketi cluster operations
Change-Id: I5886680a0d5666c68c677893e0fb327be0e80760 Signed-off-by: vamahaja <vamahaja@redhat.com>
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/heketi_ops.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
index 9bb3a85..f98a8d7 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
@@ -435,6 +435,50 @@ def hello_heketi(heketi_client_node, heketi_server_url, **kwargs):
return True
+def heketi_cluster_create(heketi_client_node, heketi_server_url, **kwargs):
+ """Executes heketi cluster create command with provided options.
+
+ Args:
+ heketi_client_node (str): Node on which cmd has to be executed.
+ heketi_server_url (str): Heketi server url
+
+ Kwargs:
+ The keys, values in kwargs are:
+ - json : (bool)
+ - secret : (str)|None
+ - user : (str)|None
+ - block : (bool)|None
+ - file : (bool)|None
+
+ Returns:
+ str: cluster delete command output on success
+
+ Raises:
+ exceptions.ExecutionError: if command fails.
+
+ Example:
+ heketi_cluster_create(
+ heketi_client_node, heketi_server_url, block=True)
+ """
+
+ heketi_server_url, json_arg, admin_key, user = _set_heketi_global_flags(
+ heketi_server_url, **kwargs)
+
+ cmd = "heketi-cli -s %s cluster create %s %s %s" % (
+ heketi_server_url, json_arg, admin_key, user)
+
+ if not kwargs.get("block", True):
+ cmd += " --block=false"
+ if not kwargs.get("file", True):
+ cmd += " --file=false"
+
+ cmd = TIMEOUT_PREFIX + cmd
+ out = heketi_cmd_run(heketi_client_node, cmd)
+ if kwargs.get("json", False):
+ return json.loads(out)
+ return out
+
+
def heketi_cluster_delete(heketi_client_node, heketi_server_url, cluster_id,
**kwargs):
"""Executes heketi cluster delete command.