Skip to content

Commit

Permalink
fix(xo-server-netbox): fix site property null/undefined cases (#7145)
Browse files Browse the repository at this point in the history
Introduced by 1d7559d
  • Loading branch information
pdonias committed Oct 31, 2023
1 parent ae0f3b4 commit a3ea70c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

> 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))

### Packages to release

> When modifying a package, add it here with its release type.
Expand All @@ -27,4 +29,6 @@
<!--packages-start-->

- xo-server-netbox patch

<!--packages-end-->
4 changes: 3 additions & 1 deletion packages/xo-server-netbox/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ class Netbox {
cluster: nbVm.cluster?.id ?? null,
status: nbVm.status?.value ?? null,
platform: nbVm.platform?.id ?? null,
site: nbVm.site?.id,
// If site is not supported by Netbox, its value is undefined
// If site is supported by Netbox but empty, its value is null
site: nbVm.site == null ? nbVm.site : nbVm.site.id,
// Sort them so that they can be compared by diff()
tags: nbVm.tags.map(nbTag => ({ id: nbTag.id })).sort(({ id: id1 }, { id: id2 }) => (id1 < id2 ? -1 : 1)),
})
Expand Down

0 comments on commit a3ea70c

Please sign in to comment.