]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-daemon: ls: behave if /var/log/ceph doesn't exist
authorSage Weil <sage@redhat.com>
Wed, 2 Oct 2019 21:54:18 +0000 (16:54 -0500)
committerSage Weil <sage@redhat.com>
Sat, 5 Oct 2019 01:33:35 +0000 (20:33 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph-daemon

index af8f7ff852712d8cafe86c52f90c8070c95648ae..c2f131a5b59d1bd77312273fcc14f76b582f2011 100755 (executable)
@@ -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