Fix events watching XenServer < 6.0.

This commit is contained in:
Julien Fontanet 2015-10-23 16:53:42 +02:00
parent fcbc476462
commit 277669a13c

View File

@ -575,19 +575,26 @@ export class Xapi extends EventEmitter {
return Promise.all(map( return Promise.all(map(
getAllRecordsMethods, getAllRecordsMethods,
method => this._sessionCall(method, []).then(objects => { method => this._sessionCall(method, []).then(
const type = method.slice(0, method.indexOf('.')).toLowerCase() objects => {
forEach(objects, (object, ref) => { const type = method.slice(0, method.indexOf('.')).toLowerCase()
this._addObject(type, ref, object) forEach(objects, (object, ref) => {
}) this._addObject(type, ref, object)
}) })
},
error => {
if (error.code !== 'MESSAGE_REMOVED') {
throw error
}
}
)
)) ))
}) })
} }
const watchEvents = (() => { const watchEvents = (() => {
const loop = ((onSuccess, onFailure) => { const loop = ((onSuccess, onFailure) => {
return this._sessionCall('event.next', []).then(onSuccess, onFailure) return () => this._sessionCall('event.next', []).then(onSuccess, onFailure)
})( })(
events => { events => {
this._processEvents(events) this._processEvents(events)