Skip to content

Commit 4db3bb7

Browse files
committed
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 <[email protected]>
1 parent bd51dcf commit 4db3bb7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

doc/mgr/smb.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ clustering
9696
enables clustering regardless of the placement count. A value of ``never``
9797
disables clustering regardless of the placement count. If unspecified,
9898
``default`` is assumed.
99+
public_addrs
100+
Optional. A string in the form of <ipaddress/prefixlength>[%<destination interface>].
101+
Supported only when using Samba's clustering. Assign "virtual" IP
102+
addresses that will be managed by the clustering subsystem and may automatically
103+
move between nodes running Samba containers.
99104

100105
Remove Cluster
101106
++++++++++++++

src/pybind/mgr/smb/module.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def cluster_create(
167167
custom_dns: Optional[List[str]] = None,
168168
placement: Optional[str] = None,
169169
clustering: Optional[SMBClustering] = None,
170+
public_addrs: Optional[List[str]] = None,
170171
) -> results.Result:
171172
"""Create an smb cluster"""
172173
domain_settings = None
@@ -251,6 +252,18 @@ def cluster_create(
251252
)
252253
)
253254

255+
c_public_addrs = []
256+
if public_addrs:
257+
for pa in public_addrs:
258+
pa_arr = pa.split('%', 1)
259+
address = pa_arr[0]
260+
destination = pa_arr[1] if len(pa_arr) > 1 else None
261+
c_public_addrs.append(
262+
resources.ClusterPublicIPAssignment(
263+
address=address, destination=destination
264+
)
265+
)
266+
254267
pspec = resources.WrappedPlacementSpec.wrap(
255268
PlacementSpec.from_string(placement)
256269
)
@@ -262,6 +275,7 @@ def cluster_create(
262275
custom_dns=custom_dns,
263276
placement=pspec,
264277
clustering=clustering,
278+
public_addrs=c_public_addrs,
265279
)
266280
to_apply.append(cluster)
267281
return self._handler.apply(to_apply, create_only=True).squash(cluster)

0 commit comments

Comments
 (0)