feat(vm.start): with force can bypass blocked operation (#550)
See vatesfr/xo-web#2119
This commit is contained in:
parent
90be44738d
commit
9c5df507ae
@ -892,10 +892,11 @@ exports.rollingDrCopy = rollingDrCopy
|
|||||||
|
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
|
|
||||||
start = ({vm}) ->
|
start = ({vm, force}) ->
|
||||||
return @getXapi(vm).startVm(vm._xapiId)
|
return @getXapi(vm).startVm(vm._xapiId, force)
|
||||||
|
|
||||||
start.params = {
|
start.params = {
|
||||||
|
force: { type: 'boolean', optional: true}
|
||||||
id: { type: 'string' }
|
id: { type: 'string' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1433,9 +1433,15 @@ export default class Xapi extends XapiBase {
|
|||||||
await this._updateObjectMapProperty(vm, 'VCPUs_params', {weight})
|
await this._updateObjectMapProperty(vm, 'VCPUs_params', {weight})
|
||||||
}
|
}
|
||||||
|
|
||||||
_startVm (vm) {
|
async _startVm (vm, force) {
|
||||||
debug(`Starting VM ${vm.name_label}`)
|
debug(`Starting VM ${vm.name_label}`)
|
||||||
|
|
||||||
|
if (force) {
|
||||||
|
await this._updateObjectMapProperty(vm, 'blocked_operations', {
|
||||||
|
start: null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return this.call(
|
return this.call(
|
||||||
'VM.start',
|
'VM.start',
|
||||||
vm.$ref,
|
vm.$ref,
|
||||||
@ -1444,9 +1450,9 @@ export default class Xapi extends XapiBase {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async startVm (vmId) {
|
async startVm (vmId, force) {
|
||||||
try {
|
try {
|
||||||
await this._startVm(this.getObject(vmId))
|
await this._startVm(this.getObject(vmId), force)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code === 'OPERATION_BLOCKED') {
|
if (e.code === 'OPERATION_BLOCKED') {
|
||||||
throw forbiddenOperation('Start', e.params[1])
|
throw forbiddenOperation('Start', e.params[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user