I would like to make custom events to be listened by the
So currently, if I would like to do something on domain startup I could do something like this:
import qubesadmin.events import qubesadmin import asyncio def print_starting_domain(*args, **kwargs): print(args) print(kwargs) qubes = qubesadmin.Qubes() dispatcher = qubesadmin.events.EventsDispatcher(qubes) dispatcher.add_handler("domain-start", print_start_domain) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete( asyncio.ensure_future(dispatcher.listen_for_events()) ) loop.run_forever()
This code allows me to handle and get the vm information on startup. Now, I would like to do something similar but add my custom event (e.g. handle-vm-network).
I found that (AppVM, TemplateVM, AdminVM, DispVM, and StandaloneVM) under
qubes.vm are childs of
qubes.events.Emitter. So, I would like to use something as follow and receive the event using
import qubes class MyClass(qubes.events.Emitter): def __init__(self) -> None: super().__init__() self.events_enabled = True my_class = MyClass() my_class.fire_event('handle-vm-network')
Now, I would like to see the
handle-vm-network event in my previous code. Is there away to do so?