Fix KeyError: 'pvid' in lldp.py
```
lldp.eth0.vlan.vlan-id=300
lldp.eth0.vlan.pvid=yes
lldp.eth0.vlan=VLAN300
```
```
Version: lldpd 1.0.11
```
```
{'300': {'pvid': True}, 'VLAN300': {}}
Traceback (most recent call last):
File "/root/.local/bin/netbox_agent", line 8, in <module>
sys.exit(main())
File "/root/.local/lib/python3.10/site-packages/netbox_agent/cli.py", line 44, in main
return run(config)
File "/root/.local/lib/python3.10/site-packages/netbox_agent/cli.py", line 39, in run
server.netbox_create_or_update(config)
File "/root/.local/lib/python3.10/site-packages/netbox_agent/server.py", line 292, in netbox_create_or_update
self.network.create_or_update_netbox_network_cards()
File "/root/.local/lib/python3.10/site-packages/netbox_agent/network.py", line 417, in create_or_update_netbox_network_cards
ret, interface = self.reset_vlan_on_interface(nic, interface)
File "/root/.local/lib/python3.10/site-packages/netbox_agent/network.py", line 234, in reset_vlan_on_interface
pvid_vlan = [key for (key, value) in lldp_vlan.items() if value['pvid']]
File "/root/.local/lib/python3.10/site-packages/netbox_agent/network.py", line 234, in <listcomp>
pvid_vlan = [key for (key, value) in lldp_vlan.items() if value['pvid']]
KeyError: 'pvid'
```
This commit is contained in:
parent
6181800cb3
commit
a59fb446f3
1 changed files with 1 additions and 1 deletions
|
|
@ -37,7 +37,7 @@ class LLDP():
|
||||||
vid = value
|
vid = value
|
||||||
vlans[interface][value] = vlans[interface].get(vid, {})
|
vlans[interface][value] = vlans[interface].get(vid, {})
|
||||||
elif path.endswith('vlan'):
|
elif path.endswith('vlan'):
|
||||||
vid = value.replace('vlan-', '')
|
vid = value.replace('vlan-', '').replace('VLAN', '')
|
||||||
vlans[interface][vid] = vlans[interface].get(vid, {})
|
vlans[interface][vid] = vlans[interface].get(vid, {})
|
||||||
elif 'pvid' in path:
|
elif 'pvid' in path:
|
||||||
vlans[interface][vid]['pvid'] = True
|
vlans[interface][vid]['pvid'] = True
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue