From ae3405541593bfb98ac5e32de6cccdf59d7ddcc4 Mon Sep 17 00:00:00 2001 From: Pierre Donias Date: Mon, 9 Sep 2024 11:22:13 +0200 Subject: [PATCH 1/2] feat(netbox): check Netbox version down to minor + allow to bypass check --- docs/advanced.md | 13 ++++++++++++- packages/xo-server-netbox/src/index.js | 8 ++++++-- packages/xo-server/config.toml | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/advanced.md b/docs/advanced.md index 801d5f4efcf..152cc946e55 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -347,7 +347,18 @@ Synchronize your pools, VMs, network interfaces and IP addresses with your [Netb - `>= 2.10` - `3.x` -- `4.x` +- `4.0` + +:::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: + +```toml +[netbox] +checkNetboxVersion = false +``` + +Please be aware that by doing this, a Netbox update might make XO delete some of your data in Netbox. +::: ### Netbox side diff --git a/packages/xo-server-netbox/src/index.js b/packages/xo-server-netbox/src/index.js index c61f8f0b320..b0b5113dd7f 100644 --- a/packages/xo-server-netbox/src/index.js +++ b/packages/xo-server-netbox/src/index.js @@ -16,7 +16,7 @@ import slugify from './slugify' const log = createLogger('xo:netbox') -const SUPPORTED_VERSION = '>=2.10 <5.0' +const SUPPORTED_VERSION = '>=2.10 <4.1' const CLUSTER_TYPE = 'XCP-ng Pool' const TYPES_WITH_UUID = ['virtualization.cluster', 'virtualization.virtualmachine', 'virtualization.vminterface'] const CHUNK_SIZE = 100 @@ -235,10 +235,14 @@ class Netbox { } async #checkNetboxVersion() { + if (!this.#xo.config.getOptional('netbox.checkNetboxVersion')) { + return + } + await this.#fetchNetboxVersion() if (this.#netboxVersion === undefined || !semver.satisfies(this.#netboxVersion, SUPPORTED_VERSION)) { throw new Error( - `Netbox version ${this.#netboxVersion ?? '<2.10'} not supported. Please check https://xen-orchestra.com/docs/advanced.html#netbox` + `Netbox version ${this.#netboxVersion ?? '<2.10'} not supported. Please check https://xen-orchestra.com/docs/advanced.html#supported-versions` ) } } diff --git a/packages/xo-server/config.toml b/packages/xo-server/config.toml index 3f85bdd5e47..26a0823c866 100644 --- a/packages/xo-server/config.toml +++ b/packages/xo-server/config.toml @@ -160,6 +160,9 @@ level = 'info' [logs.transport.console] +[netbox] +checkNetboxVersion = true + [plugins] lookupPaths = ['./node_modules', '../', '/usr/local/lib/node_modules'] From 7f394513c0069e1fe91a13f12d113d81a8441f8d Mon Sep 17 00:00:00 2001 From: Pierre Donias Date: Fri, 20 Sep 2024 10:27:43 +0200 Subject: [PATCH 2/2] Changelog --- CHANGELOG.unreleased.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 0c54d57254c..9c7a86bb2e5 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -12,6 +12,7 @@ > Users must be able to say: “Nice enhancement, I'm eager to test it” - [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)) - **XO 6**: - [Dashboard] Display backup issues data (PR [#7974](https://github.com/vatesfr/xen-orchestra/pull/7974)) @@ -41,6 +42,7 @@ - @xen-orchestra/lite minor - @xen-orchestra/web minor - @xen-orchestra/web-core minor +- xo-server-netbox minor - xo-web minor