mgr/crash: add 'crash ls-new'

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2019-07-14 11:26:41 -05:00
parent 7cbaa5ac56
commit bebb1c3100
2 changed files with 20 additions and 3 deletions

View File

@ -37,7 +37,13 @@ Remove a specific crash dump.
ceph crash ls
List the timestamp/uuid crashids for all saved crash info.
List the timestamp/uuid crashids for all new and archived crash info.
::
ceph crash ls-new
List the timestamp/uuid crashids for all newcrash info.
::

View File

@ -107,10 +107,15 @@ class Module(MgrModule):
self.crashes[crashid] = metadata
key = 'crash/%s' % crashid
self.set_store(key, json.dumps(metadata))
self._refresh_health_checks()
return 0, '', ''
def do_ls(self, cmd, inbuf):
r = self.crashes.values()
if cmd['prefix'] == 'crash ls':
r = self.crashes.values()
else:
r = [crash for crashid, crash in self.crashes.items()
if 'archived' not in crash]
if cmd.get('format') == 'json' or cmd.get('format') == 'json-pretty':
return 0, json.dumps(r, indent=4), ''
else:
@ -256,7 +261,13 @@ class Module(MgrModule):
},
{
'cmd': 'crash ls',
'desc': 'Show saved crash dumps',
'desc': 'Show new and archived crash dumps',
'perm': 'r',
'handler': do_ls,
},
{
'cmd': 'crash ls-new',
'desc': 'Show new crash dumps',
'perm': 'r',
'handler': do_ls,
},