devices: client stub for DeviceCollection.update_persistent

QubesOS/qubes-issues#3055
This commit is contained in:
Marek Marczykowski-Górecki 2017-09-05 03:59:01 +02:00
parent b895015274
commit 1481dc4fb8
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 30 additions and 0 deletions

View File

@ -229,6 +229,19 @@ class DeviceCollection(object):
yield DeviceInfo(self._vm, ident, description=description,
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
def clear_cache(self):

View File

@ -293,3 +293,20 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase):
self.assertEqual(devs[1].ident, 'dev2')
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()