From: John Mulligan Date: Sat, 6 Jul 2024 17:37:20 +0000 (-0400) Subject: mgr/smb: add function for setting up sqlite mirroring store X-Git-Tag: v20.0.0~1489^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=30ed498e0a117bfc975adb82a446c708142e3294;p=ceph.git mgr/smb: add function for setting up sqlite mirroring store Add a function similar to the existing function for setting up a sqlite3 db based store for a mgr module, but with mirroring. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/sqlite_store.py b/src/pybind/mgr/smb/sqlite_store.py index 277cde14fbfe..501bb9128ebc 100644 --- a/src/pybind/mgr/smb/sqlite_store.py +++ b/src/pybind/mgr/smb/sqlite_store.py @@ -510,17 +510,46 @@ def _tables( ] +def _specialize(opts: Optional[Dict[str, str]] = None) -> bool: + return (opts or {}).get('specialize') != 'no' + + +def _mirror_join_auths(opts: Optional[Dict[str, str]] = None) -> bool: + return (opts or {}).get('mirror_join_auths') != 'no' + + +def _mirror_users_and_groups(opts: Optional[Dict[str, str]] = None) -> bool: + return (opts or {}).get('mirror_users_and_groups') != 'no' + + def mgr_sqlite3_db( mgr: Any, opts: Optional[Dict[str, str]] = None ) -> SqliteStore: """Set up a store for use in the real ceph mgr.""" - specialize = (opts or {}).get('specialize') != 'no' + specialize = _specialize(opts) return SqliteStore( mgr, _tables(specialize=specialize), ) +def mgr_sqlite3_db_with_mirroring( + mgr: Any, + mirror_store: ConfigStore, + opts: Optional[Dict[str, str]] = None, +) -> SqliteMirroringStore: + """Set up a store for use in the ceph mgr that will mirror some + objects into an alternate store. + """ + tables = _tables(specialize=_specialize(opts)) + mirrors: List[Mirror] = [] + if _mirror_join_auths(opts): + mirrors.append(MirrorJoinAuths(mirror_store)) + if _mirror_users_and_groups(opts): + mirrors.append(MirrorUsersAndGroups(mirror_store)) + return SqliteMirroringStore(mgr, tables, mirrors) + + def memory_db( *, specialize: bool = True,