fix(xo-server/xapi-object-to-xo): handle guest metrics reporting empty IP field (#6328)

See https://xcp-ng.org/forum/topic/4810/netbox-plugin-error-ipaddr-the-address-has-neither-ipv6-nor-ipv4-format/27?_=1658735770330
This commit is contained in:
Pierre Donias 2022-07-27 12:03:22 +02:00 committed by GitHub
parent d157fd3528
commit 433851d771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -16,6 +16,7 @@
- [Home/VM] Show error when deleting VMs failed (PR [#6323](https://github.com/vatesfr/xen-orchestra/pull/6323))
- [REST API] Fix broken VDI after VHD import [#6327](https://github.com/vatesfr/xen-orchestra/issues/6327) (PR [#6326](https://github.com/vatesfr/xen-orchestra/pull/6326))
- [Netbox] Fix `ipaddr: the address has neither IPv6 nor IPv4 format` error (PR [#6328](https://github.com/vatesfr/xen-orchestra/pull/6328))
### Packages to release

View File

@ -341,6 +341,11 @@ const TRANSFORMS = {
// See https://xcp-ng.org/forum/topic/4810
const addresses = {}
for (const key in networks) {
// Some fields may be emtpy
// See https://xcp-ng.org/forum/topic/4810/netbox-plugin-error-ipaddr-the-address-has-neither-ipv6-nor-ipv4-format/27?_=1658735770330
if (networks[key].trim() === '') {
continue
}
const [, device, index] = /^(\d+)\/ip(?:v[46]\/(\d))?$/.exec(key) ?? []
const ips = networks[key].split(/\s+/)
if (ips.length === 1 && index !== undefined) {