Add new API virDomain{Set, Get}BlockIoTune
[libvirt-python/ericb.git] / libvirt-override-virConnect.py
blobb908b32dfb28ee900d81b17ef7566d03942f416c
1 def __del__(self):
2 try:
3 for cb,opaque in self.domainEventCallbacks.items():
4 del self.domainEventCallbacks[cb]
5 del self.domainEventCallbacks
6 libvirtmod.virConnectDomainEventDeregister(self._o, self)
7 except AttributeError:
8 pass
10 if self._o != None:
11 libvirtmod.virConnectClose(self._o)
12 self._o = None
14 def domainEventDeregister(self, cb):
15 """Removes a Domain Event Callback. De-registering for a
16 domain callback will disable delivery of this event type """
17 try:
18 del self.domainEventCallbacks[cb]
19 if len(self.domainEventCallbacks) == 0:
20 del self.domainEventCallbacks
21 ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
22 if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
23 except AttributeError:
24 pass
26 def domainEventRegister(self, cb, opaque):
27 """Adds a Domain Event Callback. Registering for a domain
28 callback will enable delivery of the events """
29 try:
30 self.domainEventCallbacks[cb] = opaque
31 except AttributeError:
32 self.domainEventCallbacks = {cb:opaque}
33 ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
34 if ret == -1: raise libvirtError ('virConnectDomainEventRegister() failed', conn=self)
36 def _dispatchDomainEventCallbacks(self, dom, event, detail):
37 """Dispatches events to python user domain event callbacks
38 """
39 try:
40 for cb,opaque in self.domainEventCallbacks.items():
41 cb(self,dom,event,detail,opaque)
42 return 0
43 except AttributeError:
44 pass
46 def _dispatchDomainEventLifecycleCallback(self, dom, event, detail, cbData):
47 """Dispatches events to python user domain lifecycle event callbacks
48 """
49 cb = cbData["cb"]
50 opaque = cbData["opaque"]
52 cb(self, virDomain(self, _obj=dom), event, detail, opaque)
53 return 0
55 def _dispatchDomainEventGenericCallback(self, dom, cbData):
56 """Dispatches events to python user domain generic event callbacks
57 """
58 cb = cbData["cb"]
59 opaque = cbData["opaque"]
61 cb(self, virDomain(self, _obj=dom), opaque)
62 return 0
64 def _dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
65 """Dispatches events to python user domain RTC change event callbacks
66 """
67 cb = cbData["cb"]
68 opaque = cbData["opaque"]
70 cb(self, virDomain(self, _obj=dom), offset ,opaque)
71 return 0
73 def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
74 """Dispatches events to python user domain watchdog event callbacks
75 """
76 cb = cbData["cb"]
77 opaque = cbData["opaque"]
79 cb(self, virDomain(self, _obj=dom), action, opaque)
80 return 0
82 def _dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias,
83 action, cbData):
84 """Dispatches events to python user domain IO error event callbacks
85 """
86 cb = cbData["cb"]
87 opaque = cbData["opaque"]
89 cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, opaque)
90 return 0
92 def _dispatchDomainEventIOErrorReasonCallback(self, dom, srcPath,
93 devAlias, action, reason,
94 cbData):
95 """Dispatches events to python user domain IO error event callbacks
96 """
97 cb = cbData["cb"]
98 opaque = cbData["opaque"]
100 cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action,
101 reason, opaque)
102 return 0
104 def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
105 remoteAddr, authScheme, subject,
106 cbData):
107 """Dispatches events to python user domain graphics event callbacks
109 cb = cbData["cb"]
110 opaque = cbData["opaque"]
112 cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr,
113 authScheme, subject, opaque)
114 return 0
116 def dispatchDomainEventBlockPullCallback(self, dom, path, type, status, cbData):
117 """Dispatches events to python user domain blockJob event callbacks
119 try:
120 cb = cbData["cb"]
121 opaque = cbData["opaque"]
123 cb(self, virDomain(self, _obj=dom), path, type, status, opaque)
124 return 0
125 except AttributeError:
126 pass
128 def _dispatchDomainEventDiskChangeCallback(self, dom, oldSrcPath, newSrcPath, devAlias, reason, cbData):
129 """Dispatches event to python user domain diskChange event callbacks
131 cb = cbData["cb"]
132 opaque = cbData["opaque"]
134 cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason, opaque)
135 return 0;
137 def domainEventDeregisterAny(self, callbackID):
138 """Removes a Domain Event Callback. De-registering for a
139 domain callback will disable delivery of this event type """
140 try:
141 ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
142 if ret == -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn=self)
143 del self.domainEventCallbackID[callbackID]
144 except AttributeError:
145 pass
147 def domainEventRegisterAny(self, dom, eventID, cb, opaque):
148 """Adds a Domain Event Callback. Registering for a domain
149 callback will enable delivery of the events """
150 if not hasattr(self, 'domainEventCallbackID'):
151 self.domainEventCallbackID = {}
152 cbData = { "cb": cb, "conn": self, "opaque": opaque }
153 if dom is None:
154 ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
155 else:
156 ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
157 if ret == -1:
158 raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn=self)
159 self.domainEventCallbackID[ret] = opaque
160 return ret