Skip to content

Commit 32ba9b7

Browse files
mgr/smb: pass custom options to samba(cc) configuration
Pass the custom share and/or global option key-value pairs to the generated configurations. Signed-off-by: John Mulligan <[email protected]>
1 parent 70ec6d4 commit 32ba9b7

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/pybind/mgr/smb/handler.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ def _generate_share(
978978
share.cephfs.subvolume,
979979
share.cephfs.path,
980980
)
981-
return {
981+
cfg = {
982982
# smb.conf options
983983
'options': {
984984
'path': path,
@@ -992,6 +992,12 @@ def _generate_share(
992992
'x:ceph:id': f'{share.cluster_id}.{share.share_id}',
993993
}
994994
}
995+
# extend share with custom options
996+
custom_opts = share.cleaned_custom_smb_share_options
997+
if custom_opts:
998+
cfg['options'].update(custom_opts)
999+
cfg['options']['x:ceph:has_custom_options'] = 'yes'
1000+
return cfg
9951001

9961002

9971003
def _generate_config(
@@ -1016,7 +1022,7 @@ def _generate_config(
10161022
for share in shares
10171023
}
10181024

1019-
return {
1025+
cfg: Dict[str, Any] = {
10201026
'samba-container-config': 'v0',
10211027
'configs': {
10221028
cluster.cluster_id: {
@@ -1042,6 +1048,14 @@ def _generate_config(
10421048
},
10431049
'shares': share_configs,
10441050
}
1051+
# insert global custom options
1052+
custom_opts = cluster.cleaned_custom_smb_global_options
1053+
if custom_opts:
1054+
# isolate custom config opts into a section for cleanliness
1055+
gname = f'{cluster.cluster_id}_custom'
1056+
cfg['configs'][cluster.cluster_id]['globals'].append(gname)
1057+
cfg['globals'][gname] = {'options': dict(custom_opts)}
1058+
return cfg
10451059

10461060

10471061
def _generate_smb_service_spec(

0 commit comments

Comments
 (0)