From 089f893b7ce3ca44fbf712dd1da787cf9618f1da Mon Sep 17 00:00:00 2001 From: Solvik Blum Date: Fri, 18 Aug 2023 17:08:42 +0200 Subject: [PATCH] update cable management compatibility for netbox >3.3 and pynetbox v7 --- netbox_agent/network.py | 19 +++++++++++++------ requirements.txt | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/netbox_agent/network.py b/netbox_agent/network.py index 673dfc1..4d0c8d3 100644 --- a/netbox_agent/network.py +++ b/netbox_agent/network.py @@ -556,12 +556,19 @@ 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_id': nb_server_interface.id, + 'object_type':'dcim.interface' + } + ], + b_terminations=[ + { + 'object_id': nb_switch_interface.id, + 'object_type': 'dcim.interface' + } + ], ) - nb_server_interface.cable = cable logging.info( 'Connected interface {interface} with {switch_interface} of {switch_ip}'.format( interface=nb_server_interface.name, @@ -579,7 +586,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/requirements.txt b/requirements.txt index c4a84a2..f9cf5a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pynetbox==6.1.2 +pynetbox==7.0.1 netaddr==0.8.0 netifaces==0.10.9 pyyaml==6.0.1