From d5cef9552d13ff73608d123481b9171c4534c03b Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 7 Jun 2016 16:54:55 -0400 Subject: [PATCH] Make missing global config dir not fatal in tempest init Due to the complexities and inability of the python packaging infrastructure to install data files properly or consistently we have to be prepared for the case when we have no idea where the data files end up from a tempest install. Thus this commit makes tempest init not fail when it can't find the global config dir and just logs a warning that it couldn't be found. Change-Id: Iff944092228ca1ae081e8faaf10ee0048e7ea414 --- tempest/cmd/init.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tempest/cmd/init.py b/tempest/cmd/init.py index 633b9e9ea5..dc28777273 100644 --- a/tempest/cmd/init.py +++ b/tempest/cmd/init.py @@ -114,15 +114,22 @@ class TempestInit(command.Command): config_parse.write(conf_file) def copy_config(self, etc_dir, config_dir): - shutil.copytree(config_dir, etc_dir) + if os.path.isdir(config_dir): + shutil.copytree(config_dir, etc_dir) + else: + LOG.warning("Global config dir %s can't be found" % config_dir) def generate_sample_config(self, local_dir, config_dir): - conf_generator = os.path.join(config_dir, - 'config-generator.tempest.conf') + if os.path.isdir(config_dir): + conf_generator = os.path.join(config_dir, + 'config-generator.tempest.conf') - subprocess.call(['oslo-config-generator', '--config-file', - conf_generator], - cwd=local_dir) + subprocess.call(['oslo-config-generator', '--config-file', + conf_generator], + cwd=local_dir) + else: + LOG.warning("Skipping sample config generation because global " + "config dir %s can't be found" % config_dir) def create_working_dir(self, local_dir, config_dir): # Create local dir if missing