storage: add 'rw' and 'revision_to_keep' setters

QubesOS/qubes-issues#3256
This commit is contained in:
Marek Marczykowski-Górecki 2018-03-18 17:00:39 +01:00
parent b9b9eb1f3b
commit b57b101b04
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -142,6 +142,12 @@ class Volume(object):
self._fetch_info()
return self._info['rw'] == 'True'
@rw.setter
def rw(self, value):
'''Set rw property'''
self._qubesd_call('Set.rw', str(value).encode('ascii'))
self._info = None
@property
def snap_on_start(self):
'''Create a snapshot from source on VM start.'''
@ -171,6 +177,12 @@ class Volume(object):
self._fetch_info()
return int(self._info['revisions_to_keep'])
@revisions_to_keep.setter
def revisions_to_keep(self, value):
'''Set revisions_to_keep property'''
self._qubesd_call('Set.revisions_to_keep', str(value).encode('ascii'))
self._info = None
def is_outdated(self):
''' Returns `True` if this snapshot of a source volume (for
`snap_on_start`=True) is outdated.
@ -286,6 +298,20 @@ class Pool(object):
''' Storage pool driver '''
return self.config['driver']
@property
def revisions_to_keep(self):
'''Number of revisions to keep around'''
return int(self.config['revisions_to_keep'])
@revisions_to_keep.setter
def revisions_to_keep(self, value):
'''Set revisions_to_keep property'''
self.app.qubesd_call('dom0',
'admin.pool.Set.revisions_to_keep',
self.name,
str(value).encode('ascii'))
self._config = None
@property
def volumes(self):
''' Volumes managed by this pool '''