[PATCH libvirt-python v2 17/22] event-test.py: Convert NETWORK 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 | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/examples/event-test.py b/examples/event-test.py
index 5426ecd..2436827 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -604,27 +604,18 @@ def myDomainEventBlockThresholdCallback(conn, dom, dev, path, threshold, excess,
 ##########################################################################
 # Network events
 ##########################################################################
-def netEventToString(event):
-    netEventStrings = ( "Defined",
-                     "Undefined",
-                     "Started",
-                     "Stopped",
-    )
-    return netEventStrings[event]
-
-def netDetailToString(event, detail):
-    netEventStrings = (
-        ( "Added", ),
-        ( "Removed", ),
-        ( "Started", ),
-        ( "Stopped", ),
-    )
-    return netEventStrings[event][detail]
+NET_EVENTS = Description(
+    ("Defined", ("Added",)),
+    ("Undefined", ("Removed",)),
+    ("Started", ("Started",)),
+    ("Stopped", ("Stopped",)),
+)
+
 
 def myNetworkEventLifecycleCallback(conn, net, event, detail, opaque):
-    print("myNetworkEventLifecycleCallback: Network %s %s %s" % (net.name(),
-                                                                 netEventToString(event),
-                                                                 netDetailToString(event, detail)))
+    print("myNetworkEventLifecycleCallback: Network %s %s %s" % (
+        net.name(), NET_EVENTS[event], NET_EVENTS[event][detail]))
+
 
 ##########################################################################
 # Storage pool events
-- 
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