]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: add fetch_custom_config_files function
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 15 Jun 2023 19:34:09 +0000 (15:34 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 15 Jun 2023 20:35:34 +0000 (16:35 -0400)
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 <jmulligan@redhat.com>
src/cephadm/cephadm.py

index 96ea56748f2a4b5963b9abbcc9ecbaf368fceca8..d188189cfd2684ed9a12c911c0cfa5ecd2e231e0 100755 (executable)
@@ -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.
     """