Skip to content

Commit

Permalink
add GetAllData API to get data of all VMs
Browse files Browse the repository at this point in the history
Even faster qvm-ls!
  • Loading branch information
qubesuser committed Nov 10, 2017
1 parent 7dfe7de commit 1c01393
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
27 changes: 27 additions & 0 deletions qubes/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c01393

Please sign in to comment.