From 66219713df0c33dda1f09edbd2dae1ab6e78d7dc Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 14 Mar 2022 11:29:50 -0400 Subject: [PATCH] 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) --- src/pybind/mgr/object_format.py | 13 +++++++++++++ src/pybind/mgr/orchestrator/module.py | 10 +--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 src/pybind/mgr/object_format.py diff --git a/src/pybind/mgr/object_format.py b/src/pybind/mgr/object_format.py new file mode 100644 index 00000000000..771ed1b9efb --- /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 ad7dc116d13..a18d1ca4f37 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' -- 2.47.3