mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-31 00:45:18 +00:00
Fix printing of event detail in python events demo program
The events demo program is slightly misleading printing myDomainEventCallback1 EVENT: Domain f14i686(-1) Added which is not distinguishing Add vs Update events. It should have been doing myDomainEventCallback1 EVENT: Domain f14i686(-1) Defined Updated * examples/domain-events/events-python/event-test.py: Fully print event detail info string
This commit is contained in:
parent
cb06a9bfe5
commit
de8ecb12cb
@ -396,21 +396,34 @@ def virEventLoopPureStart():
|
||||
# Everything that now follows is a simple demo of domain lifecycle events
|
||||
##########################################################################
|
||||
def eventToString(event):
|
||||
eventStrings = ( "Added",
|
||||
"Removed",
|
||||
eventStrings = ( "Defined",
|
||||
"Undefined",
|
||||
"Started",
|
||||
"Suspended",
|
||||
"Resumed",
|
||||
"Stopped",
|
||||
"Saved",
|
||||
"Restored" );
|
||||
"Stopped" );
|
||||
return eventStrings[event];
|
||||
|
||||
def detailToString(event, detail):
|
||||
eventStrings = (
|
||||
( "Added", "Updated" ),
|
||||
( "Removed" ),
|
||||
( "Booted", "Migrated", "Restored", "Snapshot" ),
|
||||
( "Paused", "Migrated", "IOError", "Watchdog" ),
|
||||
( "Unpaused", "Migrated"),
|
||||
( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot")
|
||||
)
|
||||
return eventStrings[event][detail]
|
||||
|
||||
def myDomainEventCallback1 (conn, dom, event, detail, opaque):
|
||||
print "myDomainEventCallback1 EVENT: Domain %s(%s) %s %d" % (dom.name(), dom.ID(), eventToString(event), detail)
|
||||
print "myDomainEventCallback1 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
|
||||
eventToString(event),
|
||||
detailToString(event, detail))
|
||||
|
||||
def myDomainEventCallback2 (conn, dom, event, detail, opaque):
|
||||
print "myDomainEventCallback2 EVENT: Domain %s(%s) %s %d" % (dom.name(), dom.ID(), eventToString(event), detail)
|
||||
print "myDomainEventCallback2 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
|
||||
eventToString(event),
|
||||
detailToString(event, detail))
|
||||
|
||||
def myDomainEventRebootCallback(conn, dom, opaque):
|
||||
print "myDomainEventRebootCallback: Domain %s(%s)" % (dom.name(), dom.ID())
|
||||
|
Loading…
x
Reference in New Issue
Block a user