From: John Mulligan Date: Thu, 22 Aug 2024 18:08:06 +0000 (-0400) Subject: mgr/smb: extend cluster resource type to define public ip addrs X-Git-Tag: v20.0.0~1180^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5d5757e57aaeeb77bc693683b5cd688500cd59c5;p=ceph.git mgr/smb: extend cluster resource type to define public ip addrs When a cluster defines public IPs it will pass this information along to the smb service spec. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/resources.py b/src/pybind/mgr/smb/resources.py index 3f74ed04f2768..d91485f9992bb 100644 --- a/src/pybind/mgr/smb/resources.py +++ b/src/pybind/mgr/smb/resources.py @@ -5,7 +5,11 @@ import json import yaml -from ceph.deployment.service_spec import PlacementSpec +from ceph.deployment.service_spec import ( + PlacementSpec, + SMBClusterPublicIPSpec, + SpecValidationError, +) from object_format import ErrorResponseBase from . import resourcelib, validation @@ -346,6 +350,25 @@ class WrappedPlacementSpec(PlacementSpec): return self.to_json() +# This class is a near 1:1 mirror of the service spec helper class. +@resourcelib.component() +class ClusterPublicIPAssignment(_RBase): + address: str + destination: Union[List[str], str, None] = None + + def to_spec(self) -> SMBClusterPublicIPSpec: + return SMBClusterPublicIPSpec( + address=self.address, + destination=self.destination, + ) + + def validate(self) -> None: + try: + self.to_spec().validate() + except SpecValidationError as err: + raise ValueError(str(err)) from err + + @resourcelib.resource('ceph.smb.cluster') class Cluster(_RBase): """Represents a cluster (instance) that is / should be present.""" @@ -361,6 +384,7 @@ class Cluster(_RBase): placement: Optional[WrappedPlacementSpec] = None # control if the cluster is really a cluster clustering: Optional[SMBClustering] = None + public_addrs: Optional[List[ClusterPublicIPAssignment]] = None def validate(self) -> None: if not self.cluster_id: @@ -415,6 +439,13 @@ class Cluster(_RBase): # clustering enabled unless we're deploying a single instance "cluster" return count != 1 + def service_spec_public_addrs( + self, + ) -> Optional[List[SMBClusterPublicIPSpec]]: + if self.public_addrs is None: + return None + return [a.to_spec() for a in self.public_addrs] + @resourcelib.resource('ceph.smb.join.auth') class JoinAuth(_RBase):