summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorNitin Goyal <nigoyal@redhat.com>2019-04-08 11:23:29 +0530
committerApeksha D khakharia <akhakhar@redhat.com>2019-05-23 11:10:13 +0000
commit6fbbd5f55db83fdaeff29e80582341b5116b616c (patch)
tree83773f55134d57294c3172457581e868e8ecdf74 /openshift-storage-libs
parent38ac49e0e1215161116e77069e3b773189dec8ee (diff)
Add TC expansion of block hosting volume using heketi
This TC verify the expanshion of BHV and after expanding volume verify that space is usable. Change-Id: I2621aedc1cbddcad374fe52013aba2d48acfd1e0
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/heketi_ops.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
index b0ecc7c..f8d4175 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
@@ -5,12 +5,15 @@ except ImportError:
# py2
import json
+import re
+
from glusto.core import Glusto as g
from openshiftstoragelibs import exceptions
from openshiftstoragelibs import heketi_version
from openshiftstoragelibs.utils import parse_prometheus_data
+HEKETI_BHV = re.compile(r"Id:(\S+)\s+Cluster:(\S+)\s+Name:(\S+)\s\[block\]")
HEKETI_COMMAND_TIMEOUT = g.config.get("common", {}).get(
"heketi_command_timeout", 120)
TIMEOUT_PREFIX = "timeout %s " % HEKETI_COMMAND_TIMEOUT
@@ -1551,3 +1554,34 @@ def heketi_examine_gluster(heketi_client_node, heketi_server_url):
raise exceptions.ExecutionError(msg)
return json.loads(out)
+
+
+def get_block_hosting_volume_list(
+ heketi_client_node, heketi_server_url, **kwargs):
+ """Get heketi block hosting volume list.
+
+ 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:
+ - secret : (str)|None
+ - user : (str)|None
+
+ Returns:
+ dict: block hosting volume list
+
+ Raises:
+ exceptions.ExecutionError: if command fails.
+ """
+
+ out = heketi_volume_list(
+ heketi_client_node, heketi_server_url, **kwargs)
+
+ BHV = {}
+
+ for volume in HEKETI_BHV.findall(out.strip()):
+ BHV[volume[0]] = {'Cluster': volume[1], 'Name': volume[2]}
+
+ return BHV