Skip to content

Commit 98d4853

Browse files
cephadm/smb: fix issue setting port of remote-control sidecar
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 <[email protected]>
1 parent c141eab commit 98d4853

File tree

1 file changed

+22
-5
lines changed
  • src/cephadm/cephadmlib/daemons

1 file changed

+22
-5
lines changed

src/cephadm/cephadmlib/daemons/smb.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
Tuple,
1818
)
1919

20+
import ceph.smb.constants
21+
2022
from .. import context_getters
2123
from .. import daemon_form
2224
from .. import data_utils
@@ -104,20 +106,35 @@ def conf_interface(self) -> str:
104106

105107

106108
class Ports(enum.Enum):
107-
SMB = 445
108-
SMBMETRICS = 9922
109-
CTDB = 4379
110-
REMOTE_CONTROL = 54445
109+
SMB = ceph.smb.constants.SMB_PORT
110+
SMBMETRICS = ceph.smb.constants.SMBMETRICS_PORT
111+
CTDB = ceph.smb.constants.CTDB_PORT
112+
REMOTE_CONTROL = ceph.smb.constants.REMOTE_CONTROL_PORT
111113

112114
def customized(self, service_ports: Dict[str, int]) -> int:
113115
"""Return a custom port value if it is present in service_ports or the
114116
default port value if it is not present.
115117
"""
116-
port = service_ports.get(self.name.lower())
118+
port = service_ports.get(str(self))
117119
if port:
118120
return int(port)
119121
return int(self.value)
120122

123+
def __str__(self) -> str:
124+
# NOTE: mypy is getting the key type below wrong. using reveal_type:
125+
# >>> reveal_type(self.SMB)
126+
# > note: Revealed type is "builtins.int"
127+
# >>> reveal_type(self)
128+
# > note: Revealed type is "cephadmlib.daemons.smb.Ports"
129+
# maybe newer versions would not hit this issue?
130+
names: Dict[Any, str] = {
131+
self.SMB: ceph.smb.constants.SMB,
132+
self.SMBMETRICS: ceph.smb.constants.SMBMETRICS,
133+
self.CTDB: ceph.smb.constants.CTDB,
134+
self.REMOTE_CONTROL: ceph.smb.constants.REMOTE_CONTROL,
135+
}
136+
return names[self]
137+
121138

122139
@dataclasses.dataclass(frozen=True)
123140
class TLSFiles:

0 commit comments

Comments
 (0)