admin: add admin.deviceclass.List

QubesOS/qubes-issues#5213
This commit is contained in:
Frédéric Pierret (fepitre) 2019-08-06 10:07:14 +02:00
parent 7f670614c8
commit 7ff01b631d
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2
3 changed files with 17 additions and 0 deletions

View File

@ -8,6 +8,7 @@ OS ?= Linux
PYTHON ?= python3 PYTHON ?= python3
ADMIN_API_METHODS_SIMPLE = \ ADMIN_API_METHODS_SIMPLE = \
admin.deviceclass.List \
admin.vmclass.List \ admin.vmclass.List \
admin.Events \ admin.Events \
admin.backup.Execute \ admin.backup.Execute \

View File

@ -1146,6 +1146,19 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
self.app.save() self.app.save()
@qubes.api.method('admin.deviceclass.List', no_payload=True,
scope='global', read=True)
@asyncio.coroutine
def deviceclass_list(self):
"""List all DEVICES classes"""
self.enforce(not self.arg)
self.enforce(self.dest.name == 'dom0')
entrypoints = self.fire_event_for_filter(
pkg_resources.iter_entry_points('qubes.devices'))
return ''.join('{}\n'.format(ep.name) for ep in entrypoints)
@qubes.api.method('admin.vm.device.{endpoint}.Available', endpoints=(ep.name @qubes.api.method('admin.vm.device.{endpoint}.Available', endpoints=(ep.name
for ep in pkg_resources.iter_entry_points('qubes.devices')), for ep in pkg_resources.iter_entry_points('qubes.devices')),
no_payload=True, no_payload=True,

View File

@ -2620,6 +2620,7 @@ class TC_00_VMs(AdminAPITestCase):
def test_992_dom0_unexpected_payload(self): def test_992_dom0_unexpected_payload(self):
methods_with_no_payload = [ methods_with_no_payload = [
b'admin.deviceclass.List',
b'admin.vmclass.List', b'admin.vmclass.List',
b'admin.vm.List', b'admin.vm.List',
b'admin.label.List', b'admin.label.List',
@ -2661,6 +2662,7 @@ class TC_00_VMs(AdminAPITestCase):
def test_993_dom0_unexpected_argument(self): def test_993_dom0_unexpected_argument(self):
methods_with_no_argument = [ methods_with_no_argument = [
b'admin.deviceclass.List',
b'admin.vmclass.List', b'admin.vmclass.List',
b'admin.vm.List', b'admin.vm.List',
b'admin.label.List', b'admin.label.List',
@ -2696,6 +2698,7 @@ class TC_00_VMs(AdminAPITestCase):
# TODO set some better arguments, to make sure the call was rejected # TODO set some better arguments, to make sure the call was rejected
# because of invalid destination, not invalid arguments # because of invalid destination, not invalid arguments
methods_for_dom0_only = [ methods_for_dom0_only = [
b'admin.deviceclass.List',
b'admin.vmclass.List', b'admin.vmclass.List',
b'admin.vm.Create.AppVM', b'admin.vm.Create.AppVM',
b'admin.vm.CreateInPool.AppVM', b'admin.vm.CreateInPool.AppVM',