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:
Marek Marczykowski-Górecki 2018-03-18 21:45:43 +01:00
parent e2b70306e5
commit 2a962c54db
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 11 additions and 4 deletions

View File

@ -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)

View File

@ -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):