summaryrefslogtreecommitdiffstats
path: root/libvirt-override-virConnect.py
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-07-30 17:30:42 +0100
committerDaniel P. Berrange <berrange@redhat.com>2012-12-04 13:50:11 +0000
commitac532dd37dcca7f7b43dda56516aa39a69b3401c (patch)
tree0966583fc83ee58239659724736b3bb846e59356 /libvirt-override-virConnect.py
parentca7f58d203971b219bb965f20500cf463fdbed58 (diff)
downloadlibvirt-python-v6-ac532dd37dcca7f7b43dda56516aa39a69b3401c.tar.gz
libvirt-python-v6-ac532dd37dcca7f7b43dda56516aa39a69b3401c.tar.xz
libvirt-python-v6-ac532dd37dcca7f7b43dda56516aa39a69b3401c.zip
Bind connection close callback APIs to python binding
Add code in the python binding to cope with the new APIs virConnectRegisterCloseCallback and virConnectUnregisterCloseCallback. Also demonstrate their use in the python domain events demo Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'libvirt-override-virConnect.py')
-rw-r--r--libvirt-override-virConnect.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index cb8d892..84d6cc3 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -287,3 +287,26 @@
retlist.append(virSecret(self, _obj=secret_ptr))
return retlist
+
+ def _dispatchCloseCallback(self, reason, cbData):
+ """Dispatches events to python user close callback"""
+ cb = cbData["cb"]
+ opaque = cbData["opaque"]
+
+ cb(self, reason, opaque)
+ return 0
+
+
+ def unregisterCloseCallback(self):
+ """Removes a close event callback"""
+ ret = libvirtmod.virConnectUnregisterCloseCallback(self._o)
+ if ret == -1: raise libvirtError ('virConnectUnregisterCloseCallback() failed', conn=self)
+
+ def registerCloseCallback(self, cb, opaque):
+ """Adds a close event callback, providing a notification
+ when a connection fails / closes"""
+ cbData = { "cb": cb, "conn": self, "opaque": opaque }
+ ret = libvirtmod.virConnectRegisterCloseCallback(self._o, cbData)
+ if ret == -1:
+ raise libvirtError ('virConnectRegisterCloseCallback() failed', conn=self)
+ return ret