From: Sebastian Wagner Date: Thu, 11 Jun 2020 09:55:00 +0000 (+0200) Subject: mgr/orch: make YAML of ServiceDescription readable X-Git-Tag: v16.1.0~1916^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd29e1c4a8ccaa84f3f2e73920b637576d565015;p=ceph.git mgr/orch: make YAML of ServiceDescription readable Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index daaad69c49c9..7899b4fef48c 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1420,7 +1420,7 @@ class ServiceDescription(object): def __repr__(self): return f"" - def to_json(self): + def to_json(self) -> OrderedDict: out = self.spec.to_json() status = { 'container_image_id': self.container_image_id, @@ -1452,6 +1452,13 @@ class ServiceDescription(object): c_status[k] = datetime.datetime.strptime(c_status[k], DATEFMT) return cls(spec=spec, **c_status) + @staticmethod + def yaml_representer(dumper: 'yaml.SafeDumper', data: 'DaemonDescription'): + return dumper.represent_dict(data.to_json().items()) + + +yaml.add_representer(ServiceDescription, ServiceDescription.yaml_representer) + class InventoryFilter(object): """