python: add python binding for virDomainSetMemoryParameters
[libvirt-python/ericb.git] / libvirt-override-virConnect.py
blob65b53420c6e1ba7bd05992ff9423fa22d19efadf
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 domainEventDeregisterAny(self, callbackID):
129 """Removes a Domain Event Callback. De-registering for a
130 domain callback will disable delivery of this event type """
131 try:
132 ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
133 if ret == -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn=self)
134 del self.domainEventCallbackID[callbackID]
135 except AttributeError:
136 pass
138 def domainEventRegisterAny(self, dom, eventID, cb, opaque):
139 """Adds a Domain Event Callback. Registering for a domain
140 callback will enable delivery of the events """
141 if not hasattr(self, 'domainEventCallbackID'):
142 self.domainEventCallbackID = {}
143 cbData = { "cb": cb, "conn": self, "opaque": opaque }
144 if dom is None:
145 ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
146 else:
147 ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
148 if ret == -1:
149 raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn=self)
150 self.domainEventCallbackID[ret] = opaque
151 return ret