[libvirt] [PATCH libvirt-python v2 19/22] event-test.py: Convert DEVICE events

Philipp Hahn posted 22 patches 6 years, 2 months ago
[libvirt] [PATCH libvirt-python v2 19/22] event-test.py: Convert DEVICE events
Posted by Philipp Hahn 6 years, 2 months ago
to use new Description class

Signed-off-by: Philipp Hahn <hahn@univention.de>
---
 examples/event-test.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/examples/event-test.py b/examples/event-test.py
index 499f434..0a1d06d 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -641,16 +641,16 @@ def myStoragePoolEventRefreshCallback(conn, pool, opaque):
 ##########################################################################
 # Node device events
 ##########################################################################
-def nodeDeviceEventToString(event):
-    nodeDeviceEventStrings = ( "Created",
-                               "Deleted",
-    )
-    return nodeDeviceEventStrings[event]
+DEVICE_EVENTS = Description(
+    ("Created", ()),
+    ("Deleted", ()),
+)
+
 
 def myNodeDeviceEventLifecycleCallback(conn, dev, event, detail, opaque):
-    print("myNodeDeviceEventLifecycleCallback: Node device  %s %s %d" % (dev.name(),
-                                                                          nodeDeviceEventToString(event),
-                                                                          detail))
+    print("myNodeDeviceEventLifecycleCallback: Node device  %s %s %s" % (
+        dev.name(), DEVICE_EVENTS[event], DEVICE_EVENTS[event][detail]))
+
 
 def myNodeDeviceEventUpdateCallback(conn, dev, opaque):
     print("myNodeDeviceEventUpdateCallback: Node device %s" % dev.name())
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list