From: Sage Weil Date: Tue, 1 Oct 2019 19:14:31 +0000 (-0500) Subject: ceph-daemon: add --config-and-keyring to ceph-volume command X-Git-Tag: v15.1.0~1313^2~31 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2c7468e96dcb1492ff1f9d6bfbde8bfd17aacbec;p=ceph-ci.git ceph-daemon: add --config-and-keyring to ceph-volume command ...to provide a ceph.conf and the bootstrap-osd key. Signed-off-by: Sage Weil --- diff --git a/src/ceph-daemon b/src/ceph-daemon index 50c381df348..e2fb47afed3 100755 --- a/src/ceph-daemon +++ b/src/ceph-daemon @@ -682,12 +682,44 @@ def command_exec(): def command_ceph_volume(): log_dir = get_log_dir(args.log_dir, args.fsid) makedirs(log_dir) + + mounts = get_container_mounts(args.fsid, 'osd', None) + + tmp_config = None + tmp_keyring = None + + if args.config_and_keyring: + import json + if args.config_and_keyring == '-': + j = sys.stdin.read() + else: + with open(args.config_and_keyring, 'r') as f: + j = f.read() + d = json.loads(j) + config = d.get('config') + keyring = d.get('keyring') + + # tmp keyring file + tmp_keyring = tempfile.NamedTemporaryFile(mode='w') + os.fchmod(tmp_keyring.fileno(), 0o600) + tmp_keyring.write(keyring) + tmp_keyring.flush() + + # tmp config file + tmp_config = tempfile.NamedTemporaryFile(mode='w') + os.fchmod(tmp_config.fileno(), 0o600) + tmp_config.write(config) + tmp_config.flush() + + mounts[tmp_config.name] = '/etc/ceph/ceph.conf:z' + mounts[tmp_keyring.name] = '/var/lib/ceph/bootstrap-osd/ceph.keyring:z' + c = CephContainer( image=args.image, entrypoint='/usr/sbin/ceph-volume', args=args.command, podman_args=['--privileged'], - volume_mounts=get_container_mounts(args.fsid, 'osd', None), + volume_mounts=mounts, ) subprocess.call(c.run_cmd()) @@ -913,6 +945,9 @@ parser_ceph_volume.add_argument( '--fsid', required=True, help='cluster FSID') +parser_ceph_volume.add_argument( + '--config-and-keyring', + help='JSON file with config and (client.bootrap-osd) key') parser_ceph_volume.add_argument( 'command', nargs='+', help='command')