From 70ec6d4037ee1ed5a05a968c4b9231dbe0cfbcd4 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 2 May 2024 16:41:37 -0400 Subject: [PATCH] mgr/smb: add custom config options to share and cluster resources 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 --- src/pybind/mgr/smb/resources.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pybind/mgr/smb/resources.py b/src/pybind/mgr/smb/resources.py index 536ad0c9bb7..ff004b47f4a 100644 --- a/src/pybind/mgr/smb/resources.py +++ b/src/pybind/mgr/smb/resources.py @@ -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): -- 2.39.5