diff options
author | ShwethaHP <spandura@redhat.com> | 2017-12-15 14:25:19 +0530 |
---|---|---|
committer | Jonathan Holloway <jholloway@redhat.com> | 2018-01-16 06:18:24 +0000 |
commit | 63890db6fa339aded7aaa86d99543570befc43da (patch) | |
tree | 2a0cbc2d77203642180040d5926b86d308bacf91 | |
parent | faf5077586ab5c631524a434533da4e46f25abae (diff) |
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 <spandura@redhat.com>
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/gluster_base_class.py | 26 | ||||
-rw-r--r-- | tests/gluster_tests_config.yml | 2 |
2 files changed, 27 insertions, 1 deletions
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 diff --git a/tests/gluster_tests_config.yml b/tests/gluster_tests_config.yml index 70d4ec4e9..9a3689407 100644 --- a/tests/gluster_tests_config.yml +++ b/tests/gluster_tests_config.yml @@ -191,6 +191,8 @@ gluster: redundancy_count: 2 transport: tcp + volume_create_force: False + # Volume options that has to be applicable to all volume types volume_options: ## performance.quick-read: "off" |