From 93570a501b0f7efe3c451f2e543af4eb579ea206 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Oct 2019 10:32:00 -0500 Subject: [PATCH] ceph-daemon: make ConfigParser py2 compatible Signed-off-by: Sage Weil --- src/ceph-daemon | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ceph-daemon b/src/ceph-daemon index 949af8ffb27e2..9ac185a474269 100755 --- a/src/ceph-daemon +++ b/src/ceph-daemon @@ -241,8 +241,8 @@ def get_legacy_config_fsid(cluster): try: config = ConfigParser() config.read('/etc/ceph/%s.conf' % cluster) - if 'global' in config and 'fsid' in config['global']: - return config['global']['fsid'] + if config.has_section('global') and config.has_option('global', 'fsid'): + return config.get('global', 'fsid') except Exception as e: logger.warning('unable to parse \'fsid\' from \'[global]\' section of /etc/ceph/ceph.conf: %s' % e) return None @@ -760,8 +760,10 @@ def command_bootstrap(): mon_ip = args.mon_addrv.split(':')[1] else: raise RuntimeError('must specify --mon-ip or --mon-addrv') - cp['global']['fsid'] = fsid; - cp['global']['mon host'] = addr_arg + if not cp.has_section('global'): + cp.add_section('global') + cp.set('global', 'fsid', fsid); + cp.set('global', 'mon host', addr_arg) with StringIO() as f: cp.write(f) config = f.getvalue() -- 2.39.5