summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormandaltapesh <tmandal@redhat.com>2018-01-15 15:48:10 +0530
committerTapesh Mandal <tmandal@redhat.com>2018-01-18 13:16:58 +0000
commit169bcbdea5b7e6cf7ba6135627a0ecd45fb7613e (patch)
treeab07ed625e05a2e4391089d9c630ffbfb05166ca
parent89c91bf031ceab518b8f7de3232b78532b9b2ccc (diff)
Adding delete volumes function
Change-Id: I36dfea0d9c1715a015fc14183f1dce39cbc20eb2 Signed-off-by: mandaltapesh <tmandal@redhat.com>
-rw-r--r--cns-libs/cnslibs/common/heketi_libs.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/cns-libs/cnslibs/common/heketi_libs.py b/cns-libs/cnslibs/common/heketi_libs.py
index 0e913c29..79fcd69a 100644
--- a/cns-libs/cnslibs/common/heketi_libs.py
+++ b/cns-libs/cnslibs/common/heketi_libs.py
@@ -11,7 +11,9 @@ from collections import OrderedDict
from cnslibs.common.exceptions import ExecutionError, ConfigError
from cnslibs.common.heketi_ops import (setup_heketi_ssh_key,
modify_heketi_executor,
- export_heketi_cli_server, hello_heketi)
+ export_heketi_cli_server,
+ hello_heketi,
+ heketi_volume_delete)
from cnslibs.common.openshift_ops import (oc_login, switch_oc_project,
get_ocp_gluster_pod_names)
@@ -102,6 +104,29 @@ class HeketiBaseClass(unittest.TestCase):
msg = "Starting Test : %s : %s" % (self.id(), self.glustotest_run_id)
g.log.info(msg)
+ def delete_volumes(self, volume_ids):
+ """
+ Delete volumes by their IDs and raise error with list of failures
+ Input: (volume_ids) It can be a single volume ID
+ or a list of volume IDs
+ """
+ errored_ids = []
+
+ if not isinstance(volume_ids, (list, set, tuple)):
+ volume_ids = [volume_ids]
+
+ for volume_id in volume_ids:
+ out = heketi_volume_delete(
+ self.heketi_client_node, self.heketi_server_url, volume_id)
+ output_str = 'Volume %s deleted' % volume_id
+ if output_str not in out:
+ errored_ids.append(volume_id)
+
+ if errored_ids:
+ raise ExecutionError(
+ "Failed to delete following heketi volumes: "
+ "%s" % ',\n'.join(errored_ids))
+
def tearDown(self):
super(HeketiBaseClass, self).tearDown()
msg = "Ending Test: %s : %s" % (self.id(), self.glustotest_run_id)