On 06/24/2016 01:38 PM, Daniel P. Berrange wrote:
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
examples/event-test.py | 6 ++++-
libvirt-override-virConnect.py | 10 ++++++++
libvirt-override.c | 54 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/examples/event-test.py b/examples/event-test.py
index 241369b..f0341b5 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -572,7 +572,6 @@ def storageEventToString(event):
"Undefined",
"Started",
"Stopped",
- "Refreshed",
)
return storageEventStrings[event]
@@ -581,6 +580,9 @@ def myStoragePoolEventLifecycleCallback(conn, pool, event, detail,
opaque):
storageEventToString(event),
detail))
+def myStoragePoolEventRefreshCallback(conn, pool, event, detail, opaque):
+ print("myStoragePoolEventRefreshCallback: Storage pool %s" % pool.name())
+
##########################################################################
# Set up and run the program
##########################################################################
@@ -672,7 +674,9 @@ 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.storagePoolEventRegisterAny(None, libvirt.VIR_STORAGE_POOL_EVENT_ID_REFRESH,
myStoragePoolEventRefreshCallback, None)
vc.setKeepAlive(5, 3)
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index 1aaa586..b085b07 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -312,6 +312,16 @@
cb(self, virStoragePool(self, _obj=pool), event, detail, opaque)
return 0
+ def _dispatchStoragePoolEventGenericCallback(self, pool, cbData):
+ """Dispatches events to python user storage pool
+ generic event callbacks
+ """
+ cb = cbData["cb"]
+ opaque = cbData["opaque"]
+
+ cb(self, virStoragePool(self, _obj=pool), opaque)
+ return 0
+
def storagePoolEventDeregisterAny(self, callbackID):
"""Removes a Storage Pool Event Callback. De-registering for a
storage pool callback will disable delivery of this event
type"""
diff --git a/libvirt-override.c b/libvirt-override.c
index 4734b7e..79e3d30 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8832,6 +8832,56 @@ libvirt_virConnectStoragePoolEventLifecycleCallback(virConnectPtr
conn ATTRIBUTE
return ret;
}
+static int
+libvirt_virConnectStoragePoolEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolPtr pool,
+ void *opaque)
+{
+ PyObject *pyobj_cbData = (PyObject*)opaque;
+ PyObject *pyobj_pool;
+ PyObject *pyobj_ret = NULL;
+ PyObject *pyobj_conn;
+ PyObject *dictKey;
+ int ret = -1;
+
+ LIBVIRT_ENSURE_THREAD_STATE;
+
+ if (!(dictKey = libvirt_constcharPtrWrap("conn")))
+ goto cleanup;
+ pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
+ Py_DECREF(dictKey);
+
+ /* Create a python instance of this virNetworkPtr */
Mentions virNetworkPtr
ACK otherwise
- Cole