From: Alfredo Deza Date: Thu, 30 Jan 2014 20:42:58 +0000 (-0500) Subject: add a new helper function for raw conf reading X-Git-Tag: v1.3.5~5^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e49e0adccd01ba9b25125968b88bf38c79f9ace2;p=ceph-deploy.git add a new helper function for raw conf reading Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/conf.py b/ceph_deploy/conf.py index 63ea0ba..e823fc3 100644 --- a/ceph_deploy/conf.py +++ b/ceph_deploy/conf.py @@ -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