Move oslo config generator config inside package

This commit moves the oslo config generator config file from living as
a data file, which makes it very difficult to rely on, to just living
in the package. By including it in the package we have a guaranteed
relative path we can rely on for building utilities on it, like the
tempest init command.

Change-Id: I5b9deae733f42fe3ed39418103304f71b43dccb3
Partially-implements: bp tempest-run-cmd
This commit is contained in:
Matthew Treinish 2016-06-21 18:06:49 -04:00
parent 73c449834b
commit bdef1c77ab
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177
5 changed files with 13 additions and 17 deletions

View File

@ -34,7 +34,7 @@ extensions = ['sphinx.ext.autodoc',
'oslo_config.sphinxconfiggen',
]
config_generator_config_file = '../../etc/config-generator.tempest.conf'
config_generator_config_file = '../../tempest/cmd/config-generator.tempest.conf'
sample_config_basename = '_static/tempest'
todo_include_todos = True

View File

@ -18,6 +18,7 @@ import subprocess
import sys
from cliff import command
from oslo_config import generator
from oslo_log import log as logging
from six import moves
@ -125,17 +126,16 @@ class TempestInit(command.Command):
else:
LOG.warning("Global config dir %s can't be found" % config_dir)
def generate_sample_config(self, local_dir, config_dir):
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)
def generate_sample_config(self, local_dir):
conf_generator = os.path.join(os.path.dirname(__file__),
'config-generator.tempest.conf')
output_file = os.path.join(local_dir, 'etc/tempest.conf.sample')
if os.path.isfile(conf_generator):
generator.main(['--config-file', conf_generator, '--output-file',
output_file])
else:
LOG.warning("Skipping sample config generation because global "
"config dir %s can't be found" % config_dir)
"config file %s can't be found" % conf_generator)
def create_working_dir(self, local_dir, config_dir):
# Create local dir if missing
@ -162,7 +162,7 @@ class TempestInit(command.Command):
# Create and copy local etc dir
self.copy_config(etc_dir, config_dir)
# Generate the sample config file
self.generate_sample_config(local_dir, config_dir)
self.generate_sample_config(local_dir)
# Update local confs to reflect local paths
self.update_local_conf(config_path, lock_dir, log_dir)
# Generate a testr conf file

View File

@ -13,7 +13,6 @@
# under the License.
import os
import shutil
import fixtures
@ -43,15 +42,12 @@ class TestTempestInit(base.TestCase):
local_dir = self.useFixture(fixtures.TempDir())
etc_dir_path = os.path.join(local_dir.path, 'etc/')
os.mkdir(etc_dir_path)
tmp_dir = self.useFixture(fixtures.TempDir())
config_dir = os.path.join(tmp_dir.path, 'config/')
shutil.copytree('etc/', config_dir)
init_cmd = init.TempestInit(None, None)
local_sample_conf_file = os.path.join(etc_dir_path,
'tempest.conf.sample')
# Verify no sample config file exist
self.assertFalse(os.path.isfile(local_sample_conf_file))
init_cmd.generate_sample_config(local_dir.path, config_dir)
init_cmd.generate_sample_config(local_dir.path)
# Verify sample config file exist with some content
self.assertTrue(os.path.isfile(local_sample_conf_file))

View File

@ -28,7 +28,7 @@ commands =
bash tools/pretty_tox.sh '{posargs}'
[testenv:genconfig]
commands = oslo-config-generator --config-file etc/config-generator.tempest.conf
commands = oslo-config-generator --config-file tempest/cmd/config-generator.tempest.conf
[testenv:cover]
setenv = OS_TEST_PATH=./tempest/tests