feat(xapi): host_restartAgent

This commit is contained in:
Julien Fontanet
2022-03-21 10:40:35 +01:00
parent 1aa4fac528
commit 0eb2ee72a4
4 changed files with 19 additions and 5 deletions

View File

@@ -0,0 +1,17 @@
module.exports = class Host {
async restartAgent(ref) {
const agentStartTime = +(await this.getField('host', ref, 'other_config')).agent_start_time
await this.call('host.restart_agent', ref)
await new Promise(resolve => {
// even though the ref could change in case of pool master restart, tests show it stays the same
const stopWatch = this.watchObject(ref, host => {
if (+host.other_config.agent_start_time > agentStartTime) {
stopWatch()
resolve()
}
})
})
}
}

View File

@@ -206,6 +206,7 @@ function mixin(mixins) {
}
mixin({
task: require('./task.js'),
host: require('./host.js'),
VBD: require('./vbd.js'),
VDI: require('./vdi.js'),
VIF: require('./vif.js'),

View File

@@ -134,7 +134,7 @@ restart.resolve = {
// -------------------------------------------------------------------
export function restartAgent({ host }) {
return this.getXapi(host).restartHostAgent(host._xapiId)
return this.getXapiObject(host).$restartAgent()
}
restartAgent.description = 'restart the Xen agent on the host'

View File

@@ -302,10 +302,6 @@ export default class Xapi extends XapiBase {
await this.callAsync('host.reboot', host.$ref)
}
async restartHostAgent(hostId) {
await this.callAsync('host.restart_agent', this.getObject(hostId).$ref)
}
async setRemoteSyslogHost(hostId, syslogDestination) {
const host = this.getObject(hostId)
await host.set_logging({