]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: update handler.py to make use of the cluster custom ports value
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 11 Jun 2025 18:58:24 +0000 (14:58 -0400)
committerAdam King <adking@redhat.com>
Wed, 9 Jul 2025 15:52:24 +0000 (11:52 -0400)
When a custom_ports field on the Cluster type is provided pass it
to the smb service spec and smb/sambacc configuration fields needed.

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

src/pybind/mgr/smb/handler.py

index e0dc9518902523fefc261e242d3c5c153de7c496..cb690fc387d85129bf6848fdcdc7c147a66a64be 100644 (file)
@@ -1262,6 +1262,10 @@ def _generate_config(
         cluster_global_opts['workgroup'] = wg
         cluster_global_opts['idmap config * : backend'] = 'autorid'
         cluster_global_opts['idmap config * : range'] = '2000-9999999'
+    if cluster.is_clustered() and cluster.custom_ports:
+        # a ctdb enabled cluster (w/ host networking) with custom ports needs
+        # to change the port at the smbd level
+        cluster_global_opts['smb ports'] = str(_smb_port(cluster))
 
     share_configs = {
         share.name: _generate_share(share, resolver, cephx_entity)
@@ -1355,6 +1359,7 @@ def _generate_smb_service_spec(
         custom_dns=cluster.custom_dns,
         include_ceph_users=user_entities,
         cluster_public_addrs=cluster.service_spec_public_addrs(),
+        custom_ports=cluster.custom_ports,
     )
 
 
@@ -1489,3 +1494,7 @@ def _has_proxied_vfs(change_group: ClusterChangeGroup) -> bool:
         == CephFSStorageProvider.SAMBA_VFS_PROXIED
         for s in change_group.shares
     )
+
+
+def _smb_port(cluster: resources.Cluster, default: int = 445) -> int:
+    return (cluster.custom_ports or {}).get("smb", default)