return True
+def validate_fsid(func):
+ @wraps(func)
+ def _validate_fsid(ctx: CephadmContext):
+ if 'fsid' in ctx and ctx.fsid:
+ if not is_fsid(ctx.fsid):
+ raise Error('not an fsid: %s' % ctx.fsid)
+ return func(ctx)
+ return _validate_fsid
+
+
def infer_fsid(func):
"""
If we only find a single fsid in /var/lib/ceph/*, use that
@infer_config
@wraps(func)
def _infer_fsid(ctx: CephadmContext):
- if ctx.fsid:
+ if 'fsid' in ctx and ctx.fsid:
logger.debug('Using specified fsid: %s' % ctx.fsid)
return func(ctx)
if ctx.config:
logger.debug('Using specified config: %s' % ctx.config)
return func(ctx)
- if ctx.fsid:
+ if 'fsid' in ctx and ctx.fsid:
name = ctx.name if 'name' in ctx else None
if not name:
daemon_list = list_daemons(ctx, detail=False)
@infer_fsid
@infer_config
@infer_image
+@validate_fsid
def command_shell(ctx):
# type: (CephadmContext) -> int
cp = read_config(ctx.config)
assert retval == 0
assert ctx.fsid == fsid
+ cmd = ['shell', '--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)