qubes/mgmt: mgmt.vm.property.List

QubesOS/qubes-issues#2622
This commit is contained in:
Wojtek Porczyk 2017-02-09 20:16:23 +01:00
parent c12fc744a2
commit 02639b8d02

View File

@ -114,6 +114,12 @@ class QubesMgmt(object):
return self.src.fire_event_pre('mgmt-permission:{}'.format(self.method),
self.dest, self.arg, *args, **kwargs)
@not_in_api
def fire_event_for_filter(self, iterable, *args, **kwargs):
for selector in self.fire_event_for_permission(*args, **kwargs):
iterable = filter(selector, iterable)
return iterable
@not_in_api
def repr(self, *args, **kwargs):
return self.prepr.repr(*args, **kwargs)
@ -128,9 +134,7 @@ class QubesMgmt(object):
assert not untrusted_payload
del untrusted_payload
domains = self.app.domains
for selector in self.fire_event_for_permission():
domains = filter(selector, domains)
domains = self.fire_event_for_filter(self.app.domains)
return ''.join('{} class={} state={}\n'.format(
self.repr(vm),
@ -138,6 +142,15 @@ class QubesMgmt(object):
vm.get_power_state())
for vm in sorted(domains))
def vm_property_list(self, untrusted_payload):
assert not self.arg
assert not untrusted_payload
del untrusted_payload
properties = self.fire_event_for_filter(self.dest.property_list())
return ''.join('{}\n'.format(prop.__name__) for prop in properties)
def vm_property_get(self, untrusted_payload):
assert self.arg in self.dest.property_list()
assert not untrusted_payload
@ -153,5 +166,3 @@ class QubesMgmt(object):
return 'default={} {}'.format(
str(self.dest.property_is_default(self.arg)),
self.repr(value))