to use new Description class
Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
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