]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: invert if statement in list_daemons
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 7 Oct 2024 18:51:13 +0000 (14:51 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 11 Feb 2025 21:08:05 +0000 (16:08 -0500)
Invert an if-statement within the list_daemons function and thus remove
an unnecessary and somewhat confusing extra level of indentation (as it
defines a bunch of vars that are used later outside the indented block).
This should be logically identical to the previous code.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py

index a695b4beb39bbe1f7b3e7b325c2d96a55f7a2992..2ca89b7f8d2fbb4db6b43d620b764b682c2f97d8 100755 (executable)
@@ -3469,18 +3469,18 @@ def list_daemons(
         elif is_fsid(i):
             fsid = str(i)  # convince mypy that fsid is a str here
             for j in os.listdir(os.path.join(data_dir, i)):
-                if '.' in j and os.path.isdir(
-                    os.path.join(data_dir, fsid, j)
+                if not (
+                    '.' in j
+                    and os.path.isdir(os.path.join(data_dir, fsid, j))
                 ):
-                    name = j
-                    if daemon_name and name != daemon_name:
-                        continue
-                    (daemon_type, daemon_id) = j.split('.', 1)
-                    if type_of_daemon and type_of_daemon != daemon_type:
-                        continue
-                    unit_name = get_unit_name(fsid, daemon_type, daemon_id)
-                else:
                     continue
+                name = j
+                if daemon_name and name != daemon_name:
+                    continue
+                (daemon_type, daemon_id) = j.split('.', 1)
+                if type_of_daemon and type_of_daemon != daemon_type:
+                    continue
+                unit_name = get_unit_name(fsid, daemon_type, daemon_id)
                 val = {
                     'style': 'cephadm:v1',
                     'name': name,