Skip to content

Commit

Permalink
event-test: Add node device lifecycle event tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JGulic authored and crobinso committed Aug 2, 2016
1 parent 58a9869 commit 8b2d5c0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/event-test.py
Expand Up @@ -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
##########################################################################
Expand Down Expand Up @@ -678,6 +692,8 @@ def exit():
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
Expand Down

0 comments on commit 8b2d5c0

Please sign in to comment.