Utilities for common events-based actions
- qubesadmin.events.utils.interrupt_on_vm_shutdown(vms, dispatcher, subject, event)¶
Interrupt events processing when given VM was shutdown
- async qubesadmin.events.utils.wait_for_domain_shutdown(vms)¶
Helper function to wait for domain shutdown.
This function wait for domain shutdown, but do not initiate the shutdown itself.
vms – QubesVM object collection to wait for shutdown on
Event handling implementation, require Python >=3.5.2 for asyncio.
- class qubesadmin.events.EventsDispatcher(app, api_method='admin.Events', enable_cache=True)¶
Events dispatcher, responsible for receiving events and calling appropriate handlers
- add_handler(event, handler)¶
Register handler for event
Use ‘*’ as event to register a handler for all events.
- Handler function is called with:
subject (VM object or None)
event name (str)
keyword arguments related to the event, if any - all values as str
:param event Event name, or ‘*’ for all events :param handler Handler function
- handle(subject, event, **kwargs)¶
Call handlers for given event
event handlers - dict of event -> handlers
- async listen_for_events(vm=None, reconnect=True)¶
Listen for events and call appropriate handlers. This function do not exit until manually terminated.
This is coroutine.
vm – Listen for events only for this VM, use None to listen for events about all VMs and not related to any particular VM.
reconnect – should reconnect to qubesd if connection is interrupted?
- Return type:
- remove_handler(event, handler)¶
Remove previously registered event handler
:param event Event name :param handler Handler function
Stop currently running dispatcher