From: Sage Weil Date: Wed, 2 Oct 2019 21:54:18 +0000 (-0500) Subject: ceph-daemon: ls: behave if /var/log/ceph doesn't exist X-Git-Tag: v15.1.0~1313^2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c84dfe84d41fdbdd8b40c9b527f4e4740459fee0;p=ceph-ci.git ceph-daemon: ls: behave if /var/log/ceph doesn't exist Signed-off-by: Sage Weil --- diff --git a/src/ceph-daemon b/src/ceph-daemon index af8f7ff8527..c2f131a5b59 100755 --- a/src/ceph-daemon +++ b/src/ceph-daemon @@ -829,36 +829,39 @@ def command_ls(): ls = [] # /var/lib/ceph - for i in os.listdir(args.data_dir): - if i in ['mon', 'osd', 'mds', 'mgr']: - daemon_type = i - for j in os.listdir(os.path.join(args.data_dir, i)): - if '-' not in j: - continue - (cluster, daemon_id) = j.split('-', 1) - fsid = get_legacy_daemon_fsid(cluster, daemon_type, daemon_id) - (enabled, active) = check_unit('ceph-%s@%s' % (daemon_type, - daemon_id)) - ls.append({ - 'style': 'legacy', - 'name': '%s.%s' % (daemon_type, daemon_id), - 'fsid': fsid, - 'enabled': enabled, - 'active': active, - }) - elif is_fsid(i): - fsid = i - for j in os.listdir(os.path.join(args.data_dir, i)): - (daemon_type, daemon_id) = j.split('.', 1) - (enabled, active) = check_unit(get_unit_name(fsid, daemon_type, - daemon_id)) - ls.append({ - 'style': 'ceph-daemon:v1', - 'name': '%s.%s' % (daemon_type, daemon_id), - 'fsid': fsid, - 'enabled': enabled, - 'active': active, - }) + if os.path.exists(args.data_dir): + for i in os.listdir(args.data_dir): + if i in ['mon', 'osd', 'mds', 'mgr']: + daemon_type = i + for j in os.listdir(os.path.join(args.data_dir, i)): + if '-' not in j: + continue + (cluster, daemon_id) = j.split('-', 1) + fsid = get_legacy_daemon_fsid(cluster, daemon_type, + daemon_id) or 'unknown' + (enabled, active) = check_unit('ceph-%s@%s' % (daemon_type, + daemon_id)) + ls.append({ + 'style': 'legacy', + 'name': '%s.%s' % (daemon_type, daemon_id), + 'fsid': fsid, + 'enabled': enabled, + 'active': active, + }) + elif is_fsid(i): + fsid = i + for j in os.listdir(os.path.join(args.data_dir, i)): + (daemon_type, daemon_id) = j.split('.', 1) + (enabled, active) = check_unit(get_unit_name(fsid, + daemon_type, + daemon_id)) + ls.append({ + 'style': 'ceph-daemon:v1', + 'name': '%s.%s' % (daemon_type, daemon_id), + 'fsid': fsid, + 'enabled': enabled, + 'active': active, + }) # /var/lib/rook # WRITE ME