]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: accept public_addrs on cli when creating cluster
authorSachin Prabhu <sprabhu@redhat.com>
Thu, 12 Sep 2024 16:13:25 +0000 (17:13 +0100)
committerSachin Prabhu <sprabhu@redhat.com>
Tue, 24 Sep 2024 09:30:00 +0000 (10:30 +0100)
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 <sp@spui.uk>
doc/mgr/smb.rst
src/pybind/mgr/smb/module.py

index 05e6369ddf1078ab4c3745890c55f93367ba123c..3252c485a9aa7b24b0369d8fd35cd13ae9646531 100644 (file)
@@ -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 <ipaddress/prefixlength>[%<destination interface>].
+    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
 ++++++++++++++
index 1e71721202e806434e3ea7f377b02499d677e732..e2ec9663af52fef64218eac7417ba4db0c77cbe4 100644 (file)
@@ -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)