]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[6348] ceph-deploy should use same option seperator 90/head
authorAndrew Woodward <awoodward@mirantis.com>
Tue, 24 Sep 2013 18:24:17 +0000 (11:24 -0700)
committerAndrew Woodward <awoodward@mirantis.com>
Tue, 24 Sep 2013 18:43:53 +0000 (11:43 -0700)
define subclass for Ceph config files.
make new.new and conf.load use new CephConf
add test case for config writing.

Signed-off-by: Andrew Woodward (awoodward@mirantis.com)
ceph_deploy/conf.py
ceph_deploy/new.py
ceph_deploy/tests/test_conf.py

index a7b97a4baac26a0886c59f3a9656d9861e8f959d..3fcdd2195de85c48a3ee63eab36329b23c52215c 100644 (file)
@@ -13,15 +13,15 @@ class _TrimIndentFile(object):
         return line.lstrip(' \t')
 
 
-def _optionxform(s):
-    s = s.replace('_', ' ')
-    s = '_'.join(s.split())
-    return s
+class CephConf(ConfigParser.RawConfigParser):
+    def optionxform(self, s):
+        s = s.replace('_', ' ')
+        s = '_'.join(s.split())
+        return s
 
 
 def parse(fp):
-    cfg = ConfigParser.RawConfigParser()
-    cfg.optionxform = _optionxform
+    cfg = CephConf()
     ifp = _TrimIndentFile(fp)
     cfg.readfp(ifp)
     return cfg
index 404d395cb8380299ea617d53213c4fe3b1211ee9..9a0945be9d89e64fcfd30c1d8889f187f9e707e7 100644 (file)
@@ -10,6 +10,7 @@ import socket
 
 from . import exc
 from .cliutil import priority
+from .conf import CephConf
 from .util import arg_validators
 from .misc import mon_hosts
 
@@ -42,7 +43,7 @@ def get_nonlocal_ip(host):
 
 def new(args):
     LOG.debug('Creating new cluster named %s', args.cluster)
-    cfg = ConfigParser.RawConfigParser()
+    cfg = CephConf()
     cfg.add_section('global')
 
     fsid = uuid.uuid4()
index faa36887166e61dc1498cbef7b4fcfde9a64d7b4..79796c670c8abec4666f757e56d75013cd574833 100644 (file)
@@ -57,3 +57,12 @@ bar__ thud   quux = baz
     cfg = conf.parse(f)
     assert cfg.get('foo', 'bar_thud_quux') == 'baz'
     assert cfg.get('foo', 'bar thud quux') == 'baz'
+
+def test_write_words_underscore():
+    cfg = conf.CephConf()
+    cfg.add_section('foo')
+    cfg.set('foo', 'bar thud quux', 'baz')
+    f = StringIO()
+    cfg.write(f)
+    f.reset()
+    assert f.readlines() == ['[foo]\n', 'bar_thud_quux = baz\n','\n']