fix(xo-server-netbox): properly delete all interfaces that don't have a UUID (#7153)
Fixes zammad#18812
Introduced by 3b1bcc67ae
The first step of synchronizing VIFs with Netbox interfaces is to clean up any interface attached to the Netbox VM that isn't found on the XO VM, *based on their UUID*, including the interfaces that don't have a UUID at all (`uuid` is `null`).
But by looping over the keyed-by-UUID collection, we could only ever delete at most *one* null-UUID interface, the other ones being dropped by `keyBy`.
Using the flat-array collection instead makes sure all the interfaces are handled.
This commit is contained in:
parent
db99a22244
commit
457fec0bc8
@ -12,6 +12,7 @@
|
||||
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
||||
|
||||
- [Netbox] Fix VMs' `site` property being unnecessarily updated on some versions of Netbox (PR [#7145](https://github.com/vatesfr/xen-orchestra/pull/7145))
|
||||
- [Netbox] Fix "400 Bad Request" error (PR [#7153](https://github.com/vatesfr/xen-orchestra/pull/7153))
|
||||
|
||||
### Packages to release
|
||||
|
||||
|
@ -550,10 +550,12 @@ class Netbox {
|
||||
continue
|
||||
}
|
||||
// Start by deleting old interfaces attached to this Netbox VM
|
||||
Object.entries(nbIfs).forEach(([id, nbIf]) => {
|
||||
if (nbIf.virtual_machine.id === nbVm.id && !xoVm.VIFs.includes(nbIf.custom_fields.uuid)) {
|
||||
// Loop over the array to make sure interfaces with a `null` UUID also get deleted
|
||||
nbIfsList.forEach(nbIf => {
|
||||
const xoVifId = nbIf.custom_fields.uuid
|
||||
if (nbIf.virtual_machine.id === nbVm.id && !xoVm.VIFs.includes(xoVifId)) {
|
||||
ifsToDelete.push({ id: nbIf.id })
|
||||
delete nbIfs[id]
|
||||
delete nbIfs[xoVifId]
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user