]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add custom config options to share and cluster resources
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 2 May 2024 20:41:37 +0000 (16:41 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 17 Jun 2024 15:17:00 +0000 (11:17 -0400)
Allow devs/testers/experimenters to add custom smb config params to our
managed shares or clusters. Use at your own risk.

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

index 536ad0c9bb71a9b439e8d072e2fbff21244db2da..ff004b47f4a84dda893ac2f120e6a72f0d884b2f 100644 (file)
@@ -134,6 +134,7 @@ class Share(_RBase):
     readonly: bool = False
     browseable: bool = True
     cephfs: Optional[CephFSStorage] = None
+    custom_smb_share_options: Optional[Dict[str, str]] = None
 
     def __post_init__(self) -> None:
         # if name is not given explicitly, take it from the share_id
@@ -153,6 +154,7 @@ class Share(_RBase):
         # currently only cephfs is supported
         if self.cephfs is None:
             raise ValueError('a cephfs configuration is required')
+        validation.check_custom_options(self.custom_smb_share_options)
 
     @property
     def checked_cephfs(self) -> CephFSStorage:
@@ -165,6 +167,10 @@ class Share(_RBase):
         rc.on_construction_error(InvalidResourceError.wrap)
         return rc
 
+    @property
+    def cleaned_custom_smb_share_options(self) -> Optional[Dict[str, str]]:
+        return validation.clean_custom_options(self.custom_smb_share_options)
+
 
 @resourcelib.component()
 class JoinAuthValues(_RBase):
@@ -294,6 +300,7 @@ class Cluster(_RBase):
     domain_settings: Optional[DomainSettings] = None
     user_group_settings: Optional[List[UserGroupSource]] = None
     custom_dns: Optional[List[str]] = None
+    custom_smb_global_options: Optional[Dict[str, str]] = None
     # embedded orchestration placement spec
     placement: Optional[WrappedPlacementSpec] = None
 
@@ -321,6 +328,7 @@ class Cluster(_RBase):
                 raise ValueError(
                     'domain settings not supported for user auth mode'
                 )
+        validation.check_custom_options(self.custom_smb_global_options)
 
     @resourcelib.customize
     def _customize_resource(rc: resourcelib.Resource) -> resourcelib.Resource:
@@ -328,6 +336,10 @@ class Cluster(_RBase):
         rc.on_construction_error(InvalidResourceError.wrap)
         return rc
 
+    @property
+    def cleaned_custom_smb_global_options(self) -> Optional[Dict[str, str]]:
+        return validation.clean_custom_options(self.custom_smb_global_options)
+
 
 @resourcelib.resource('ceph.smb.join.auth')
 class JoinAuth(_RBase):