[libvirt] [PATCH python 2/2] event-test: Add storage pool lifecycle event tests

Cole Robinson crobinso at redhat.com
Mon Jun 13 16:51:19 UTC 2016


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

> +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)

Thanks,
Cole




More information about the libvir-list mailing list