diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-10 16:55:46 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-10 16:55:46 +0000 |
| commit | c9db396cb6473246e5ccf3072ba592ef47fd9d16 (patch) | |
| tree | 382f7498ae70b05707776ef616300b3a9105da69 /openstack | |
| parent | f6cf448b92dc1df1c1d922e03a6f44770460b9fe (diff) | |
| parent | 038d59778eecf953375da701b4cd55d4e3ca309f (diff) | |
| download | oslo-c9db396cb6473246e5ccf3072ba592ef47fd9d16.tar.gz oslo-c9db396cb6473246e5ccf3072ba592ef47fd9d16.tar.xz oslo-c9db396cb6473246e5ccf3072ba592ef47fd9d16.zip | |
Merge "Add import_opt() method to ConfigOpts"
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/cfg.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py index 728ecdc..b42c30e 100644 --- a/openstack/common/cfg.py +++ b/openstack/common/cfg.py @@ -1156,6 +1156,25 @@ class ConfigOpts(collections.Mapping): for opt in opts: self.unregister_opt(opt, group, clear_cache=False) + def import_opt(self, name, module_str, group=None): + """Import an option definition from a module. + + Import a module and check that a given option is registered. + + This is intended for use with global configuration objects + like cfg.CONF where modules commonly register options with + CONF at module load time. If one module requires an option + defined by another module it can use this method to explicitly + declare the dependency. + + :param name: the name/dest of the opt + :param module_str: the name of a module to import + :param group: an option OptGroup object or group name + :raises: NoSuchOptError, NoSuchGroupError + """ + __import__(module_str) + self._get_opt_info(name, group) + @__clear_cache def set_override(self, name, override, group=None): """Override an opt value. |
