From: John Mulligan Date: Mon, 15 Jul 2024 19:14:13 +0000 (-0400) Subject: cephadm: add a new context getter for rank X-Git-Tag: v20.0.0~1223^2~16 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f6cab59a8f7f5a5dfb72014bfe89dee9f904ec3c;p=ceph.git cephadm: add a new context getter for rank Add a new context getter function to fetch a daemon's rank and rank generation value. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadmlib/context_getters.py b/src/cephadm/cephadmlib/context_getters.py index 0bd0c0e5e6c45..7b99abeaa5f55 100644 --- a/src/cephadm/cephadmlib/context_getters.py +++ b/src/cephadm/cephadmlib/context_getters.py @@ -136,6 +136,24 @@ def fetch_endpoints(ctx: CephadmContext) -> List[EndPoint]: return endpoints +def fetch_rank_info(ctx: CephadmContext) -> Optional[Tuple[int, int]]: + """Return the daemon's rank and rank generation values as a tuple of ints + if available. Return None if rank information is not available. + """ + meta = getattr(ctx, 'meta_properties', None) + if meta is None: + return None + # We must either return both rank *and* rank_generation together or + # nothing at all. + try: + rank, gen = meta['rank'], meta['rank_generation'] + except KeyError: + return None + if rank is None or gen is None: + return None + return int(rank), int(gen) + + def get_config_and_keyring(ctx): # type: (CephadmContext) -> Tuple[Optional[str], Optional[str]] config = None