From b81c94900b766dec4131eb8a4e58965950cb6b90 Mon Sep 17 00:00:00 2001 From: qubesuser Date: Fri, 10 Nov 2017 00:00:52 +0100 Subject: [PATCH] add GetAllData API to get data of all VMs Even faster qvm-ls! --- Makefile | 1 + qubes/api/admin.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Makefile b/Makefile index 7af2593a6..e74662c0a 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ ADMIN_API_METHODS_SIMPLE = \ admin.vm.CreateInPool.StandaloneVM \ admin.vm.CreateInPool.TemplateVM \ admin.vm.CreateDisposable \ + admin.vm.GetAllData \ admin.vm.Kill \ admin.vm.List \ admin.vm.Pause \ diff --git a/qubes/api/admin.py b/qubes/api/admin.py index 726fabbd2..c550547a8 100644 --- a/qubes/api/admin.py +++ b/qubes/api/admin.py @@ -145,6 +145,33 @@ def vm_list(self): self._vm_line_strs(strs, vm) return ''.join(strs) + @qubes.api.method('admin.vm.GetAllData', no_payload=True, + scope='global', read=True) + @asyncio.coroutine + def vm_get_all_data(self): + '''List all VMs and return the value of all their properties''' + assert not self.arg + + if self.dest.name == 'dom0': + domains = self.fire_event_for_filter(self.app.domains) + else: + domains = self.fire_event_for_filter([self.dest]) + + strs = [] + orig_dest = self.dest + orig_method = self.method + try: + for vm in sorted(domains): + self.dest = vm + self.method = "admin.vm.property.GetAll" + self._vm_line_strs(strs, vm) + self._property_get_all_strs(strs, vm, "\tP\t") + finally: + self.dest = orig_dest + self.method = orig_method + + return ''.join(strs) + @qubes.api.method('admin.vm.property.List', no_payload=True, scope='local', read=True) @asyncio.coroutine