diff --git a/README.md b/README.md index fa84074..f8cd7d7 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ usage: netbox-sync.py [-h] [-c settings.ini [settings.ini ...]] [-g] Sync objects from various sources to NetBox -Version: 1.5.0 (2023-07-07) +Version: 1.5.1 (2023-09-25) Project URL: https://github.com/bb-ricardo/netbox-sync options: diff --git a/module/__init__.py b/module/__init__.py index d802cb5..2e01498 100644 --- a/module/__init__.py +++ b/module/__init__.py @@ -7,8 +7,8 @@ # For a copy, see file LICENSE.txt included in this # repository or visit: . -__version__ = "1.5.0" -__version_date__ = "2023-07-07" +__version__ = "1.5.1" +__version_date__ = "2023-09-25" __author__ = "Ricardo Bartels " __description__ = "NetBox Sync" __license__ = "MIT" diff --git a/module/netbox/object_classes.py b/module/netbox/object_classes.py index b296d5c..1e1c6e1 100644 --- a/module/netbox/object_classes.py +++ b/module/netbox/object_classes.py @@ -10,6 +10,9 @@ import json from ipaddress import ip_network, IPv4Network, IPv6Network +# noinspection PyUnresolvedReferences +from packaging import version + from module.common.misc import grab, do_error_exit from module.common.logging import get_logger from module.netbox.manufacturer_mapping import sanitize_manufacturer_name @@ -1513,6 +1516,7 @@ class NBDevice(NetBoxObject): "name": 64, "device_type": NBDeviceType, "device_role": NBDeviceRole, + "role": NBDeviceRole, "platform": NBPlatform, "serial": 50, "site": NBSite, @@ -1527,6 +1531,16 @@ class NBDevice(NetBoxObject): } super().__init__(*args, **kwargs) + def update(self, data=None, read_from_netbox=False, source=None): + + # Add adaption for change in NetBox 3.6.0 Device model + if version.parse(self.inventory.netbox_api_version) >= version.parse("3.6.0"): + if data.get("device_role") is not None: + data["role"] = data.get("device_role") + del data["device_role"] + + super().update(data=data, read_from_netbox=read_from_netbox, source=source) + class NBVM(NetBoxObject): name = "virtual machine" diff --git a/settings-example.ini b/settings-example.ini index c3498a3..d00fb4f 100644 --- a/settings-example.ini +++ b/settings-example.ini @@ -1,5 +1,5 @@ ;;; Welcome to the NetBox Sync configuration file. -;;; Version: 1.5.0 (2023-07-07) +;;; Version: 1.5.1 (2023-09-25) ;;; Project URL: https://github.com/bb-ricardo/netbox-sync ; The values in this file override the default values used by the system if a config