netbox-agent icon indicating copy to clipboard operation
netbox-agent copied to clipboard

AttributeError: 'NoneType' object has no attribute 'mode'

Open KivraChristoffer opened this issue 2 years ago • 5 comments

When running: python3 -m netbox_agent.cli --hostname_cmd "hostname -f" -c ../netbox_agent.yml -u --preserve-tags

i get 443 "GET /api/dcim/interfaces/?id=929&limit=0 HTTP/1.1" 200 52 Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/opt/netbox-agent/netbox_agent/cli.py", line 54, in <module> main() File "/opt/netbox-agent/netbox_agent/cli.py", line 50, in main return run(config) File "/opt/netbox-agent/netbox_agent/cli.py", line 43, in run server.netbox_create_or_update(config) File "/opt/netbox-agent/netbox_agent/virtualmachine.py", line 108, in netbox_create_or_update self.network.create_or_update_netbox_network_cards() File "/opt/netbox-agent/netbox_agent/network.py", line 443, in create_or_update_netbox_network_cards ret, interface = self.reset_vlan_on_interface(nic, interface) File "/opt/netbox-agent/netbox_agent/network.py", line 222, in reset_vlan_on_interface (interface.mode is not None or len(interface.tagged_vlans) > 0): AttributeError: 'NoneType' object has no attribute 'mode'

KivraChristoffer avatar Apr 27 '22 12:04 KivraChristoffer

@cyrinux this is a old bug , line 217 replace with self.nb_net

KivraChristoffer avatar Jun 02 '22 14:06 KivraChristoffer

@KivraChristoffer Replace what to what? please give me the correct line here.

devopstales avatar Jun 24 '22 07:06 devopstales

@devopstales network.py

215 # For strange reason, we need to get the object from scratch 216 # The object returned by pynetbox's save isn't always working (since pynetbox 6) 217 interface = nb.dcim.interfaces.get(id=interface.id) <---- interface = self.nb_net.interfaces.get(id=interface.id)

KivraChristoffer avatar Jun 24 '22 07:06 KivraChristoffer

this is still not merged to master :)

KivraChristoffer avatar Jul 21 '22 06:07 KivraChristoffer

addressed in #232

KivraChristoffer avatar Jul 21 '22 06:07 KivraChristoffer