From 44ce35e2390120bf2d9c1cefbbe50f7d2b7cbcbc Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 15 Jun 2023 15:34:09 -0400 Subject: [PATCH] cephadm: add fetch_custom_config_files function This function works similarly to get_custom_config_files but doesn't require the use of "ctx.config_json" and will prefer sourcing the data from `config_blobs`. This function also returns the list of dicts rather than return a dict with exactly one key which maps to said list of dicts. There appeared to be no benefit to that when the call sites of get_custom_config_files was examined. This function is `fetch_configs` evil twin. Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 96ea56748f2..d188189cfd2 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -3064,6 +3064,23 @@ def fetch_configs(ctx: CephadmContext) -> Dict[str, str]: return {} +def fetch_custom_config_files(ctx: CephadmContext) -> List[Dict[str, Any]]: + """Return a list containing dicts that can be used to populate + custom configuration files for containers. + """ + # NOTE: this function works like the opposite of fetch_configs. + # instead of filtering out custom_config_files, it returns only + # the content in that key. + cfg_blobs = getattr(ctx, 'config_blobs', None) + if cfg_blobs: + return cfg_blobs.get('custom_config_files', []) + cfg_json = getattr(ctx, 'config_json', None) + if cfg_json: + jdata = _get_config_json(cfg_json) + return jdata.get('custom_config_files', []) + return [] + + def fetch_tcp_ports(ctx: CephadmContext) -> List[int]: """Return a list of tcp ports, as integers, stored on the given ctx. """ -- 2.39.5