summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorNitin Goyal <nigoyal@redhat.com>2020-11-17 11:54:53 +0530
committerNitin Goyal <nigoyal@redhat.com>2020-12-08 11:41:03 +0530
commitf99e0fc4d1966abed8cb28fdf080d78f28a5efeb (patch)
tree2b2589d8fd9e98b19a674dfcfb613c11be1b11cc /openshift-storage-libs
parent245d04454acd4e95640c0f9ca598ac53d340181f (diff)
[Lib] Add lib heketi_blockvolume_expand
The lib will expand heketi block volume Change-Id: I0264bdc2407cf019dbb3524cbbbf29b5e9dbb9e3 Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/heketi_ops.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
index 77be788..877f0f8 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
@@ -293,6 +293,55 @@ def heketi_volume_expand(heketi_client_node, heketi_server_url, volume_id,
return out
+def heketi_blockvolume_expand(heketi_client_node, heketi_server_url,
+ blockvolume_id, new_size, raise_on_error=True,
+ **kwargs):
+ """Executes heketi blockvolume expand command.
+
+ Args:
+ heketi_client_node (str): Node on which cmd has to be executed.
+ heketi_server_url (str): Heketi server url
+ blockvolume_id (str): blockvolume ID
+ new_size (str): blockvolume net new size
+ raise_on_error (bool): whether or not to raise exception
+ in case of an error.
+
+ Kwargs:
+ The keys, values in kwargs are:
+ - json : (bool)
+ - secret : (str)|None
+ - user : (str)|None
+
+ Returns:
+ dict: if json if True, then it returns raw string output.
+ string: returns raw string output if json is False
+
+ 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 blockvolume "
+ "expand".format(version.v_str))
+ g.log.error(msg)
+ raise NotImplementedError(msg)
+
+ heketi_server_url, json_arg, admin_key, user = _set_heketi_global_flags(
+ heketi_server_url, **kwargs)
+
+ cmd = ("heketi-cli -s {} blockvolume expand {} "
+ "--new-size={} {} {} {}".format(
+ heketi_server_url, blockvolume_id, new_size, json_arg,
+ admin_key, user))
+ cmd = TIMEOUT_PREFIX + cmd
+ out = heketi_cmd_run(
+ heketi_client_node, cmd, raise_on_error=raise_on_error)
+ if json_arg and out:
+ return json.loads(out)
+ return out
+
+
def heketi_volume_delete(heketi_client_node, heketi_server_url, volume_id,
raise_on_error=True, **kwargs):
"""Executes heketi volume delete command.