]> 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)
committerJohn Mulligan <jmulligan@redhat.com>
Fri, 13 May 2022 14:41:59 +0000 (10:41 -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>
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 db89483a6061447a0edce2bf325827b0a1da57c0..51a9fe10ff624ab40f295741cbe3c82615bc0f92 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'