From 4db3bb77b6458f8b54af7f9279151d616f042d49 Mon Sep 17 00:00:00 2001 From: Sachin Prabhu Date: Thu, 12 Sep 2024 17:13:25 +0100 Subject: [PATCH] mgr/smb: accept public_addrs on cli when creating cluster We can set the public ip address to set for the cluster using the declarative method by providing the information in the resource description. The corresponding functionality is not available with the imperative method of creating the smb cluster. This patch adds this functionality by allowing the user the option of providing the a public address on the command line when creating the smb cluster. Signed-off-by: Sachin Prabhu --- doc/mgr/smb.rst | 5 +++++ src/pybind/mgr/smb/module.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/doc/mgr/smb.rst b/doc/mgr/smb.rst index 05e6369ddf1..3252c485a9a 100644 --- a/doc/mgr/smb.rst +++ b/doc/mgr/smb.rst @@ -96,6 +96,11 @@ clustering enables clustering regardless of the placement count. A value of ``never`` disables clustering regardless of the placement count. If unspecified, ``default`` is assumed. +public_addrs + Optional. A string in the form of [%]. + Supported only when using Samba's clustering. Assign "virtual" IP + addresses that will be managed by the clustering subsystem and may automatically + move between nodes running Samba containers. Remove Cluster ++++++++++++++ diff --git a/src/pybind/mgr/smb/module.py b/src/pybind/mgr/smb/module.py index 1e71721202e..e2ec9663af5 100644 --- a/src/pybind/mgr/smb/module.py +++ b/src/pybind/mgr/smb/module.py @@ -167,6 +167,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): custom_dns: Optional[List[str]] = None, placement: Optional[str] = None, clustering: Optional[SMBClustering] = None, + public_addrs: Optional[List[str]] = None, ) -> results.Result: """Create an smb cluster""" domain_settings = None @@ -251,6 +252,18 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): ) ) + c_public_addrs = [] + if public_addrs: + for pa in public_addrs: + pa_arr = pa.split('%', 1) + address = pa_arr[0] + destination = pa_arr[1] if len(pa_arr) > 1 else None + c_public_addrs.append( + resources.ClusterPublicIPAssignment( + address=address, destination=destination + ) + ) + pspec = resources.WrappedPlacementSpec.wrap( PlacementSpec.from_string(placement) ) @@ -262,6 +275,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): custom_dns=custom_dns, placement=pspec, clustering=clustering, + public_addrs=c_public_addrs, ) to_apply.append(cluster) return self._handler.apply(to_apply, create_only=True).squash(cluster) -- 2.39.5