summaryrefslogtreecommitdiffstats
path: root/src/cephadm
diff options
context:
space:
mode:
authorJohn Mulligan <jmulligan@redhat.com>2024-07-15 21:14:13 +0200
committerJohn Mulligan <jmulligan@redhat.com>2024-08-20 15:42:12 +0200
commitf6cab59a8f7f5a5dfb72014bfe89dee9f904ec3c (patch)
treeed296c6dc47e1657fd2fb6356f82447459c82239 /src/cephadm
parentMerge pull request #58460 from rkachach/fix_issue_oauth2_support (diff)
downloadceph-f6cab59a8f7f5a5dfb72014bfe89dee9f904ec3c.tar.xz
ceph-f6cab59a8f7f5a5dfb72014bfe89dee9f904ec3c.zip
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 <jmulligan@redhat.com>
Diffstat (limited to 'src/cephadm')
-rw-r--r--src/cephadm/cephadmlib/context_getters.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/cephadm/cephadmlib/context_getters.py b/src/cephadm/cephadmlib/context_getters.py
index 0bd0c0e5e6c..7b99abeaa5f 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