The CephadmContext holds much of cephadm's state, including values from
cli options and (soon) configuration file input. Add a `fetch_meta`
function that reads processed metadata from `meta_properties` or parses
JSON stored on `meta_json`. Parsed JSON is saved to `meta_properties`.
Future code should always use fetch_meta for reading, and only ever
set `meta_properties` as a python dict, not round trip JSON through
meta_json.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
return js
+def fetch_meta(ctx: CephadmContext) -> Dict[str, Any]:
+ """Return a dict containing metadata about a deployment.
+ """
+ meta = getattr(ctx, 'meta_properties', None)
+ if meta is not None:
+ return meta
+ mjson = getattr(ctx, 'meta_json', None)
+ if mjson is not None:
+ meta = json.loads(mjson) or {}
+ ctx.meta_properties = meta
+ return meta
+ return {}
+
+
def get_config_and_keyring(ctx):
# type: (CephadmContext) -> Tuple[Optional[str], Optional[str]]
config = None