From 6831d2a71436b114e19d5f53763551f742d74567 Mon Sep 17 00:00:00 2001 From: Nitin Goyal Date: Thu, 4 Apr 2019 15:49:15 +0530 Subject: 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 --- .../openshiftstoragelibs/openshift_ops.py | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'openshift-storage-libs') diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py index 57c4dee7..b6d086a6 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) -- cgit