summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorNitin Goyal <nigoyal@redhat.com>2020-11-30 15:29:41 +0530
committerNitin Goyal <nigoyal@redhat.com>2020-12-09 19:39:13 +0530
commit95321df5195b2964a12bb6bd0d8d544e9131083b (patch)
treebd9a5aa0e5b8e04939d3be2517def947098f97f9 /openshift-storage-libs
parent5824364e65321851730b6955b0dd5eec4b8dd04f (diff)
[Lib] Add lib 'heketi_brick_evict'
Change-Id: I3fe4d9befc233e0c9c52839df7c722d9e291a22c Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/heketi_ops.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
index 877f0f84..30e08f0f 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
@@ -2116,3 +2116,40 @@ def validate_dev_path_vg_and_uuid(
# Compare the uuid from node and heketi
return n_uuid == h_uuid
+
+
+def heketi_brick_evict(heketi_client_node, heketi_server_url, brick_id,
+ raise_on_error=True, **kwargs):
+ """Executes heketi brick evict command.
+
+ Args:
+ heketi_client_node (str): Node on which cmd has to be executed.
+ heketi_server_url (str): Heketi server url
+ brick_id (str): Brick ID
+ raise_on_error (bool): whether or not to raise exception
+ in case of an error.
+
+ Kwargs:
+ The keys, values in kwargs are:
+ - secret : (str)|None
+ - user : (str)|None
+
+ Raises:
+ exceptions.ExecutionError: if command fails.
+ """
+
+ version = heketi_version.get_heketi_version(heketi_client_node)
+ if version < '9.0.0-13':
+ msg = (
+ "heketi-client package {} does not support brick evict".format(
+ version.v_str))
+ raise NotImplementedError(msg)
+
+ heketi_server_url, _, admin_key, user = _set_heketi_global_flags(
+ heketi_server_url, **kwargs)
+
+ cmd = "heketi-cli -s {} brick evict {} {} {}".format(
+ heketi_server_url, brick_id, admin_key, user)
+ cmd = TIMEOUT_PREFIX + cmd
+ heketi_cmd_run(
+ heketi_client_node, cmd, raise_on_error=raise_on_error)