fix(xo-server/network): create bond for each host (#4756)

Fixes #4529
This commit is contained in:
badrAZ
2020-01-31 11:00:12 +01:00
committed by GitHub
parent cca43040d3
commit a947c3152a
3 changed files with 19 additions and 13 deletions

View File

@@ -20,6 +20,8 @@
> Users must be able to say: “I had this issue, happy to know it's fixed”
- [New network] Fix bonded network not linked to the slave hosts [#4529](https://github.com/vatesfr/xen-orchestra/issues/4529) (PR [#4756](https://github.com/vatesfr/xen-orchestra/pull/4756))
### Released packages
> Packages will be released in the order they are here, therefore, they should

View File

@@ -46,7 +46,6 @@ export async function createBonded({
description,
pifs,
mtu = 1500,
mac,
bondMode,
}) {
return this.getXapi(pool).createBondedNetwork({
@@ -54,7 +53,6 @@ export async function createBonded({
description,
pifIds: mapToArray(pifs, pif => this.getObject(pif, 'PIF')._xapiId),
mtu: +mtu,
mac,
bondMode,
})
}
@@ -70,7 +68,6 @@ createBonded.params = {
},
},
mtu: { type: ['integer', 'string'], optional: true },
mac: { type: 'string', optional: true },
// RegExp since schema-inspector does not provide a param check based on an enumeration
bondMode: {
type: 'string',

View File

@@ -2139,18 +2139,25 @@ export default class Xapi extends XapiBase {
}
@deferrable
async createBondedNetwork($defer, { bondMode, mac = '', pifIds, ...params }) {
async createBondedNetwork(
$defer,
{ bondMode, pifIds: masterPifIds, ...params }
) {
const network = await this.createNetwork(params)
$defer.onFailure(() => this.deleteNetwork(network))
// TODO: test and confirm:
// Bond.create is called here with PIFs from one host but XAPI should then replicate the
// bond on each host in the same pool with the corresponding PIFs (ie same interface names?).
await this.call(
'Bond.create',
network.$ref,
map(pifIds, pifId => this.getObject(pifId).$ref),
mac,
bondMode
const pifsByHost = {}
masterPifIds.forEach(pifId => {
this.getObject(pifId).$network.$PIFs.forEach(pif => {
if (pifsByHost[pif.host] === undefined) {
pifsByHost[pif.host] = []
}
pifsByHost[pif.host].push(pif.$ref)
})
})
await asyncMap(pifsByHost, pifs =>
this.call('Bond.create', network.$ref, pifs, '', bondMode)
)
return network