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

Philipp Hahn posted 22 patches 6 years, 2 months ago
[libvirt] [PATCH libvirt-python v2 20/22] event-test.py: Convert SECRET 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 0a1d06d..5e3b884 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -658,16 +658,16 @@ def myNodeDeviceEventUpdateCallback(conn, dev, opaque):
 ##########################################################################
 # Secret events
 ##########################################################################
-def secretEventToString(event):
-    secretEventStrings = ( "Defined",
-                           "Undefined",
-    )
-    return secretEventStrings[event]
+SECRET_EVENTS = Description(
+    ("Defined", ()),
+    ("Undefined", ()),
+)
+
 
 def mySecretEventLifecycleCallback(conn, secret, event, detail, opaque):
-    print("mySecretEventLifecycleCallback: Secret %s %s %d" % (secret.UUIDString(),
-                                                               secretEventToString(event),
-                                                               detail))
+    print("mySecretEventLifecycleCallback: Secret %s %s %s" % (
+        secret.UUIDString(), SECRET_EVENTS[event], SECRET_EVENTS[event][detail]))
+
 
 def mySecretEventValueChanged(conn, secret, opaque):
     print("mySecretEventValueChanged: Secret %s" % secret.UUIDString())
-- 
2.11.0

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