]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm/smb: fix issue setting port of remote-control sidecar 65068/head
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 13 Aug 2025 16:59:24 +0000 (12:59 -0400)
committerAdam King <adking@redhat.com>
Thu, 21 Aug 2025 18:13:56 +0000 (14:13 -0400)
Use the new set of constants to ensure all components that touch the smb
services use the same set of ports and port names.  Ensure that the
remote-control sidecar service's port can be customized.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit 98d48538c16f57ceeb31e49b501303ef4c0bddc9)

src/cephadm/cephadmlib/daemons/smb.py

index f7a70a8654225f18d056424793f9e489aa59f4a2..688e4ff79112b3e65dcf534f32fd7a719a846465 100644 (file)
@@ -17,6 +17,8 @@ from typing import (
     Tuple,
 )
 
+import ceph.smb.constants
+
 from .. import context_getters
 from .. import daemon_form
 from .. import data_utils
@@ -104,20 +106,35 @@ class BindInterface(NamedTuple):
 
 
 class Ports(enum.Enum):
-    SMB = 445
-    SMBMETRICS = 9922
-    CTDB = 4379
-    REMOTE_CONTROL = 54445
+    SMB = ceph.smb.constants.SMB_PORT
+    SMBMETRICS = ceph.smb.constants.SMBMETRICS_PORT
+    CTDB = ceph.smb.constants.CTDB_PORT
+    REMOTE_CONTROL = ceph.smb.constants.REMOTE_CONTROL_PORT
 
     def customized(self, service_ports: Dict[str, int]) -> int:
         """Return a custom port value if it is present in service_ports or the
         default port value if it is not present.
         """
-        port = service_ports.get(self.name.lower())
+        port = service_ports.get(str(self))
         if port:
             return int(port)
         return int(self.value)
 
+    def __str__(self) -> str:
+        # NOTE: mypy is getting the key type below wrong. using reveal_type:
+        # >>> reveal_type(self.SMB)
+        # > note: Revealed type is "builtins.int"
+        # >>> reveal_type(self)
+        # > note: Revealed type is "cephadmlib.daemons.smb.Ports"
+        # maybe newer versions would not hit this issue?
+        names: Dict[Any, str] = {
+            self.SMB: ceph.smb.constants.SMB,
+            self.SMBMETRICS: ceph.smb.constants.SMBMETRICS,
+            self.CTDB: ceph.smb.constants.CTDB,
+            self.REMOTE_CONTROL: ceph.smb.constants.REMOTE_CONTROL,
+        }
+        return names[self]
+
 
 @dataclasses.dataclass(frozen=True)
 class TLSFiles: