feat(xo-server/host): ability to enable/disable multipathing (#3858)
See #3659
This commit is contained in:
parent
270185d9dc
commit
ea48136797
@ -2,14 +2,22 @@ import { format } from 'json-rpc-peer'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export function set({
|
||||
export async function set({
|
||||
host,
|
||||
multipathing,
|
||||
|
||||
// TODO: use camel case.
|
||||
name_label: nameLabel,
|
||||
name_description: nameDescription,
|
||||
}) {
|
||||
return this.getXapi(host).setHostProperties(host._xapiId, {
|
||||
const xapi = this.getXapi(host)
|
||||
const hostId = host._xapiId
|
||||
|
||||
if (multipathing !== undefined) {
|
||||
await xapi.setHostMultipathing(hostId, multipathing)
|
||||
}
|
||||
|
||||
return xapi.setHostProperties(hostId, {
|
||||
nameLabel,
|
||||
nameDescription,
|
||||
})
|
||||
@ -27,6 +35,10 @@ set.params = {
|
||||
type: 'string',
|
||||
optional: true,
|
||||
},
|
||||
multipathing: {
|
||||
type: 'boolean',
|
||||
optional: true,
|
||||
},
|
||||
}
|
||||
|
||||
set.resolve = {
|
||||
|
@ -415,6 +415,36 @@ export default class Xapi extends XapiBase {
|
||||
await this.call('host.enable', this.getObject(hostId).$ref)
|
||||
}
|
||||
|
||||
@deferrable.onError(log.warn)
|
||||
async setHostMultipathing($defer, hostId, multipathing) {
|
||||
const host = this.getObject(hostId)
|
||||
|
||||
const pluggedPbds = host.$PBDs.filter(pbd => pbd.currently_attached)
|
||||
await asyncMap(pluggedPbds, async pbd => {
|
||||
const ref = pbd.$ref
|
||||
await this.unplugPbd(ref)
|
||||
$defer(() => this.plugPbd(ref))
|
||||
})
|
||||
|
||||
if (host.enabled) {
|
||||
await this.disableHost(hostId)
|
||||
$defer(() => this.enableHost(hostId))
|
||||
}
|
||||
|
||||
return this._updateObjectMapProperty(
|
||||
host,
|
||||
'other_config',
|
||||
multipathing
|
||||
? {
|
||||
multipathing: 'true',
|
||||
multipathhandle: 'dmp',
|
||||
}
|
||||
: {
|
||||
multipathing: 'false',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async powerOnHost(hostId) {
|
||||
await this.call('host.power_on', this.getObject(hostId).$ref)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user