From 9c5531c5adccf1d6cc8194e3ed83a8f30210b91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 28 Jul 2017 22:28:27 +0200 Subject: [PATCH] events: add variable Admin API method name Add support for differnet methods, not only admin.Events. For example admin.vm.Stats also return events. --- qubesadmin/events/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qubesadmin/events/__init__.py b/qubesadmin/events/__init__.py index db8cf05..70b554f 100644 --- a/qubesadmin/events/__init__.py +++ b/qubesadmin/events/__init__.py @@ -30,11 +30,13 @@ import qubesadmin.exc class EventsDispatcher(object): ''' Events dispatcher, responsible for receiving events and calling appropriate handlers''' - def __init__(self, app): + def __init__(self, app, api_method='admin.Events'): '''Initialize EventsDispatcher''' #: Qubes() object self.app = app + self._api_method = api_method + #: event handlers - dict of event -> handlers self.handlers = {} @@ -77,7 +79,7 @@ class EventsDispatcher(object): reader, writer = yield from asyncio.open_unix_connection( qubesadmin.config.QUBESD_SOCKET) writer.write(b'dom0\0') # source - writer.write(b'admin.Events\0') # method + writer.write(self._api_method.encode() + b'\0') # method writer.write(dest.encode('ascii') + b'\0') # dest writer.write(b'\0') # arg writer.write_eof() @@ -87,7 +89,7 @@ class EventsDispatcher(object): writer.close() elif self.app.qubesd_connection_type == 'qrexec': proc = yield from asyncio.create_subprocess_exec( - 'qrexec-client-vm', dest, 'admin.Events', + 'qrexec-client-vm', dest, self._api_method, stdin=subprocess.PIPE, stdout=subprocess.PIPE) proc.stdin.write_eof()