[PATCH python 2/2] event-test: Add node device lifecycle event tests

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

 



---
 examples/event-test.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/examples/event-test.py b/examples/event-test.py
index 1bcea07..e06ebc6 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -584,6 +584,20 @@ def myStoragePoolEventRefreshCallback(conn, pool, opaque):
     print("myStoragePoolEventRefreshCallback: Storage pool %s" % pool.name())
 
 ##########################################################################
+# Node decice events
+##########################################################################
+def nodeDeviceEventToString(event):
+    nodeDeviceEventStrings = ( "Created",
+                               "Deleted",
+    )
+    return nodeDeviceEventStrings[event]
+
+def myNodeDeviceEventLifecycleCallback(conn, dev, event, detail, opaque):
+    print("myNodeDeviceEventLifecycleCallback: Node device  %s %s %d" % (dev.name(),
+                                                                          nodeDeviceEventToString(event),
+                                                                          detail))
+
+##########################################################################
 # Set up and run the program
 ##########################################################################
 
@@ -678,6 +692,8 @@ def main():
     vc.storagePoolEventRegisterAny(None, libvirt.VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE, myStoragePoolEventLifecycleCallback, None)
     vc.storagePoolEventRegisterAny(None, libvirt.VIR_STORAGE_POOL_EVENT_ID_REFRESH, myStoragePoolEventRefreshCallback, None)
 
+    vc.nodeDeviceEventRegisterAny(None, libvirt.VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE, myNodeDeviceEventLifecycleCallback, None)
+
     vc.setKeepAlive(5, 3)
 
     # The rest of your app would go here normally, but for sake
-- 
2.7.4

--
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]