summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorNitin Goyal <nigoyal@redhat.com>2019-04-04 15:49:15 +0530
committerNitin Goyal <nigoyal@redhat.com>2019-05-03 15:07:53 +0530
commit6831d2a71436b114e19d5f53763551f742d74567 (patch)
tree488b31abd4d739069c40de99b6d91aecca402095 /openshift-storage-libs
parentca0834d26675c0e11c6d3c9f92825c5f35be9e04 (diff)
Add TCs creation of block vol greater than default size of BHV
The purpose of TCs is to validate that block device size cannot be more than the block hosting volume. Change-Id: I35aac44bdc2b3e72f1de9ab167e1468ece932f14
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 57c4dee..b6d086a 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -1532,3 +1532,42 @@ def oc_get_schedulable_nodes(ocp_client):
out = command.cmd_run(cmd, ocp_client)
return out.split('\n') if out else out
+
+
+def get_default_block_hosting_volume_size(hostname, heketi_dc_name):
+ """Get the default size of block hosting volume.
+
+ Args:
+ hostname (str): Node where we want to run our commands.
+ heketi_dc_name (str): Name of heketi DC.
+
+ Raises:
+ exceptions.ExecutionError: if command fails.
+
+ Returns:
+ integer: if successful
+ """
+ heketi_pod = get_pod_name_from_dc(
+ hostname, heketi_dc_name, timeout=10)
+ cmd = 'cat /etc/heketi/heketi.json'
+ ret, out, err = oc_rsh(hostname, heketi_pod, cmd)
+ if ret or not out:
+ msg = ("Failed to get the default size of block hosting volume with"
+ " err: '%s' and output: '%s'" % (err, out))
+ g.log.error(msg)
+ raise exceptions.ExecutionError(msg)
+
+ try:
+ out = json.loads(out)
+ except ValueError:
+ msg = "Not able to load data into json format \n data: %s" % out
+ g.log.error(msg)
+ raise exceptions.ExecutionError(msg)
+
+ if ('glusterfs' in out.keys() and
+ 'block_hosting_volume_size' in out['glusterfs'].keys()):
+ return int(out['glusterfs']['block_hosting_volume_size'])
+ msg = ("Not able to get the value of "
+ "out['glusterfs']['block_hosting_volume_size'] from out:\n" % out)
+ g.log.error(msg)
+ raise exceptions.ExecutionError(msg)