3 for cb
,opaque
in self
.domainEventCallbacks
.items():
4 del self
.domainEventCallbacks
[cb
]
5 del self
.domainEventCallbacks
6 libvirtmod
.virConnectDomainEventDeregister(self
._o
, self
)
11 libvirtmod
.virConnectClose(self
._o
)
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 """
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:
26 def domainEventRegister(self
, cb
, opaque
):
27 """Adds a Domain Event Callback. Registering for a domain
28 callback will enable delivery of the events """
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
40 for cb
,opaque
in self
.domainEventCallbacks
.items():
41 cb(self
,dom
,event
,detail
,opaque
)
43 except AttributeError:
46 def dispatchDomainEventLifecycleCallback(self
, dom
, event
, detail
, cbData
):
47 """Dispatches events to python user domain lifecycle event callbacks
50 opaque
= cbData
["opaque"]
52 cb(self
, virDomain(self
, _obj
=dom
), event
, detail
, opaque
)
55 def dispatchDomainEventGenericCallback(self
, dom
, cbData
):
56 """Dispatches events to python user domain generic event callbacks
60 opaque
= cbData
["opaque"]
62 cb(self
, virDomain(self
, _obj
=dom
), opaque
)
64 except AttributeError:
67 def dispatchDomainEventRTCChangeCallback(self
, dom
, offset
, cbData
):
68 """Dispatches events to python user domain RTC change event callbacks
72 opaque
= cbData
["opaque"]
74 cb(self
, virDomain(self
, _obj
=dom
), offset
,opaque
)
76 except AttributeError:
79 def dispatchDomainEventWatchdogCallback(self
, dom
, action
, cbData
):
80 """Dispatches events to python user domain watchdog event callbacks
84 opaque
= cbData
["opaque"]
86 cb(self
, virDomain(self
, _obj
=dom
), action
, opaque
)
88 except AttributeError:
91 def dispatchDomainEventIOErrorCallback(self
, dom
, srcPath
, devAlias
, action
, cbData
):
92 """Dispatches events to python user domain IO error event callbacks
96 opaque
= cbData
["opaque"]
98 cb(self
, virDomain(self
, _obj
=dom
), srcPath
, devAlias
, action
, opaque
)
100 except AttributeError:
103 def dispatchDomainEventIOErrorReasonCallback(self
, dom
, srcPath
, devAlias
, action
, reason
, cbData
):
104 """Dispatches events to python user domain IO error event callbacks
108 opaque
= cbData
["opaque"]
110 cb(self
, virDomain(self
, _obj
=dom
), srcPath
, devAlias
, action
, reason
, opaque
)
112 except AttributeError:
115 def dispatchDomainEventGraphicsCallback(self
, dom
, phase
, localAddr
, remoteAddr
, authScheme
, subject
, cbData
):
116 """Dispatches events to python user domain graphics event callbacks
120 opaque
= cbData
["opaque"]
122 cb(self
, virDomain(self
, _obj
=dom
), phase
, localAddr
, remoteAddr
, authScheme
, subject
, opaque
)
124 except AttributeError:
127 def dispatchDomainEventBlockPullCallback(self
, dom
, path
, status
, cbData
):
128 """Dispatches events to python user domain blockPull event callbacks
132 opaque
= cbData
["opaque"]
134 cb(self
, virDomain(self
, _obj
=dom
), path
, status
, opaque
)
136 except AttributeError:
139 def domainEventDeregisterAny(self
, callbackID
):
140 """Removes a Domain Event Callback. De-registering for a
141 domain callback will disable delivery of this event type """
143 ret
= libvirtmod
.virConnectDomainEventDeregisterAny(self
._o
, callbackID
)
144 if ret
== -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn
=self
)
145 del self
.domainEventCallbackID
[callbackID
]
146 except AttributeError:
149 def domainEventRegisterAny(self
, dom
, eventID
, cb
, opaque
):
150 """Adds a Domain Event Callback. Registering for a domain
151 callback will enable delivery of the events """
152 if not hasattr(self
, 'domainEventCallbackID'):
153 self
.domainEventCallbackID
= {}
154 cbData
= { "cb": cb
, "conn": self
, "opaque": opaque
}
156 ret
= libvirtmod
.virConnectDomainEventRegisterAny(self
._o
, None, eventID
, cbData
)
158 ret
= libvirtmod
.virConnectDomainEventRegisterAny(self
._o
, dom
._o
, eventID
, cbData
)
160 raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn
=self
)
161 self
.domainEventCallbackID
[ret
] = opaque