devices: client stub for DeviceCollection.update_persistent
QubesOS/qubes-issues#3055
This commit is contained in:
parent
b895015274
commit
1481dc4fb8
@ -229,6 +229,19 @@ class DeviceCollection(object):
|
|||||||
yield DeviceInfo(self._vm, ident, description=description,
|
yield DeviceInfo(self._vm, ident, description=description,
|
||||||
options=None, **info_dict)
|
options=None, **info_dict)
|
||||||
|
|
||||||
|
def update_persistent(self, device, persistent):
|
||||||
|
'''Update `persistent` flag of already attached device.
|
||||||
|
|
||||||
|
:param DeviceInfo device: device for which change persistent flag
|
||||||
|
:param bool persistent: new persistent flag
|
||||||
|
'''
|
||||||
|
|
||||||
|
self._vm.qubesd_call(None,
|
||||||
|
'admin.vm.device.{}.Set.persistent'.format(self._class),
|
||||||
|
'{!s}+{!s}'.format(device.backend_domain,
|
||||||
|
device.ident),
|
||||||
|
str(persistent).encode('utf-8'))
|
||||||
|
|
||||||
__iter__ = available
|
__iter__ = available
|
||||||
|
|
||||||
def clear_cache(self):
|
def clear_cache(self):
|
||||||
|
@ -293,3 +293,20 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase):
|
|||||||
self.assertEqual(devs[1].ident, 'dev2')
|
self.assertEqual(devs[1].ident, 'dev2')
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
|
def test_070_update_persistent(self):
|
||||||
|
self.app.expected_calls[
|
||||||
|
('test-vm', 'admin.vm.device.test.Set.persistent', 'test-vm2+dev1',
|
||||||
|
b'True')] = b'0\0'
|
||||||
|
dev = qubesadmin.devices.DeviceInfo(
|
||||||
|
self.app.domains['test-vm2'], 'dev1')
|
||||||
|
self.vm.devices['test'].update_persistent(dev, True)
|
||||||
|
self.assertAllCalled()
|
||||||
|
|
||||||
|
def test_071_update_persistent_false(self):
|
||||||
|
self.app.expected_calls[
|
||||||
|
('test-vm', 'admin.vm.device.test.Set.persistent', 'test-vm2+dev1',
|
||||||
|
b'False')] = b'0\0'
|
||||||
|
dev = qubesadmin.devices.DeviceInfo(
|
||||||
|
self.app.domains['test-vm2'], 'dev1')
|
||||||
|
self.vm.devices['test'].update_persistent(dev, False)
|
||||||
|
self.assertAllCalled()
|
||||||
|
Loading…
Reference in New Issue
Block a user