Skip to content

Commit

Permalink
feat(netbox): support Netbox v4.1
Browse files Browse the repository at this point in the history
Fixes #7966

Storage size unit changed from GB to MB
  • Loading branch information
pdonias committed Sep 23, 2024
1 parent a297160 commit ca3ff31
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [SR/Disks] Display information if the VDI is an empty metadata snapshot (PR [#7970](https://github.com/vatesfr/xen-orchestra/pull/7970))
- [Netbox] Do not synchronize if detected minor version is not supported (PR [#7992](https://github.com/vatesfr/xen-orchestra/pull/7992))
- [Netbox] Support version 4.1
- **XO 6**:
- [Dashboard] Display backup issues data (PR [#7974](https://github.com/vatesfr/xen-orchestra/pull/7974))

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Synchronize your pools, VMs, network interfaces and IP addresses with your [Netb

- `>= 2.10`
- `3.x`
- `4.0`
- `4.0` - `4.1`

:::tip
For safety, XO will not synchronize your pools if it detects a Netbox version that is not supported. If you wish to change that behavior, edit you `xo-server` configuration like so:
Expand Down
5 changes: 3 additions & 2 deletions packages/xo-server-netbox/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import slugify from './slugify'

const log = createLogger('xo:netbox')

const SUPPORTED_VERSION = '>=2.10 <4.1'
const SUPPORTED_VERSION = '>=2.10 <4.2'
const CLUSTER_TYPE = 'XCP-ng Pool'
const TYPES_WITH_UUID = ['virtualization.cluster', 'virtualization.virtualmachine', 'virtualization.vminterface']
const CHUNK_SIZE = 100
Expand Down Expand Up @@ -466,7 +466,8 @@ class Netbox {
.map(vbdId => this.getObject(vbdId))
.filter(vbd => !vbd.is_cd_drive)
.map(vbd => this.getObject(vbd.VDI))
.reduce((total, vdi) => total + vdi.size, 0) / G
// Storage size unit changed from GB to MB in Netbox 4.1 (https://github.com/netbox-community/netbox/releases/tag/v4.1.0)
.reduce((total, vdi) => total + vdi.size, 0) / (semver.satisfies(this.#netboxVersion, '^4.1') ? M : G)
),
memory: Math.floor(xoVm.memory.dynamic[1] / M),
cluster: nbCluster.id,
Expand Down

0 comments on commit ca3ff31

Please sign in to comment.