]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add function for setting up sqlite mirroring store
authorJohn Mulligan <jmulligan@redhat.com>
Sat, 6 Jul 2024 17:37:20 +0000 (13:37 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sat, 6 Jul 2024 18:53:06 +0000 (14:53 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/smb/sqlite_store.py

index 277cde14fbfe4afe8dd5159d5a4af4f6cca66ddc..501bb9128ebc15e3f9d1e7911b233205d0a9a5ea 100644 (file)
@@ -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,