]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind / snap_schedule: sanely dump schedules and retention specs
authorVenky Shankar <vshankar@redhat.com>
Thu, 20 Aug 2020 09:44:17 +0000 (05:44 -0400)
committerVenky Shankar <vshankar@redhat.com>
Tue, 17 Nov 2020 06:15:46 +0000 (01:15 -0500)
For easiness in parsing for tests.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/pybind/mgr/snap_schedule/module.py

index 83112c4cc324dd2833e22ba11c91bb3be54be658..62768fbe6293d6241533ac5f2c49cdebc33081eb 100644 (file)
@@ -4,6 +4,7 @@ Copyright (C) 2019 SUSE
 LGPL2.1.  See file COPYING.
 """
 import errno
+import json
 import sqlite3
 from .fs.schedule_client import SnapSchedClient
 from mgr_module import MgrModule, CLIReadCommand, CLIWriteCommand
@@ -88,10 +89,13 @@ class Module(MgrModule):
         except CephfsConnectionException as e:
             return e.to_tuple()
         if not scheds:
-            return errno.ENOENT, '', f'SnapSchedule for {path} not found'
+            return -errno.ENOENT, '', f'SnapSchedule for {path} not found'
         if format == 'json':
-            json_list = ','.join([sched.json_list() for sched in scheds])
-            return 0, f'[{json_list}]', ''
+            # json_list = ','.join([sched.json_list() for sched in scheds])
+            schedule_list = [sched.schedule for sched in scheds]
+            retention_list = [sched.retention for sched in scheds]
+            out = {'path': path, 'schedule': schedule_list, 'retention': retention_list}
+            return 0, json.dumps(out), ''
         return 0, '\n'.join([str(sched) for sched in scheds]), ''
 
     @CLIWriteCommand('fs snap-schedule add',