]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: add fetch_configs function for reading configuration items from ctx
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 11 May 2023 14:30:51 +0000 (10:30 -0400)
committerAdam King <adking@redhat.com>
Thu, 31 Aug 2023 17:35:13 +0000 (13:35 -0400)
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 <jmulligan@redhat.com>
src/cephadm/cephadm.py

index 2129be1a2cb4e9b52f412d636575fdb690b1eb1c..06d786cb6c7487b780eea47c4a44c4542c9865cb 100755 (executable)
@@ -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