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

Closed
opened 2022-04-27 14:35:48 +02:00 by KivraChristoffer · 5 comments
KivraChristoffer commented 2022-04-27 14:35:48 +02:00 (Migrated from github.com)

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'

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 2022-06-02 16:04:26 +02:00 (Migrated from github.com)

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

@cyrinux this is a old bug , line 217 replace with self.nb_net
devopstales commented 2022-06-24 09:09:12 +02:00 (Migrated from github.com)

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

@KivraChristoffer Replace what to what? please give me the correct line here.
KivraChristoffer commented 2022-06-24 09:15:52 +02:00 (Migrated from github.com)

@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)

@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 2022-07-21 08:26:55 +02:00 (Migrated from github.com)

this is still not merged to master :)

this is still not merged to master :)
KivraChristoffer commented 2022-07-21 08:35:33 +02:00 (Migrated from github.com)

addressed in #232

addressed in #232
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: DGNum/netbox-agent#226
No description provided.