fix(xo-server/xapi-objects-to-xo/VM/addresses): handle old tools alias properties (#5860)
See https://xcp-ng.org/forum/topic/4810 See #5805
This commit is contained in:
parent
f2a860b01a
commit
a505cd9567
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
||||||
|
|
||||||
|
- [VM/network] Fix an issue where multiple IPs would be displayed in the same tag when using old Xen tools. This also fixes Netbox's IP synchronization for the affected VMs. (PR [#5860](https://github.com/vatesfr/xen-orchestra/pull/5860))
|
||||||
|
|
||||||
### Packages to release
|
### Packages to release
|
||||||
|
|
||||||
> Packages will be released in the order they are here, therefore, they should
|
> Packages will be released in the order they are here, therefore, they should
|
||||||
@ -27,3 +29,5 @@
|
|||||||
> - major: if the change breaks compatibility
|
> - major: if the change breaks compatibility
|
||||||
>
|
>
|
||||||
> In case of conflict, the highest (lowest in previous list) `$version` wins.
|
> In case of conflict, the highest (lowest in previous list) `$version` wins.
|
||||||
|
|
||||||
|
- xo-server patch
|
||||||
|
@ -326,18 +326,33 @@ const TRANSFORMS = {
|
|||||||
|
|
||||||
// Merge old ipv4 protocol with the new protocol
|
// Merge old ipv4 protocol with the new protocol
|
||||||
// See: https://github.com/xapi-project/xen-api/blob/324bc6ee6664dd915c0bbe57185f1d6243d9ed7e/ocaml/xapi/xapi_guest_agent.ml#L59-L81
|
// See: https://github.com/xapi-project/xen-api/blob/324bc6ee6664dd915c0bbe57185f1d6243d9ed7e/ocaml/xapi/xapi_guest_agent.ml#L59-L81
|
||||||
|
|
||||||
|
// Old protocol: when there's more than 1 IP on an interface, the IPs
|
||||||
|
// are space-delimited in the same `x/ip` field
|
||||||
|
// See https://github.com/vatesfr/xen-orchestra/issues/5801#issuecomment-854337568
|
||||||
|
|
||||||
|
// The `x/ip` field may have a `x/ipv4/0` alias
|
||||||
|
// e.g:
|
||||||
|
// {
|
||||||
|
// '1/ip': '<IP1> <IP2>',
|
||||||
|
// '1/ipv4/0': '<IP1> <IP2>',
|
||||||
|
// }
|
||||||
|
// See https://xcp-ng.org/forum/topic/4810
|
||||||
const addresses = {}
|
const addresses = {}
|
||||||
for (const key in networks) {
|
for (const key in networks) {
|
||||||
const [, device] = /^(\d+)\/ip$/.exec(key) ?? []
|
const [, device, index] = /^(\d+)\/ip(?:v[46]\/(\d))?$/.exec(key) ?? []
|
||||||
if (device !== undefined) {
|
const ips = networks[key].split(' ')
|
||||||
// Old protocol: when there's more than 1 IP on an interface, the IPs
|
if (ips.length === 1 && index !== undefined) {
|
||||||
// are space-delimited in the same field
|
// New protocol or alias
|
||||||
// See https://github.com/vatesfr/xen-orchestra/issues/5801#issuecomment-854337568
|
addresses[key] = networks[key]
|
||||||
networks[key].split(' ').forEach((ip, i) => {
|
} else if (index !== '0' && index !== undefined) {
|
||||||
|
// Should never happen (alias with index >0)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
// Old protocol
|
||||||
|
ips.forEach((ip, i) => {
|
||||||
addresses[`${device}/ipv4/${i}`] = ip
|
addresses[`${device}/ipv4/${i}`] = ip
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
addresses[key] = networks[key]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user