Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(netbox): check Netbox version down to minor + allow to bypass check #7992

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -47,6 +48,7 @@
- xen-api patch
- xo-cli minor
- xo-server patch
- xo-server-netbox minor
- xo-web minor

<!--packages-end-->
13 changes: 12 additions & 1 deletion docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 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 <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
Expand Down Expand Up @@ -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`
)
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/xo-server/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ level = 'info'

[logs.transport.console]

[netbox]
checkNetboxVersion = true

[plugins]
lookupPaths = ['./node_modules', '../', '/usr/local/lib/node_modules']

Expand Down
Loading