diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-02-10 17:14:52 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-02-10 17:17:07 +0000 |
| commit | 8723af7665d004ae088d5066b795877c7d8f890f (patch) | |
| tree | 1d2b183632035d0d0cbc53b979f327492d81a030 | |
| parent | 6f08fb4edabd0be6a61fca91b3cee15433bc110f (diff) | |
Disable ConfigParser interpolation (lp#930270)
This breaks e.g.
volume_name_template=volume-%08x
instance_name_template=instance-%08x
and is not part of the API contract anyway. We use $opt based value
interpolation.
Change-Id: I7ba566ae7c9a77322b52c67c5e1ffbffb760f0fc
| -rw-r--r-- | openstack/common/cfg.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_cfg.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py index 2562af4..23b6773 100644 --- a/openstack/common/cfg.py +++ b/openstack/common/cfg.py @@ -435,7 +435,7 @@ class Opt(object): :param cparser: a ConfigParser object :param section: a section name """ - return cparser.get(section, self.dest) + return cparser.get(section, self.dest, raw=True) def _add_to_cli(self, parser, group=None): """Makes the option available in the command line interface. diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index c93f444..8dd6352 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -469,6 +469,18 @@ class ConfigFileOptsTestCase(BaseTestCase): self.assertTrue(hasattr(self.conf, 'bar')) self.assertEquals(self.conf.bar, 'foo') + def test_conf_file_raw_value(self): + self.conf.register_opt(StrOpt('foo')) + + paths = self.create_tempfiles([('test.conf', + '[DEFAULT]\n' + 'foo = bar-%08x\n')]) + + self.conf(['--config-file', paths[0]]) + + self.assertTrue(hasattr(self.conf, 'foo')) + self.assertEquals(self.conf.foo, 'bar-%08x') + class OptGroupsTestCase(BaseTestCase): |
