Solvik / netbox-agent

Netbox agent to run on your infrastructure's servers
Apache License 2.0
287 stars 74 forks source link

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

Closed KivraChristoffer closed 1 year ago

KivraChristoffer commented 2 years ago

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 commented 2 years ago

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

devopstales commented 2 years ago

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

KivraChristoffer commented 2 years ago

@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 commented 2 years ago

this is still not merged to master :)

KivraChristoffer commented 2 years ago

addressed in #232