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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



to use new Description class

Signed-off-by: Philipp Hahn <hahn@xxxxxxxxxxxxx>
---
 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux