From: Michael Fritch Date: Thu, 23 Jan 2020 15:11:59 +0000 (-0700) Subject: cephadm: infer the fsid by name X-Git-Tag: v15.1.0~77^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f46be311e46afa045aa4ee0e168744225aa9dfb2;p=ceph.git cephadm: infer the fsid by name Signed-off-by: Michael Fritch --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index d4424846a2df..6067be3e4c26 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -630,23 +630,25 @@ def infer_fsid(func): logger.debug('Using specified fsid: %s' % args.fsid) return func() - fsid_list = [] - if os.path.exists(args.data_dir): - for i in os.listdir(args.data_dir): - if is_fsid(i): - fsid_list.append(i) - logger.debug('Found fsids %s' % str(fsid_list)) - - if not fsid_list: - # TODO: raise? - return func() - - if len(fsid_list) > 1: - raise Error('cannot infer fsid, must specify --fsid') - - logger.info('Inferring fsid %s' % fsid_list[0]) - args.fsid = fsid_list[0] + fsids = set() + daemon_list = list_daemons(detail=False) + for daemon in daemon_list: + if 'name' not in args or not args.name: + fsids.add(daemon['fsid']) + elif daemon['name'] == args.name: + fsids.add(daemon['fsid']) + fsids = list(fsids) + + if not fsids: + # some commands do not always require an fsid + pass + elif len(fsids) == 1: + logger.info('Inferring fsid %s' % fsids[0]) + args.fsid = fsids[0] + else: + raise Error('Cannot infer an fsid, one must be specified: %s' % fsids) return func() + return _infer_fsid def write_tmp(s, uid, gid):