Merge "Use cfg's new group autocreation feature"

This commit is contained in:
Jenkins 2012-06-05 17:56:00 +00:00 committed by Gerrit Code Review
commit b75efede1a

View File

@ -94,45 +94,38 @@ def setup_logging(conf):
def register_str(*args, **kw): def register_str(*args, **kw):
conf = kw.pop('conf', CONF) conf = kw.pop('conf', CONF)
group = _ensure_group(kw, conf) group = kw.pop('group', None)
return conf.register_opt(cfg.StrOpt(*args, **kw), group=group) return conf.register_opt(cfg.StrOpt(*args, **kw), group=group)
def register_cli_str(*args, **kw): def register_cli_str(*args, **kw):
conf = kw.pop('conf', CONF) conf = kw.pop('conf', CONF)
group = _ensure_group(kw, conf) group = kw.pop('group', None)
return conf.register_cli_opt(cfg.StrOpt(*args, **kw), group=group) return conf.register_cli_opt(cfg.StrOpt(*args, **kw), group=group)
def register_bool(*args, **kw): def register_bool(*args, **kw):
conf = kw.pop('conf', CONF) conf = kw.pop('conf', CONF)
group = _ensure_group(kw, conf) group = kw.pop('group', None)
return conf.register_opt(cfg.BoolOpt(*args, **kw), group=group) return conf.register_opt(cfg.BoolOpt(*args, **kw), group=group)
def register_cli_bool(*args, **kw): def register_cli_bool(*args, **kw):
conf = kw.pop('conf', CONF) conf = kw.pop('conf', CONF)
group = _ensure_group(kw, conf) group = kw.pop('group', None)
return conf.register_cli_opt(cfg.BoolOpt(*args, **kw), group=group) return conf.register_cli_opt(cfg.BoolOpt(*args, **kw), group=group)
def register_int(*args, **kw): def register_int(*args, **kw):
conf = kw.pop('conf', CONF) conf = kw.pop('conf', CONF)
group = _ensure_group(kw, conf) group = kw.pop('group', None)
return conf.register_opt(cfg.IntOpt(*args, **kw), group=group) return conf.register_opt(cfg.IntOpt(*args, **kw), group=group)
def register_cli_int(*args, **kw): def register_cli_int(*args, **kw):
conf = kw.pop('conf', CONF) conf = kw.pop('conf', CONF)
group = _ensure_group(kw, conf)
return conf.register_cli_opt(cfg.IntOpt(*args, **kw), group=group)
def _ensure_group(kw, conf):
group = kw.pop('group', None) group = kw.pop('group', None)
if group: return conf.register_cli_opt(cfg.IntOpt(*args, **kw), group=group)
conf.register_group(cfg.OptGroup(name=group))
return group
CONF = CommonConfig(project='keystone') CONF = CommonConfig(project='keystone')