qubesadmin: define methods list_vmclass and list_devicesclass
Adapt also previous direct calls of qubesdb QubesOS/qubes-issues#5213
This commit is contained in:
parent
a982e1e538
commit
3dce4e9742
@ -165,6 +165,18 @@ class QubesBase(qubesadmin.base.PropertyHolder):
|
||||
self._pool_drivers = None
|
||||
self.log = logging.getLogger('app')
|
||||
|
||||
def list_vmclass(self):
|
||||
"""Call Qubesd in order to obtain the vm classes list"""
|
||||
vmclass = self.qubesd_call('dom0', 'admin.vmclass.List')\
|
||||
.decode().splitlines()
|
||||
return sorted(vmclass)
|
||||
|
||||
def list_deviceclass(self):
|
||||
"""Call Qubesd in order to obtain the device classes list"""
|
||||
deviceclasses = self.qubesd_call('dom0', 'admin.deviceclass.List')\
|
||||
.decode().splitlines()
|
||||
return sorted(deviceclasses)
|
||||
|
||||
def _refresh_pool_drivers(self):
|
||||
"""
|
||||
Refresh cached storage pool drivers and their parameters.
|
||||
|
@ -303,17 +303,7 @@ class DeviceManager(dict):
|
||||
return self[key]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._get_device_classes())
|
||||
return iter(self._vm.app.list_deviceclass())
|
||||
|
||||
def keys(self):
|
||||
return self._get_device_classes()
|
||||
|
||||
def _get_device_classes(self):
|
||||
"""Function used to call Qubesd in order to obtain
|
||||
the device classes list
|
||||
"""
|
||||
device_classes = \
|
||||
self._vm.app.qubesd_call('dom0', 'admin.deviceclass.List').decode()
|
||||
device_classes = sorted(device_classes.splitlines())
|
||||
|
||||
return device_classes
|
||||
return self._vm.app.list_deviceclass()
|
||||
|
@ -103,9 +103,8 @@ def main(args=None, app=None):
|
||||
args = parser.parse_args(args, app=app)
|
||||
|
||||
if args.help_classes:
|
||||
vm_classes = args.app.qubesd_call('dom0', 'admin.vmclass.List').decode()
|
||||
vm_classes = vm_classes.splitlines()
|
||||
print('\n'.join(sorted(vm_classes)))
|
||||
vm_classes = args.app.list_vmclass()
|
||||
print('\n'.join(vm_classes))
|
||||
return 0
|
||||
|
||||
pools = {}
|
||||
|
Loading…
Reference in New Issue
Block a user