api/admin: include 'revisions_to_keep' and 'is_outdated' in volume info
Since Volume.is_outdated() is a method, not a property, add a function for handling serialization. And at the same time, fix None serialization (applicable to 'source' property). QubesOS/qubes-issues#3256
This commit is contained in:
parent
e2b70306e5
commit
2a962c54db
@ -336,9 +336,16 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
|
||||
# properties defined in API
|
||||
volume_properties = [
|
||||
'pool', 'vid', 'size', 'usage', 'rw', 'source',
|
||||
'save_on_stop', 'snap_on_start']
|
||||
return ''.join('{}={}\n'.format(key, getattr(volume, key)) for key in
|
||||
volume_properties)
|
||||
'save_on_stop', 'snap_on_start', 'revisions_to_keep', 'is_outdated']
|
||||
|
||||
def _serialize(value):
|
||||
if callable(value):
|
||||
value = value()
|
||||
if value is None:
|
||||
value = ''
|
||||
return str(value)
|
||||
return ''.join('{}={}\n'.format(key, _serialize(getattr(volume, key)))
|
||||
for key in volume_properties)
|
||||
|
||||
@qubes.api.method('admin.vm.volume.ListSnapshots', no_payload=True,
|
||||
scope='local', read=True)
|
||||
|
@ -40,7 +40,7 @@ import qubes.storage
|
||||
# properties defined in API
|
||||
volume_properties = [
|
||||
'pool', 'vid', 'size', 'usage', 'rw', 'source',
|
||||
'save_on_stop', 'snap_on_start']
|
||||
'save_on_stop', 'snap_on_start', 'revisions_to_keep', 'is_outdated']
|
||||
|
||||
|
||||
class AdminAPITestCase(qubes.tests.QubesTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user