Skip to content

Commit b5e0ab8

Browse files
mgr/smb: add support for tls credential resoruces to sqlite store
The sqlite store needs to be updated for each top-level resource type. Update it for the newly added tls credential type. Configure it so that it works similarly to the join auth resource such that the cert data is not stored in the sqlite db - only in the layered mon store. Signed-off-by: John Mulligan <[email protected]>
1 parent 6d9e126 commit b5e0ab8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/pybind/mgr/smb/sqlite_store.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,20 @@ def filter_object(self, obj: Simplified) -> Simplified:
506506
return filtered
507507

508508

509+
class MirrorTLSCredentials(Mirror):
510+
"""Mirroring configuration for objects in the tls_credentials namespace."""
511+
512+
def __init__(self, store: ConfigStore) -> None:
513+
super().__init__('tls_credentials', store)
514+
515+
def filter_object(self, obj: Simplified) -> Simplified:
516+
"""Filter tls_credential for sqlite3 store."""
517+
filtered = copy.deepcopy(obj)
518+
if filtered.get('credential_type') and filtered.get('value'):
519+
filtered.pop('value', None)
520+
return filtered
521+
522+
509523
def _tables(
510524
*,
511525
specialize: bool = True,
@@ -526,6 +540,7 @@ def _tables(
526540
srt,
527541
SimpleTable('join_auths', 'join_auths'),
528542
SimpleTable('users_and_groups', 'users_and_groups'),
543+
SimpleTable('tls_creds', 'tls_creds'),
529544
]
530545

531546

@@ -541,6 +556,10 @@ def _mirror_users_and_groups(opts: Optional[Dict[str, str]] = None) -> bool:
541556
return (opts or {}).get('mirror_users_and_groups') != 'no'
542557

543558

559+
def _mirror_tls_credentials(opts: Optional[Dict[str, str]] = None) -> bool:
560+
return (opts or {}).get('mirror_tls_credentials') != 'no'
561+
562+
544563
def mgr_sqlite3_db(
545564
mgr: Any, opts: Optional[Dict[str, str]] = None
546565
) -> SqliteStore:
@@ -566,6 +585,8 @@ def mgr_sqlite3_db_with_mirroring(
566585
mirrors.append(MirrorJoinAuths(mirror_store))
567586
if _mirror_users_and_groups(opts):
568587
mirrors.append(MirrorUsersAndGroups(mirror_store))
588+
if _mirror_tls_credentials(opts):
589+
mirrors.append(MirrorTLSCredentials(mirror_store))
569590
return SqliteMirroringStore(mgr, tables, mirrors)
570591

571592

0 commit comments

Comments
 (0)