]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: start a new object_format.py for general formatting
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 14 Mar 2022 15:29:50 +0000 (11:29 -0400)
committerAdam King <adking@redhat.com>
Sat, 21 May 2022 23:20:30 +0000 (19:20 -0400)
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 <jmulligan@redhat.com>
(cherry picked from commit 006c33895f4b7559219821bcfafbe82e789e9e41)

src/pybind/mgr/object_format.py [new file with mode: 0644]
src/pybind/mgr/orchestrator/module.py

diff --git a/src/pybind/mgr/object_format.py b/src/pybind/mgr/object_format.py
new file mode 100644 (file)
index 0000000..771ed1b
--- /dev/null
@@ -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'
+
index ad7dc116d1302346efb8faec1a7eac0167a533bf..a18d1ca4f379976f7075f72e4f75447ff9de50de 100644 (file)
@@ -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'