Xapi#setPoolProperties() supports autoPowerOn.
This commit is contained in:
parent
90f79b7708
commit
5cd3e1b368
@ -14,10 +14,17 @@ startsWith = require 'lodash.startswith'
|
|||||||
|
|
||||||
#=====================================================================
|
#=====================================================================
|
||||||
|
|
||||||
set = (params) ->
|
set = ({
|
||||||
host = extractProperty(params, 'host')
|
host,
|
||||||
|
|
||||||
return @getXAPI(host).setHostProperties(host._xapiId, params)
|
# TODO: use camel case.
|
||||||
|
name_label: nameLabel,
|
||||||
|
name_description: nameDescription
|
||||||
|
}) ->
|
||||||
|
return @getXAPI(host).setHostProperties(host._xapiId, {
|
||||||
|
nameLabel,
|
||||||
|
nameDescription
|
||||||
|
})
|
||||||
|
|
||||||
set.description = 'changes the properties of an host'
|
set.description = 'changes the properties of an host'
|
||||||
|
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import {JsonRpcError} from '../api-errors'
|
import {JsonRpcError} from '../api-errors'
|
||||||
import {extractProperty} from '../utils'
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
export async function set (params) {
|
export async function set ({
|
||||||
const pool = extractProperty(params, 'pool')
|
pool,
|
||||||
|
|
||||||
await this.getXAPI(pool).setPoolProperties(params)
|
// TODO: use camel case.
|
||||||
|
name_description: nameDescription,
|
||||||
|
name_label: nameLabel
|
||||||
|
}) {
|
||||||
|
await this.getXAPI(pool).setPoolProperties({
|
||||||
|
nameDescription,
|
||||||
|
nameLabel
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
set.params = {
|
set.params = {
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
import {
|
import {
|
||||||
ensureArray,
|
ensureArray,
|
||||||
extractProperty,
|
|
||||||
forEach,
|
forEach,
|
||||||
parseXml
|
parseXml
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
export async function set (params) {
|
export async function set ({
|
||||||
const sr = extractProperty(params, 'sr')
|
sr,
|
||||||
|
|
||||||
await this.getXAPI(sr).setSrProperties(sr._xapiId, params)
|
// TODO: use camel case.
|
||||||
|
name_description: nameDescription,
|
||||||
|
name_label: nameLabel
|
||||||
|
}) {
|
||||||
|
await this.getXAPI(sr).setSrProperties(sr._xapiId, {
|
||||||
|
nameDescription,
|
||||||
|
nameLabel
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
set.params = {
|
set.params = {
|
||||||
|
48
src/xapi.js
48
src/xapi.js
@ -234,32 +234,52 @@ export default class Xapi extends XapiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setHostProperties (id, {
|
async setHostProperties (id, {
|
||||||
name_label,
|
nameLabel,
|
||||||
name_description
|
nameDescription
|
||||||
}) {
|
}) {
|
||||||
await this._setObjectProperties(this.getObject(id), {
|
await this._setObjectProperties(this.getObject(id), {
|
||||||
name_label,
|
nameLabel,
|
||||||
name_description
|
nameDescription
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async setPoolProperties ({
|
async setPoolProperties ({
|
||||||
name_label,
|
autoPowerOn,
|
||||||
name_description
|
nameLabel,
|
||||||
|
nameDescription
|
||||||
}) {
|
}) {
|
||||||
await this._setObjectProperties(this.pool, {
|
const { pool } = this
|
||||||
name_label,
|
|
||||||
name_description
|
const promises = [
|
||||||
})
|
this._setObjectProperties(pool, {
|
||||||
|
nameLabel,
|
||||||
|
nameDescription
|
||||||
|
})
|
||||||
|
]
|
||||||
|
|
||||||
|
// TODO: mutualize this code.
|
||||||
|
if (autoPowerOn != null) {
|
||||||
|
let p = this.call('pool.remove_from_other_config', pool.$ref, 'auto_poweron')
|
||||||
|
|
||||||
|
if (autoPowerOn) {
|
||||||
|
p = p
|
||||||
|
.catch(noop)
|
||||||
|
.then(() => this.call('pool.add_to_other_config', pool.$ref, 'auto_poweron', 'true'))
|
||||||
|
}
|
||||||
|
|
||||||
|
promises.push(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSrProperties (id, {
|
async setSrProperties (id, {
|
||||||
name_label,
|
nameLabel,
|
||||||
name_description
|
nameDescription
|
||||||
}) {
|
}) {
|
||||||
await this._setObjectProperties(this.getObject(id), {
|
await this._setObjectProperties(this.getObject(id), {
|
||||||
name_label,
|
nameLabel,
|
||||||
name_description
|
nameDescription
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user