emergencyHostShutdown(hostId) : suspends all the VMs running on the host and then shuts the host down
This commit is contained in:
parent
9fe3ef430f
commit
ad4439ed55
@ -256,6 +256,23 @@ exports.installAllPatches = installAllPatches
|
|||||||
|
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
|
|
||||||
|
emergencyShutdownHost = ({host}) ->
|
||||||
|
return @getXAPI(host).emergencyShutdownHost(host._xapiId)
|
||||||
|
|
||||||
|
emergencyShutdownHost.description = 'suspend all VMs and shutdown host'
|
||||||
|
|
||||||
|
emergencyShutdownHost.params = {
|
||||||
|
host: { type: 'string' }
|
||||||
|
}
|
||||||
|
|
||||||
|
emergencyShutdownHost.resolve = {
|
||||||
|
host: ['host', 'host', 'administrate']
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.emergencyShutdownHost = emergencyShutdownHost
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
|
||||||
stats = ({host, granularity}) ->
|
stats = ({host, granularity}) ->
|
||||||
return @getXapiHostStats(host, granularity)
|
return @getXapiHostStats(host, granularity)
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ rollingSnapshot.resolve = {
|
|||||||
vm: ['id', 'VM', 'administrate']
|
vm: ['id', 'VM', 'administrate']
|
||||||
}
|
}
|
||||||
|
|
||||||
rollingSnapshot.description = 'Snaphots a VM with a tagged name, and removes the oldest snapshot with the same tag according to depth'
|
rollingSnapshot.description = 'Snapshots a VM with a tagged name, and removes the oldest snapshot with the same tag according to depth'
|
||||||
|
|
||||||
exports.rollingSnapshot = rollingSnapshot
|
exports.rollingSnapshot = rollingSnapshot
|
||||||
|
|
||||||
|
18
src/xapi.js
18
src/xapi.js
@ -23,7 +23,8 @@ import {
|
|||||||
mapToArray,
|
mapToArray,
|
||||||
noop,
|
noop,
|
||||||
parseXml,
|
parseXml,
|
||||||
pFinally
|
pFinally,
|
||||||
|
pSettle
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import {JsonRpcError} from './api-errors'
|
import {JsonRpcError} from './api-errors'
|
||||||
|
|
||||||
@ -560,6 +561,21 @@ export default class Xapi extends XapiBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async emergencyShutdownHost (hostId) {
|
||||||
|
const host = this.getObject(hostId)
|
||||||
|
const vms = host.$resident_VMs
|
||||||
|
debug(`Emergency shutdown: ${host.name_label}`)
|
||||||
|
await pSettle(
|
||||||
|
mapToArray(vms, vm => {
|
||||||
|
if (!vm.is_control_domain) {
|
||||||
|
return this.call('VM.suspend', vm.$ref)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
await this.call('host.disable', host.$ref)
|
||||||
|
await this.call('host.shutdown', host.$ref)
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
|
||||||
// Disable the host and evacuate all its VMs.
|
// Disable the host and evacuate all its VMs.
|
||||||
|
Loading…
Reference in New Issue
Block a user