From 63890db6fa339aded7aaa86d99543570befc43da Mon Sep 17 00:00:00 2001 From: ShwethaHP Date: Fri, 15 Dec 2017 14:25:19 +0530 Subject: Override default volume_type configuration in gluster base class if volume type configuration is defined in the config file. Providing an option in config file to create volume with 'force' option. Change-Id: Ifeac20685f0949f7573257f30f05df6f79ce1dbd Signed-off-by: ShwethaHP --- .../glustolibs/gluster/gluster_base_class.py | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'glustolibs-gluster/glustolibs/gluster') diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py index d7297e177..ae2308140 100644 --- a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py +++ b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py @@ -181,11 +181,15 @@ class GlusterBaseClass(unittest.TestCase): Returns (bool): True if all the steps mentioned in the descriptions passes. False otherwise. """ + force_volume_create = False + if volume_create_force or cls.volume_create_force: + force_volume_create = True + # Setup Volume g.log.info("Setting up volume %s", cls.volname) ret = setup_volume(mnode=cls.mnode, all_servers_info=cls.all_servers_info, - volume_config=cls.volume, force=volume_create_force) + volume_config=cls.volume, force=force_volume_create) if not ret: g.log.error("Failed to Setup volume %s", cls.volname) return False @@ -515,6 +519,26 @@ class GlusterBaseClass(unittest.TestCase): } } + # Check if default volume_type configuration is provided in + # config yml + if (g.config.get('gluster') and + g.config['gluster'].get('volume_types')): + default_volume_type_from_config = ( + g.config['gluster']['volume_types']) + + for volume_type in default_volume_type_from_config.keys(): + if default_volume_type_from_config[volume_type]: + if volume_type in cls.default_volume_type_config: + cls.default_volume_type_config[volume_type] = ( + default_volume_type_from_config[volume_type]) + + # Create Volume with force option + cls.volume_create_force = False + if (g.config.get('gluster') and + g.config['gluster'].get('volume_create_force')): + cls.volume_create_force = ( + g.config['gluster']['volume_create_force']) + # Default volume options which is applicable for all the volumes cls.volume_options = {} if (g.config.get('gluster') and -- cgit