to use new Description class
Signed-off-by: Philipp Hahn <hahn@univention.de>
---
examples/event-test.py | 42 ++++++++++++++----------------------------
1 file changed, 14 insertions(+), 28 deletions(-)
diff --git a/examples/event-test.py b/examples/event-test.py
index d2d2c60..493828f 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -481,32 +481,18 @@ class Description(object):
raise TypeError(args)
-def domEventToString(event):
- domEventStrings = ( "Defined",
- "Undefined",
- "Started",
- "Suspended",
- "Resumed",
- "Stopped",
- "Shutdown",
- "PMSuspended",
- "Crashed",
- )
- return domEventStrings[event]
-
-def domDetailToString(event, detail):
- domEventStrings = (
- ( "Added", "Updated", "Renamed", "Snapshot" ),
- ( "Removed", "Renamed", ),
- ( "Booted", "Migrated", "Restored", "Snapshot", "Wakeup" ),
- ( "Paused", "Migrated", "IOError", "Watchdog", "Restored", "Snapshot", "API error", "Postcopy", "Postcopy failed" ),
- ( "Unpaused", "Migrated", "Snapshot", "Postcopy" ),
- ( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot"),
- ( "Finished", "On guest request", "On host request"),
- ( "Memory", "Disk" ),
- ( "Panicked", ),
- )
- return domEventStrings[event][detail]
+DOM_EVENTS = Description(
+ ("Defined", ("Added", "Updated", "Renamed", "Snapshot")),
+ ("Undefined", ("Removed", "Renamed")),
+ ("Started", ("Booted", "Migrated", "Restored", "Snapshot", "Wakeup")),
+ ("Suspended", ("Paused", "Migrated", "IOError", "Watchdog", "Restored", "Snapshot", "API error", "Postcopy", "Postcopy failed")),
+ ("Resumed", ("Unpaused", "Migrated", "Snapshot", "Postcopy")),
+ ("Stopped", ("Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot")),
+ ("Shutdown", ("Finished", "On guest request", "On host request")),
+ ("PMSuspended", ("Memory", "Disk")),
+ ("Crashed", ("Panicked",)),
+)
+
def blockJobTypeToString(type):
blockJobTypes = ( "unknown", "Pull", "Copy", "Commit", "ActiveCommit", )
@@ -526,8 +512,8 @@ def agentLifecycleReasonToString(reason):
def myDomainEventCallback(conn, dom, event, detail, opaque):
- print("myDomainEventCallback%d EVENT: Domain %s(%s) %s %s" % (
- opaque, dom.name(), dom.ID(), domEventToString(event), domDetailToString(event, detail)))
+ print("myDomainEventCallback%s EVENT: Domain %s(%s) %s %s" % (
+ opaque, dom.name(), dom.ID(), DOM_EVENTS[event], DOM_EVENTS[event][detail]))
def myDomainEventRebootCallback(conn, dom, opaque):
--
2.11.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list