[PATCH libvirt-python v2 18/22] event-test.py: Convert STORAGE 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 | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/examples/event-test.py b/examples/event-test.py
index 2436827..499f434 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -620,20 +620,20 @@ def myNetworkEventLifecycleCallback(conn, net, event, detail, opaque):
 ##########################################################################
 # Storage pool events
 ##########################################################################
-def storageEventToString(event):
-    storageEventStrings = ( "Defined",
-                            "Undefined",
-                            "Started",
-                            "Stopped",
-                            "Created",
-                            "Deleted",
-    )
-    return storageEventStrings[event]
+STORAGE_EVENTS = Description(
+    ("Defined", ()),
+    ("Undefined", ()),
+    ("Started", ()),
+    ("Stopped", ()),
+    ("Created", ()),
+    ("Deleted", ()),
+)
+
 
 def myStoragePoolEventLifecycleCallback(conn, pool, event, detail, opaque):
-    print("myStoragePoolEventLifecycleCallback: Storage pool %s %s %d" % (pool.name(),
-                                                                          storageEventToString(event),
-                                                                          detail))
+    print("myStoragePoolEventLifecycleCallback: Storage pool %s %s %s" % (
+        pool.name(), STORAGE_EVENTS[event], STORAGE_EVENTS[event][detail]))
+
 
 def myStoragePoolEventRefreshCallback(conn, pool, opaque):
     print("myStoragePoolEventRefreshCallback: Storage pool %s" % pool.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