From 68d9451e4fa915ce23037281bf972295f0183de5 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 9 Mar 2012 15:38:04 -0800 Subject: [PATCH] More config reworkings and checks on configs for downloading that are needed... --- devstack/cfg.py | 21 +++++++++++---------- devstack/component.py | 11 ++++++++--- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/devstack/cfg.py b/devstack/cfg.py index a2b89fa1..1bfe795e 100644 --- a/devstack/cfg.py +++ b/devstack/cfg.py @@ -79,6 +79,15 @@ class IgnoreMissingConfigParser(ConfigParser.RawConfigParser): return ConfigParser.RawConfigParser.getint(self, section, option) +def make_id(section, option): + joinwhat = [] + if section is not None: + joinwhat.append(str(section)) + if option is not None: + joinwhat.append(str(option)) + return "/".join(joinwhat) + + class StackConfigParser(IgnoreMissingConfigParser): def __init__(self): IgnoreMissingConfigParser.__init__(self) @@ -86,16 +95,8 @@ class StackConfigParser(IgnoreMissingConfigParser): self.configs_fetched = dict() self.db_dsns = dict() - def _make_key(self, section, option): - joinwhat = [] - if section is not None: - joinwhat.append(str(section)) - if option is not None: - joinwhat.append(str(option)) - return "/".join(joinwhat) - def _resolve_value(self, section, option, value_gotten, auto_pw): - key = self._make_key(section, option) + key = make_id(section, option) if section in PW_SECTIONS and key not in self.pws and value_gotten: self.pws[key] = value_gotten if section == 'host' and option == 'ip': @@ -116,7 +117,7 @@ class StackConfigParser(IgnoreMissingConfigParser): return val def get(self, section, option, auto_pw=True): - key = self._make_key(section, option) + key = make_id(section, option) if key in self.configs_fetched: value = self.configs_fetched.get(key) LOG.debug("Fetched cached value [%s] for param [%s]" % (value, key)) diff --git a/devstack/component.py b/devstack/component.py index d91e299a..f9c6d4ea 100644 --- a/devstack/component.py +++ b/devstack/component.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +from devstack import cfg from devstack import downloader as down from devstack import exceptions as excp from devstack import log as logging @@ -98,17 +99,21 @@ class PkgInstallComponent(ComponentBase): uri_tuple = location_info["uri"] branch_tuple = location_info.get("branch") subdir = location_info.get("subdir") - target_loc = None + target_loc = base_dir if subdir: target_loc = sh.joinpths(base_dir, subdir) - else: - target_loc = base_dir branch = None if branch_tuple: (cfg_section, cfg_key) = branch_tuple branch = self.cfg.get(cfg_section, cfg_key) + if not branch: + msg = "No branch entry found at config location [%s]" % (cfg.make_id(cfg_section, cfg_key)) + raise excp.ConfigException(msg) (cfg_section, cfg_key) = uri_tuple uri = self.cfg.get(cfg_section, cfg_key) + if not uri: + msg = "No uri entry found at config location [%s]" % (cfg.make_id(cfg_section, cfg_key)) + raise excp.ConfigException(msg) self.tracewriter.download_happened(target_loc, uri) dirs_made = down.download(target_loc, uri, branch) #ensure this is always added so that