diff --git a/.gitignore b/.gitignore index a95d78e..bc7b989 100644 --- a/.gitignore +++ b/.gitignore @@ -181,3 +181,4 @@ dmypy.json # End of https://www.gitignore.io/api/emacs,python netbox-docker +/.vscode diff --git a/README.md b/README.md index 30b8240..d9414bf 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ The goal is to generate an existing infrastructure on Netbox and have the abilit # Requirements -- Netbox >= 2.6 -- Python >= 3.4 +- Netbox >= 3.7 +- Python >= 3.7 - [pynetbox](https://github.com/digitalocean/pynetbox/) - [python3-netaddr](https://github.com/drkjam/netaddr) - [python3-netifaces](https://github.com/al45tair/netifaces) diff --git a/netbox_agent/cli.py b/netbox_agent/cli.py index e112469..2d1de19 100644 --- a/netbox_agent/cli.py +++ b/netbox_agent/cli.py @@ -34,8 +34,8 @@ def run(config): except KeyError: server = GenericHost(dmi=dmi) - if version.parse(nb.version) < version.parse('2.9'): - print('netbox-agent is not compatible with Netbox prior to verison 2.9') + if version.parse(nb.version) < version.parse('3.7'): + print('netbox-agent is not compatible with Netbox prior to version 3.7') return False if config.register or config.update_all or config.update_network or \ diff --git a/netbox_agent/network.py b/netbox_agent/network.py index 673dfc1..41db084 100644 --- a/netbox_agent/network.py +++ b/netbox_agent/network.py @@ -544,7 +544,7 @@ class ServerNetwork(Network): switch_interface = self.lldp.get_switch_port(nb_server_interface.name) nb_switch_interface = nb.dcim.interfaces.get( - device=nb_switch, + device_id=nb_switch.id, name=switch_interface, ) if nb_switch_interface is None: @@ -556,10 +556,12 @@ class ServerNetwork(Network): switch_ip, )) cable = nb.dcim.cables.create( - termination_a_id=nb_server_interface.id, - termination_a_type="dcim.interface", - termination_b_id=nb_switch_interface.id, - termination_b_type="dcim.interface", + a_terminations=[ + {"object_type": "dcim.interface", "object_id": nb_server_interface.id}, + ], + b_terminations=[ + {"object_type": "dcim.interface", "object_id": nb_switch_interface.id}, + ], ) nb_server_interface.cable = cable logging.info( @@ -579,7 +581,7 @@ class ServerNetwork(Network): switch_ip, switch_interface, nb_server_interface ) else: - nb_sw_int = nb_server_interface.cable.termination_b + nb_sw_int = nb_server_interface.cable.b_terminations[0] nb_sw = nb_sw_int.device nb_mgmt_int = nb.dcim.interfaces.get( device_id=nb_sw.id, diff --git a/netbox_agent/server.py b/netbox_agent/server.py index c755a71..5077b7f 100644 --- a/netbox_agent/server.py +++ b/netbox_agent/server.py @@ -199,7 +199,7 @@ class ServerBase(): name=self.get_chassis_name(), device_type=device_type.id, serial=serial, - device_role=device_role.id, + role=device_role.id, site=datacenter.id if datacenter else None, tenant=tenant.id if tenant else None, rack=rack.id if rack else None, @@ -220,7 +220,7 @@ class ServerBase(): new_blade = nb.dcim.devices.create( name=hostname, serial=serial, - device_role=device_role.id, + role=device_role.id, device_type=device_type.id, parent_device=chassis.id, site=datacenter.id if datacenter else None, @@ -243,7 +243,7 @@ class ServerBase(): new_blade = nb.dcim.devices.create( name=hostname, serial=serial, - device_role=device_role.id, + role=device_role.id, device_type=device_type.id, parent_device=chassis.id, site=datacenter.id if datacenter else None, @@ -272,7 +272,7 @@ class ServerBase(): new_server = nb.dcim.devices.create( name=hostname, serial=serial, - device_role=device_role.id, + role=device_role.id, device_type=device_type.id, platform=self.device_platform.id, site=datacenter.id if datacenter else None, diff --git a/requirements.txt b/requirements.txt index 10909f7..1d5cb4d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -pynetbox==6.1.2 -netaddr==0.8.0 +pynetbox==7.3.4 +netaddr==1.3.0 netifaces==0.11.0 pyyaml==6.0.1 -jsonargparse==3.11.2 -python-slugify==8.0.1 -packaging==23.1 -distro==1.8.0 +jsonargparse==4.32.0 +python-slugify==8.0.4 +packaging==23.2 +distro==1.9.0