]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/smb: add new external ceph cluster resource type
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 26 Nov 2025 19:59:50 +0000 (14:59 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 13 Feb 2026 16:42:49 +0000 (11:42 -0500)
Add a new resource type that will allow an smb cluster to use
cephfs from a ceph cluster *other* than the one hosting the smb
instance.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/resources.py

index c43655b6cb874c390f9f455495f09304138a6829..beeb279e741433a386722de5848cd3a0fb35c231 100644 (file)
@@ -515,6 +515,27 @@ class TLSSource(_RBase):
         return rc
 
 
+@resourcelib.component()
+class ExternalCephClusterSource(_RBase):
+    """References Ceph cluster configurations for clusters other than the
+    current cluster.
+    """
+
+    source_type: SourceReferenceType = SourceReferenceType.RESOURCE
+    ref: str = ''
+
+    def validate(self) -> None:
+        if not self.ref:
+            raise ValueError('reference value must be specified')
+        else:
+            validation.check_id(self.ref)
+
+    @resourcelib.customize
+    def _customize_resource(rc: resourcelib.Resource) -> resourcelib.Resource:
+        rc.ref.quiet = True
+        return rc
+
+
 @resourcelib.component()
 class RemoteControl(_RBase):
     # enabled can be set to explicitly toggle the remote control server
@@ -559,6 +580,9 @@ class Cluster(_RBase):
     bind_addrs: Optional[List[ClusterBindIP]] = None
     # configure a remote control sidecar server.
     remote_control: Optional[RemoteControl] = None
+    # connect the smb cluster and all its shares to cephfs file systems
+    # hosted on an external ceph cluster
+    external_ceph_cluster: Optional[ExternalCephClusterSource] = None
 
     def validate(self) -> None:
         if not self.cluster_id:
@@ -751,6 +775,41 @@ class TLSCredential(_RBase):
         return self
 
 
+@resourcelib.component()
+class CephUserKey(_RBase):
+    """A Ceph User Key name and value pair."""
+
+    name: str
+    key: str
+
+
+@resourcelib.component()
+class ExternalCephClusterValues(_RBase):
+    """Contains values that can be used to connect to a Ceph cluster
+    other than the current cluster.
+    """
+
+    fsid: str
+    mon_host: str
+    cephfs_user: CephUserKey
+
+
+@resourcelib.resource('ceph.smb.ext.cluster')
+class ExternalCephCluster(_RBase):
+    """Resource used to configure an external Ceph cluster."""
+
+    external_ceph_cluster_id: str
+    intent: Intent = Intent.PRESENT
+    cluster: Optional[ExternalCephClusterValues] = None
+
+    def validate(self) -> None:
+        if not self.external_ceph_cluster_id:
+            raise ValueError('external_ceph_cluster_id requires a value')
+        validation.check_id(self.external_ceph_cluster_id)
+        if self.intent is Intent.PRESENT and not self.cluster:
+            raise ValueError('cluster parameter must be specified')
+
+
 # SMBResource is a union of all valid top-level smb resource types.
 SMBResource = Union[
     Cluster,
@@ -760,6 +819,7 @@ SMBResource = Union[
     Share,
     UsersAndGroups,
     TLSCredential,
+    ExternalCephCluster,
 ]