[libvirt-python][PATCH] examples: Update event-test.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With recent changes there are new events known to libvirt.
Reflect those changes in our event-test.py example script.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 examples/event-test.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/examples/event-test.py b/examples/event-test.py
index e43a2f8..d5af33c 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -538,6 +538,9 @@ def myDomainEventJobCompletedCallback(conn, dom, params, opaque):
 def myDomainEventDeviceRemovalFailedCallback(conn, dom, dev, opaque):
     print("myDomainEventDeviceRemovalFailedCallback: Domain %s(%s) failed to remove device: %s" % (
             dom.name(), dom.ID(), dev))
+def myDomainEventMetadataChangeCallback(conn, dom, mtype, nsuri, opaque):
+    print("myDomainEventMetadataChangeCallback: Domain %s(%s) changed metadata mtype=%d nsuri=%s" % (
+            dom.name(), dom.ID(), mtype, nsuri))
 
 ##########################################################################
 # Network events
@@ -600,6 +603,23 @@ def myNodeDeviceEventLifecycleCallback(conn, dev, event, detail, opaque):
 def myNodeDeviceEventUpdateCallback(conn, dev, opaque):
     print("myNodeDeviceEventUpdateCallback: Node device %s" % dev.name())
 
+##########################################################################
+# Secret events
+##########################################################################
+def secretEventToString(event):
+    secretEventStrings = ( "Defined",
+                           "Undefined",
+    )
+    return secretEventStrings[event]
+
+def mySecretEventLifecycleCallback(conn, secret, event, detail, opaque):
+    print("mySecretEventLifecycleCallback: Secret %s %s %d" % (secret.UUIDString(),
+                                                               secretEventToString(event),
+                                                               detail))
+
+def mySecretEventValueChanged(conn, secret, opaque):
+    print("mySecretEventValueChanged: Secret %s" % secret.UUIDString())
+
 ##########################################################################
 # Set up and run the program
 ##########################################################################
@@ -689,6 +709,7 @@ def main():
     vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION, myDomainEventMigrationIteration, None)
     vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_JOB_COMPLETED, myDomainEventJobCompletedCallback, None)
     vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, myDomainEventDeviceRemovalFailedCallback, None)
+    vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_METADATA_CHANGE, myDomainEventMetadataChangeCallback, None)
 
     vc.networkEventRegisterAny(None, libvirt.VIR_NETWORK_EVENT_ID_LIFECYCLE, myNetworkEventLifecycleCallback, None)
 
@@ -698,6 +719,9 @@ def main():
     vc.nodeDeviceEventRegisterAny(None, libvirt.VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE, myNodeDeviceEventLifecycleCallback, None)
     vc.nodeDeviceEventRegisterAny(None, libvirt.VIR_NODE_DEVICE_EVENT_ID_UPDATE, myNodeDeviceEventUpdateCallback, None)
 
+    vc.secretEventRegisterAny(None, libvirt.VIR_SECRET_EVENT_ID_LIFECYCLE, mySecretEventLifecycleCallback, None)
+    vc.secretEventRegisterAny(None, libvirt.VIR_SECRET_EVENT_ID_VALUE_CHANGED, mySecretEventValueChanged, None)
+
     vc.setKeepAlive(5, 3)
 
     # The rest of your app would go here normally, but for sake
-- 
2.11.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux