Xapi#setPoolProperties() supports autoPowerOn.

This commit is contained in:
Julien Fontanet 2015-11-25 11:03:33 +01:00
parent 90f79b7708
commit 5cd3e1b368
4 changed files with 64 additions and 25 deletions

View File

@ -14,10 +14,17 @@ startsWith = require 'lodash.startswith'
#=====================================================================
set = (params) ->
host = extractProperty(params, 'host')
set = ({
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'

View File

@ -1,12 +1,18 @@
import {JsonRpcError} from '../api-errors'
import {extractProperty} from '../utils'
// ===================================================================
export async function set (params) {
const pool = extractProperty(params, 'pool')
export async function set ({
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 = {

View File

@ -1,16 +1,22 @@
import {
ensureArray,
extractProperty,
forEach,
parseXml
} from '../utils'
// ===================================================================
export async function set (params) {
const sr = extractProperty(params, 'sr')
export async function set ({
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 = {

View File

@ -234,32 +234,52 @@ export default class Xapi extends XapiBase {
}
async setHostProperties (id, {
name_label,
name_description
nameLabel,
nameDescription
}) {
await this._setObjectProperties(this.getObject(id), {
name_label,
name_description
nameLabel,
nameDescription
})
}
async setPoolProperties ({
name_label,
name_description
autoPowerOn,
nameLabel,
nameDescription
}) {
await this._setObjectProperties(this.pool, {
name_label,
name_description
})
const { pool } = this
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, {
name_label,
name_description
nameLabel,
nameDescription
}) {
await this._setObjectProperties(this.getObject(id), {
name_label,
name_description
nameLabel,
nameDescription
})
}