From: Sage Weil Date: Sun, 10 Mar 2013 06:47:29 +0000 (-0800) Subject: admin: use the config pusher function; don't clobber X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4f8b0d0cb44d820925dcdb1249d39f5d209169f;p=ceph-deploy.git admin: use the config pusher function; don't clobber Signed-off-by: Sage Weil --- diff --git a/ceph_deploy/admin.py b/ceph_deploy/admin.py index 344a175..aef7487 100644 --- a/ceph_deploy/admin.py +++ b/ceph_deploy/admin.py @@ -5,6 +5,7 @@ import os.path from cStringIO import StringIO from . import exc +from . import conf from .cliutil import priority @@ -18,11 +19,10 @@ def write_file(path, content): pass def admin(args): - try: - with file('%s.conf' % args.cluster, 'rb') as f: - conf = f.read() - except: - raise RuntimeError('%s.conf file not present' % args.cluster) + cfg = conf.load(args) + conf_data = StringIO() + cfg.write(conf_data) + try: with file('%s.client.admin.keyring' % args.cluster, 'rb') as f: keyring = f.read() @@ -30,24 +30,39 @@ def admin(args): raise RuntimeError('%s.client.admin.keyring not found' % args.cluster) + errors = 0 for hostname in args.client: log.debug('Pushing admin keys and conf to %s', hostname) - sudo = args.pushy('ssh+sudo:{hostname}'.format( - hostname=hostname, - )) - write_file_r = sudo.compile(write_file) - error = write_file_r( - '/etc/ceph/%s.conf' % args.cluster, - conf - ) - if error is not None: - raise exc.GenericError(error) - error = write_file_r( - '/etc/ceph/%s.client.admin.keyring' % args.cluster, - keyring - ) - if error is not None: - raise exc.GenericError(error) + try: + sudo = args.pushy('ssh+sudo:{hostname}'.format( + hostname=hostname, + )) + + write_conf_r = sudo.compile(conf.write_conf) + write_conf_r( + cluster=args.cluster, + conf=conf_data.getvalue(), + overwrite=args.overwrite_conf, + ) + + sudo = args.pushy('ssh+sudo:{hostname}'.format( + hostname=hostname, + )) + write_file_r = sudo.compile(write_file) + error = write_file_r( + '/etc/ceph/%s.client.admin.keyring' % args.cluster, + keyring + ) + if error is not None: + raise exc.GenericError(error) + + except RuntimeError as e: + log.error(e) + errors += 1 + + if errors: + raise exc.GenericError('Failed to configure %d admin hosts' % errors) + @priority(70) def make(parser):