Compare commits

...

6 commits
0.2.0 ... main

Author SHA1 Message Date
1a0107381b Update run instructions
All checks were successful
CI / ci (push) Successful in 39s
2025-06-03 16:36:12 +02:00
e0a94e68d9 Release 0.2.2
All checks were successful
CD / ci (push) Successful in 59s
CI / ci (push) Successful in 51s
2025-05-07 09:10:07 +02:00
c0d2c62bbb Use NB_CLUSTER_ID even for VM update
All checks were successful
CI / ci (push) Successful in 49s
2025-05-02 08:20:54 +02:00
e0c732043c Documentation updated to mention NB_CLUSTER_ID
All checks were successful
CI / ci (push) Successful in 46s
2025-05-01 09:16:44 +02:00
e7d5f5dd26 Release 0.2.1
All checks were successful
CD / ci (push) Successful in 1m32s
CI / ci (push) Successful in 1m24s
2025-05-01 08:50:40 +02:00
c892d596f4 [#7] Improve tag handling
All checks were successful
CI / ci (push) Successful in 1m16s
Closes: #7
2025-05-01 08:49:38 +02:00
4 changed files with 22 additions and 5 deletions

View file

@ -2,6 +2,18 @@
## [Unreleased]
## [0.2.2] - 07/05/2025
### Fixed
- Use `NB_CLUSTER_ID` even for VM update.
## [0.2.1] - 01/05/2025
### Fixed
- [#7] Improve tag handling.
## [0.2.0] - 21/04/2025
### New

View file

@ -27,6 +27,9 @@ The following env variables will need to be set:
- **NB_API_URL**: The URL to your NetBox instance. (ex: https://netbox.example.org)
- **NB_API_TOKEN**: The token created previously. (ex: f74cb99cf552b7005fd1a616b53efba2ce0c9656)
You can also set the `NB_CLUSTER_ID` env variable in order to indicate the ID of the cluster that will be used in
NetBox.
You'll also need to perform a minimal configuration on NetBox:
- Create the physical nodes hosting the cluster. (The name should match the one on Proxmox, so that the script can
@ -60,5 +63,5 @@ The following env variables will need to be set:
You can then execute the script using the following command:
```
PVE_API_HOST=xx PVE_API_USER=xx PVE_API_TOKEN=xx PVE_API_SECRET=xx NB_API_URL=xx NB_API_TOKEN=xx python3 -m netbox_pve_sync
```
PVE_API_HOST=xx PVE_API_USER=xx PVE_API_TOKEN=xx PVE_API_SECRET=xx NB_API_URL=xx NB_API_TOKEN=xx nbpxsync
```

View file

@ -88,6 +88,7 @@ def _process_pve_tags(
slug=f'pool-{_pve_pool["poolid"]}'.lower(),
description=f'Proxmox pool {_pve_pool["poolid"]}',
)
_nb_objects['tags'][_nb_tag.name] = _nb_tag
return _nb_objects
@ -142,7 +143,7 @@ def _process_pve_virtual_machine(
else:
nb_virtual_machine.name = _pve_virtual_machine['name']
nb_virtual_machine.site = _nb_device.site.id
nb_virtual_machine.cluster = 1
nb_virtual_machine.cluster = os.environ.get('NB_CLUSTER_ID', 1)
nb_virtual_machine.device = _nb_device.id
nb_virtual_machine.vcpus = pve_virtual_machine_config['cores']
nb_virtual_machine.memory = int(pve_virtual_machine_config['memory'])
@ -433,7 +434,8 @@ def main():
for pve_vm_resource in pve_api.cluster.resources.get(type='vm'):
pve_vm_tags[pve_vm_resource['vmid']] = []
pve_vm_tags[pve_vm_resource['vmid']].append(f'Pool/{pve_vm_resource["pool"]}')
if 'pool' in pve_vm_resource:
pve_vm_tags[pve_vm_resource['vmid']].append(f'Pool/{pve_vm_resource["pool"]}')
if 'tags' in pve_vm_resource:
pass # TODO: pve_vm_tags[pve_vm_resource['vmid']].append(pve_vm_resource['tags'])

View file

@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "netbox-pve-sync"
version = "0.2.0"
version = "0.2.2"
authors = [
{ name = "Aloïs Micard", email = "alois@micard.lu" },
]