Load basic default config

This patch reduce the requirements of the values in the
defaults-overrides file when the user run the tool without
it.

Change-Id: I2a6d375598ee39789f81da750ba02783da2a83c2
This commit is contained in:
Arx Cruz 2018-05-11 10:57:54 +02:00
parent f13dfbfe07
commit ff5fbcbdb3
2 changed files with 40 additions and 0 deletions

View File

@ -72,6 +72,39 @@ def set_logging(debug, verbose):
LOG.setLevel(logging.INFO)
def load_basic_defaults(conf):
"""Load basic default options into conf file.
:type conf: TempestConf object
"""
LOG.debug("Setting basic default values")
default_values = {
"identity": [
("username", "demo"),
("password", "secrete"),
("tenant_name", "demo"),
("alt_username", "alt_demo"),
("alt_password", "secrete"),
("alt_tenant_name", "alt_demo")
],
"scenario": [
("img_dir", "etc")
],
"auth": [
("tempest_roles", "_member_"),
("admin_username", "admin"),
("admin_project_name", "admin"),
("admin_domain_name", "Default")
]}
for section in default_values.keys():
if not conf.has_section(section):
conf.add_section(section)
for key, value in default_values[section]:
if not conf.has_option(section, key):
conf.set(section, key, value)
def read_deployer_input(deployer_input_file, conf):
"""Read deployer-input file and set values in conf accordingly.
@ -112,6 +145,8 @@ def set_options(conf, deployer_input, non_admin, overrides=[],
if os.path.isfile(C.DEFAULTS_FILE):
LOG.info("Reading defaults from file '%s'", C.DEFAULTS_FILE)
conf.read(C.DEFAULTS_FILE)
else:
load_basic_defaults(conf)
if deployer_input and os.path.isfile(deployer_input):
read_deployer_input(deployer_input, conf)

View File

@ -0,0 +1,5 @@
---
features:
- |
Remove the requirement of a default-overrides.conf file when user is not
executing python-tempestconf inside an initialized tempest directory.