feat(sr): add disconnect and connect all PBDs to a SR (#324)

This commit is contained in:
Olivier Lambert 2016-05-27 18:31:09 +02:00 committed by Julien Fontanet
parent 4d0673f489
commit 9ce8a24eea
2 changed files with 46 additions and 0 deletions

View File

@ -76,6 +76,34 @@ forget.resolve = {
// -------------------------------------------------------------------
export async function connectAllPbds ({SR}) {
await this.getXapi(SR).connectAllSrPbds(SR._xapiId)
}
connectAllPbds.params = {
id: { type: 'string' }
}
connectAllPbds.resolve = {
SR: ['id', 'SR', 'administrate']
}
// -------------------------------------------------------------------
export async function disconnectAllPbds ({SR}) {
await this.getXapi(SR).disconnectAllSrPbds(SR._xapiId)
}
disconnectAllPbds.params = {
id: { type: 'string' }
}
disconnectAllPbds.resolve = {
SR: ['id', 'SR', 'administrate']
}
// -------------------------------------------------------------------
export async function createIso ({
host,
nameLabel,

View File

@ -3,6 +3,16 @@ import {
} from '../utils'
export default {
_connectAllSrPbds (sr) {
return Promise.all(
mapToArray(sr.$PBDs, pbd => this._plugPbd(pbd))
)
},
async connectAllSrPbds (id) {
await this._connectAllSrPbds(this.getObject(id))
},
_disconnectAllSrPbds (sr) {
return Promise.all(
mapToArray(sr.$PBDs, pbd => this._unplugPbd(pbd))
@ -25,6 +35,14 @@ export default {
await this.call('SR.forget', sr.$ref)
},
_plugPbd (pbd) {
return this.call('PBD.plug', pbd.$ref)
},
async plugPbd (id) {
await this._plugPbd(this.getObject(id))
},
_unplugPbd (pbd) {
return this.call('PBD.unplug', pbd.$ref)
},