]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
add a new helper function for raw conf reading
authorAlfredo Deza <alfredo.deza@inktank.com>
Thu, 30 Jan 2014 20:42:58 +0000 (15:42 -0500)
committerAlfredo Deza <alfredo.deza@inktank.com>
Thu, 30 Jan 2014 20:42:58 +0000 (15:42 -0500)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/conf.py

index 63ea0ba23db5f2f390ae360a023eb187a96a20cd..e823fc328690997d47562bd504f172ca0bf5b81c 100644 (file)
@@ -26,7 +26,7 @@ class CephConf(ConfigParser.RawConfigParser):
         to be doing try/except {ConfigParser Exceptions} every time.
         """
         try:
-            #Use full parent function so we can replace it in the class 
+            #Use full parent function so we can replace it in the class
             # if desired
             return ConfigParser.RawConfigParser.get(self, section, key)
         except (ConfigParser.NoSectionError,
@@ -52,6 +52,19 @@ def load(args):
             return parse(f)
 
 
+def load_raw(args):
+    """
+    Read the actual file *as is* without parsing/modifiying it
+    so that it can be written maintaining its same properties.
+    """
+    path = '{cluster}.conf'.format(cluster=args.cluster)
+    try:
+        with open(path) as ceph_conf:
+            return ceph_conf.read()
+    except (IOError, OSError) as e:
+        raise exc.ConfigError(e)
+
+
 def write_conf(cluster, conf, overwrite):
     """ write cluster configuration to /etc/ceph/{cluster}.conf """
     import os