On Mon, Jun 13, 2016 at 12:51:19PM -0400, Cole Robinson wrote:
On 06/11/2016 01:43 PM, Jovanka Gulicoska wrote:--- examples/event-test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/event-test.py b/examples/event-test.py index f96c917..241369b 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -565,6 +565,23 @@ def myNetworkEventLifecycleCallback(conn, net, event, detail, opaque): netDetailToString(event, detail))) ########################################################################## +# Storage pool events +########################################################################## +def storageEventToString(event): + storageEventStrings = ( "Defined", + "Undefined", + "Started", + "Stopped", + "Refreshed", + ) + return storageEventStrings[event] +This pattern is problematic, since if libvirt grows a new event ID this code throws an exception until we extend storageEventStrings. That said, this pattern is used all over event-test.py so it deserves a larger cleanup IMO, there's even a bug for an issue like this https://bugzilla.redhat.com/show_bug.cgi?id=1274145
Well, it's an example, so I think it's fine.
+def myStoragePoolEventLifecycleCallback(conn, pool, event, detail, opaque): + print("myStoragePoolEventLifecycleCallback: Storage pool %s %s %d" % (pool.name(), + storageEventToString(event), + detail)) + +########################################################################## # Set up and run the program ########################################################################## @@ -655,6 +672,7 @@ def main(): vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, myDomainEventDeviceRemovalFailedCallback, None) vc.networkEventRegisterAny(None, libvirt.VIR_NETWORK_EVENT_ID_LIFECYCLE, myNetworkEventLifecycleCallback, None) + vc.storagePoolEventRegisterAny(None, libvirt.VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE, myStoragePoolEventLifecycleCallback, None) vc.setKeepAlive(5, 3)ACK regardless of that bit. If there aren't any other comments I can fix the whitespace issue in patch #1 when pushing (once the libvirt.git bits go in)
Looks fine to me after a quick skim.
Thanks, Cole -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list