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
59 opaque
= cbData
["opaque"]
61 cb(self
, virDomain(self
, _obj
=dom
), opaque
)
64 def _dispatchDomainEventRTCChangeCallback(self
, dom
, offset
, cbData
):
65 """Dispatches events to python user domain RTC change event callbacks
68 opaque
= cbData
["opaque"]
70 cb(self
, virDomain(self
, _obj
=dom
), offset
,opaque
)
73 def _dispatchDomainEventWatchdogCallback(self
, dom
, action
, cbData
):
74 """Dispatches events to python user domain watchdog event callbacks
77 opaque
= cbData
["opaque"]
79 cb(self
, virDomain(self
, _obj
=dom
), action
, opaque
)
82 def _dispatchDomainEventIOErrorCallback(self
, dom
, srcPath
, devAlias
,
84 """Dispatches events to python user domain IO error event callbacks
87 opaque
= cbData
["opaque"]
89 cb(self
, virDomain(self
, _obj
=dom
), srcPath
, devAlias
, action
, opaque
)
92 def _dispatchDomainEventIOErrorReasonCallback(self
, dom
, srcPath
,
93 devAlias
, action
, reason
,
95 """Dispatches events to python user domain IO error event callbacks
98 opaque
= cbData
["opaque"]
100 cb(self
, virDomain(self
, _obj
=dom
), srcPath
, devAlias
, action
,
104 def _dispatchDomainEventGraphicsCallback(self
, dom
, phase
, localAddr
,
105 remoteAddr
, authScheme
, subject
,
107 """Dispatches events to python user domain graphics event callbacks
110 opaque
= cbData
["opaque"]
112 cb(self
, virDomain(self
, _obj
=dom
), phase
, localAddr
, remoteAddr
,
113 authScheme
, subject
, opaque
)
116 def dispatchDomainEventBlockPullCallback(self
, dom
, path
, type, status
, cbData
):
117 """Dispatches events to python user domain blockJob event callbacks
121 opaque
= cbData
["opaque"]
123 cb(self
, virDomain(self
, _obj
=dom
), path
, type, status
, opaque
)
125 except AttributeError:
128 def _dispatchDomainEventDiskChangeCallback(self
, dom
, oldSrcPath
, newSrcPath
, devAlias
, reason
, cbData
):
129 """Dispatches event to python user domain diskChange event callbacks
132 opaque
= cbData
["opaque"]
134 cb(self
, virDomain(self
, _obj
=dom
), oldSrcPath
, newSrcPath
, devAlias
, reason
, opaque
)
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 """
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:
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
}
154 ret
= libvirtmod
.virConnectDomainEventRegisterAny(self
._o
, None, eventID
, cbData
)
156 ret
= libvirtmod
.virConnectDomainEventRegisterAny(self
._o
, dom
._o
, eventID
, cbData
)
158 raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn
=self
)
159 self
.domainEventCallbackID
[ret
] = opaque