From: John Spray Date: Mon, 12 May 2014 13:25:26 +0000 (+0100) Subject: task/ceph: separate ceph.conf into function X-Git-Tag: 1.1.0~1433^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=554f8c81e09a579d00bc6dd8d82dbbc41be8065a;p=teuthology.git task/ceph: separate ceph.conf into function This is so that other tasks can modify ceph.conf as needed. Signed-off-by: John Spray --- diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index 5a695b570..41dfe8d33 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -18,6 +18,8 @@ from teuthology import contextutil from ..orchestra import run import ceph_client as cclient +DEFAULT_CONF_PATH = '/etc/ceph/ceph.conf' + log = logging.getLogger(__name__) class DaemonState(object): @@ -409,6 +411,29 @@ def make_admin_daemon_dir(ctx, remote): ], ) + +def write_conf(ctx, conf_path=DEFAULT_CONF_PATH): + conf_fp = StringIO() + ctx.ceph.conf.write(conf_fp) + conf_fp.seek(0) + writes = ctx.cluster.run( + args=[ + 'sudo', 'mkdir', '-p', '/etc/ceph', run.Raw('&&'), + 'sudo', 'chmod', '0755', '/etc/ceph', run.Raw('&&'), + 'sudo', 'python', + '-c', + 'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))', + conf_path, + run.Raw('&&'), + 'sudo', 'chmod', '0644', conf_path, + ], + stdin=run.PIPE, + wait=False) + log.warn("writes: ") + teuthology.feed_many_stdins_and_close(conf_fp, writes) + run.wait(writes) + + @contextlib.contextmanager def cluster(ctx, config): """ @@ -576,26 +601,8 @@ def cluster(ctx, config): conf['global']['fsid'] = fsid log.info('Writing ceph.conf for FSID %s...' % fsid) - conf_path = config.get('conf_path', '/etc/ceph/ceph.conf') - conf_fp = StringIO() - conf.write(conf_fp) - conf_fp.seek(0) - writes = ctx.cluster.run( - args=[ - 'sudo', 'mkdir', '-p', '/etc/ceph', run.Raw('&&'), - 'sudo', 'chmod', '0755', '/etc/ceph', run.Raw('&&'), - 'sudo', 'python', - '-c', - 'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))', - conf_path, - run.Raw('&&'), - 'sudo', 'chmod', '0644', conf_path, - ], - stdin=run.PIPE, - wait=False, - ) - teuthology.feed_many_stdins_and_close(conf_fp, writes) - run.wait(writes) + conf_path = config.get('conf_path', DEFAULT_CONF_PATH) + write_conf(ctx, conf_path) log.info('Creating admin key on %s...' % firstmon) ctx.cluster.only(firstmon).run(