mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-02 04:21:59 +03:00
event-test: Add node device lifecycle event tests
This commit is contained in:
committed by
Cole Robinson
parent
58a986984f
commit
8b2d5c0643
@ -583,6 +583,20 @@ def myStoragePoolEventLifecycleCallback(conn, pool, event, detail, opaque):
|
||||
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
|
||||
|
Reference in New Issue
Block a user