diff options
author | Jovanka Gulicoska <jovanka.gulicoska@gmail.com> | 2016-07-28 14:14:14 +0200 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2016-08-02 09:55:56 -0400 |
commit | 8b2d5c06432673c2f4c72c2abfbae06886aa1134 (patch) | |
tree | 2b91277fa43d2011fe7042405e040a8f780f7161 | |
parent | 58a986984ff0762e9ed3962e70833729c987e4a6 (diff) | |
download | libvirt-python-8b2d5c06432673c2f4c72c2abfbae06886aa1134.tar.gz |
event-test: Add node device lifecycle event tests
-rwxr-xr-x | examples/event-test.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/event-test.py b/examples/event-test.py index 1bcea07..9b59b92 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 device 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 |