From: John Mulligan Date: Mon, 14 Mar 2022 15:29:50 +0000 (-0400) Subject: pybind/mgr: start a new object_format.py for general formatting X-Git-Tag: v17.2.1~48^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=66219713df0c33dda1f09edbd2dae1ab6e78d7dc;p=ceph.git pybind/mgr: start a new object_format.py for general formatting Currently, there's some auto-formatting logic in the orchestrator module and a lot of ad-hoc formatting scattered around the mgr modules. This new module aims to bring some of that together in a central location. Start by moving the Format enum from the orchestrator. Signed-off-by: John Mulligan (cherry picked from commit 006c33895f4b7559219821bcfafbe82e789e9e41) --- diff --git a/src/pybind/mgr/object_format.py b/src/pybind/mgr/object_format.py new file mode 100644 index 000000000000..771ed1b9efbf --- /dev/null +++ b/src/pybind/mgr/object_format.py @@ -0,0 +1,13 @@ +# object_format.py provides types and functions for working with +# requested output formats such as JSON, YAML, etc. + +import enum + +class Format(enum.Enum): + plain = 'plain' + json = 'json' + json_pretty = 'json-pretty' + yaml = 'yaml' + xml_pretty = 'xml-pretty' + xml = 'xml' + diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index ad7dc116d130..a18d1ca4f379 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -22,6 +22,7 @@ from ceph.utils import datetime_now from mgr_util import to_pretty_timedelta, format_dimless, format_bytes from mgr_module import MgrModule, HandleCommandResult, Option +from object_format import Format from ._interface import OrchestratorClientMixin, DeviceLightLoc, _cli_read_command, \ raise_if_exception, _cli_write_command, OrchestratorError, \ @@ -44,15 +45,6 @@ def nice_bytes(v: Optional[int]) -> str: return format_bytes(v, 5) -class Format(enum.Enum): - plain = 'plain' - json = 'json' - json_pretty = 'json-pretty' - yaml = 'yaml' - xml_pretty = 'xml-pretty' - xml = 'xml' - - class ServiceType(enum.Enum): mon = 'mon' mgr = 'mgr'