From: John Mulligan Date: Thu, 11 May 2023 14:30:51 +0000 (-0400) Subject: cephadm: add fetch_configs function for reading configuration items from ctx X-Git-Tag: v18.2.1~326^2~71 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=580f120192710f6d71fbf622bd2a45197a9a4f90;p=ceph-ci.git cephadm: add fetch_configs function for reading configuration items from ctx The CephadmContext holds much of cephadm's state, including values from cli options and (soon) configuration file input. Add a `fetch_configs` function that reads processed configuration items from `config_blobs` (a dict mapping config name to arbitrary configuration content) or falls back to using the `get_parm` function on `ctx.config_json`. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 2129be1a2cb..06d786cb6c7 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -3048,6 +3048,23 @@ def fetch_meta(ctx: CephadmContext) -> Dict[str, Any]: return {} +def fetch_configs(ctx: CephadmContext) -> Dict[str, str]: + """Return a dict containing arbitrary configuration parameters. + This function filters out the key 'custom_config_files' which + must not be part of a deployment's configuration key-value pairs. + To access custom configuration file data, use `fetch_custom_config_files`. + """ + cfg_blobs = getattr(ctx, 'config_blobs', None) + if cfg_blobs: + cfg_blobs = dict(cfg_blobs) + cfg_blobs.pop('custom_config_files', None) + return cfg_blobs + cfg_json = getattr(ctx, 'config_json', None) + if cfg_json: + return get_parm(cfg_json) or {} + return {} + + def get_config_and_keyring(ctx): # type: (CephadmContext) -> Tuple[Optional[str], Optional[str]] config = None