chore(xo-server/vm.reboot): move into Xapi#rebootVm

This commit is contained in:
Julien Fontanet
2019-05-21 10:37:56 +02:00
parent 7be1c7a47b
commit 1e529c995a
2 changed files with 8 additions and 7 deletions

View File

@@ -630,13 +630,7 @@ set.resolve = {
// -------------------------------------------------------------------
export async function restart({ vm, force = false }) {
const xapi = this.getXapi(vm)
if (force) {
await xapi.call('VM.hard_reboot', vm._xapiRef)
} else {
await xapi.call('VM.clean_reboot', vm._xapiRef)
}
return this.getXapi(vm).rebootVm(vm._xapiId, { hard: force })
}
restart.params = {

View File

@@ -513,6 +513,13 @@ export default {
return this.call('VM.unpause', this.getObject(vmId).$ref)
},
rebootVm(vmId, { hard = false } = {}) {
return this.callAsync(
`VM.${hard ? 'hard' : 'clean'}_reboot`,
this.getObject(vmId).$ref
).then(noop)
},
shutdownVm(vmId, { hard = false } = {}) {
return this.call(
`VM.${hard ? 'hard' : 'clean'}_shutdown`,