From: Michael Fritch Date: Tue, 27 Jul 2021 21:56:25 +0000 (-0600) Subject: cephadm: validate fsid during ceph-volume command X-Git-Tag: v16.2.6~54^2~25 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e7b9664b76ce291d3777426c5f98b6d615d1acae;p=ceph.git cephadm: validate fsid during ceph-volume command Signed-off-by: Michael Fritch (cherry picked from commit f0609429c05a70b6e6e7f131f56468e704be9640) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 5f0fa84eb56..bf67d34eacc 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -4604,6 +4604,7 @@ def command_enter(ctx): @infer_fsid @infer_image +@validate_fsid def command_ceph_volume(ctx): # type: (CephadmContext) -> None cp = read_config(ctx.config) diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index 6993214ac07..d6bf394fc2a 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -1525,6 +1525,14 @@ class TestCephVolume(object): cd.command_ceph_volume(ctx) assert ctx.fsid == fsid + cmd = self._get_cmd('--fsid', '00000000-0000-0000-0000-0000deadbeez') + with with_cephadm_ctx(cmd) as ctx: + err = 'not an fsid' + with pytest.raises(cd.Error, match=err): + retval = cd.command_shell(ctx) + assert retval == 1 + assert ctx.fsid == None + s = get_ceph_conf(fsid=fsid) f = cephadm_fs.create_file('ceph.conf', contents=s)