From: Sage Weil Date: Sun, 10 Mar 2013 06:47:59 +0000 (-0800) Subject: config: add 'config HOST ...' command X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8d0ab22a440f260f729cee3e0c1cdd74de1fb0ea;p=ceph-deploy.git config: add 'config HOST ...' command Signed-off-by: Sage Weil --- diff --git a/ceph_deploy/config.py b/ceph_deploy/config.py new file mode 100644 index 0000000..fd2e317 --- /dev/null +++ b/ceph_deploy/config.py @@ -0,0 +1,55 @@ +import argparse +import logging +import os.path + +from cStringIO import StringIO + +from . import exc +from . import conf +from .cliutil import priority + + +log = logging.getLogger(__name__) + +def admin(args): + cfg = conf.load(args) + conf_data = StringIO() + cfg.write(conf_data) + + errors = 0 + for hostname in args.client: + log.debug('Pushing config to %s', hostname) + 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, + ) + + except RuntimeError as e: + log.error(e) + errors += 1 + + if errors: + raise exc.GenericError('Failed to config %d hosts' % errors) + + +@priority(70) +def make(parser): + """ + Push configuration file to a remote host. + """ + parser.add_argument( + 'client', + metavar='HOST', + nargs='*', + help='host to configure', + ) + parser.set_defaults( + func=admin, + ) diff --git a/setup.py b/setup.py index 3a85929..14d1f02 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,7 @@ setup( 'osd = ceph_deploy.osd:make', 'mds = ceph_deploy.mds:make', 'forgetkeys = ceph_deploy.forgetkeys:make', + 'config = ceph_deploy.config:make', 'admin = ceph_deploy.admin:make', 'zapdisk = ceph_deploy.zapdisk:make', ],