feat(pif): editVlan (#426)

Fix vatesfr/xo-web#1092
This commit is contained in:
Pierre Donias 2016-10-24 10:24:44 +02:00 committed by Julien Fontanet
parent 4f763e2109
commit 7bed200bf5
2 changed files with 38 additions and 0 deletions

View File

@ -76,3 +76,18 @@ reconfigureIp.params = {
reconfigureIp.resolve = { reconfigureIp.resolve = {
pif: ['id', 'PIF', 'administrate'] pif: ['id', 'PIF', 'administrate']
} }
// ===================================================================
export async function editPif ({ pif, vlan }) {
await this.getXapi(pif).editPif(pif._xapiId, { vlan })
}
editPif.params = {
id: { type: 'string' },
vlan: { type: ['integer', 'string'] }
}
editPif.resolve = {
pif: ['id', 'PIF', 'administrate']
}

View File

@ -1874,6 +1874,29 @@ export default class Xapi extends XapiBase {
return this._getOrWaitObject(networkRef) return this._getOrWaitObject(networkRef)
} }
async editPif (
pifId,
{ vlan }
) {
const pif = this.getObject(pifId)
const physPif = find(this.objects.all, obj => (
obj.$type === 'pif' &&
(obj.physical || obj.bond_master_of) &&
obj.$pool === pif.$pool &&
obj.device === pif.device
))
if (!physPif) {
throw new Error('PIF not found')
}
await this.call('VLAN.destroy', pif.VLAN_master_of)
const pifs = await this.call('pool.create_VLAN_from_PIF', physPif.$ref, pif.network, asInteger(vlan))
if (!pif.currently_attached) {
forEach(pifs, pifRef => this.call('PIF.unplug', pifRef)::pCatch(noop))
}
}
async createBondedNetwork ({ async createBondedNetwork ({
bondMode, bondMode,
mac, mac,