From: Sage Weil Date: Sun, 15 Mar 2020 15:09:30 +0000 (-0500) Subject: cephadm: verify the output files' containing directory exists X-Git-Tag: v15.2.0~43^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6d4ffc675a7ba89f4dab95cf855d5147767b9e79;p=ceph-ci.git cephadm: verify the output files' containing directory exists Signed-off-by: Sage Weil --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index fa74cc81bfa..4a8e7bcc1c9 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1974,11 +1974,14 @@ def command_bootstrap(): # type: () -> int # verify output files - if not args.allow_overwrite: - for f in [args.output_config, args.output_keyring, args.output_pub_ssh_key]: + for f in [args.output_config, args.output_keyring, args.output_pub_ssh_key]: + if not args.allow_overwrite: if os.path.exists(f): raise Error('%s already exists; delete or pass ' '--allow-overwrite to overwrite' % f) + dirname = os.path.dirname(f) + if dirname and not os.path.exists(dirname): + raise Error('%s directory %s does not exist' % (f, dirname)) if not args.skip_prepare_host: command_prepare_host()