updated so empty keys are handled better in cfg/env

This commit is contained in:
Joshua Harlow 2012-03-07 12:10:24 -08:00
parent 7d76cc3366
commit 89d6ac4516
2 changed files with 9 additions and 6 deletions

View File

@ -30,6 +30,7 @@ PW_TMPL = "Enter a password for %s: "
ENV_PAT = re.compile(r"^\s*\$\{([\w\d]+):\-(.*)\}\s*$")
SUB_MATCH = re.compile(r"(?:\$\(([\w\d]+):([\w\d]+))\)")
CACHE_MSG = "(value will now be internally cached)"
PW_SECTIONS = ['passwords']
DEF_PW_MSG = "[or press enter to get a generated one]"
PW_PROMPTS = {
'horizon_keystone_admin': "Enter a password to use for horizon and keystone (20 chars or less) %s: " % (DEF_PW_MSG),
@ -95,14 +96,13 @@ class StackConfigParser(IgnoreMissingConfigParser):
def _resolve_special(self, section, option, value_gotten, auto_pw):
key = self._makekey(section, option)
if value_gotten and len(value_gotten):
if section == 'passwords':
self.pws[key] = value_gotten
elif section == 'host' and option == 'ip':
if section in PW_SECTIONS and key not in self.pws:
self.pws[key] = value_gotten
if section == 'host' and option == 'ip':
LOG.debug("Host ip from configuration/environment was empty, programatically attempting to determine it.")
value_gotten = utils.get_host_ip()
LOG.debug("Determined your host ip to be: \"%s\"" % (value_gotten))
elif section == 'passwords' and auto_pw:
elif section in PW_SECTIONS and auto_pw and len(value_gotten) == 0:
LOG.debug("Being forced to ask for password for \"%s\" since the configuration value is empty.", key)
prompt = PW_PROMPTS.get(option, PW_TMPL % (key))
value_gotten = sh.password(prompt)

View File

@ -65,7 +65,10 @@ class RcGenerator(object):
def _make_export_cfg(self, export_name, cfg_section_key, default_val=''):
(section, key) = cfg_section_key
value = self.cfg.getdefaulted(section, key, default_val, auto_pw=False)
return self._make_export(export_name, value)
if len(value) != 0:
return self._make_export(export_name, value)
else:
return list()
def _generate_ec2_env(self):
lines = list()