Fix KeyError: 'pvid' in lldp.py #223
			No reviewers
			
				
				
			
		
		
		
	
	
	
		Labels
		
	
	
	
	No labels
	
		
			
	
	help wanted
		
			need testing
		
			status: accepted
		
			status: discussing
		
			type: bug
		
			type: documentation
		
			type: duplicate
		
			type: enhancement
		
			type:hardware
		
			type: invalid
		
			type: major feature
		
			type: minor feature
		
		
			bug
		
			duplicate
		
			enhancement
		
			help wanted
		
			invalid
		
			question
		
			wontfix
		
	
		No milestone
		
			
		
	
	No project
	
		
	
	
	
	
		No assignees
		
	
	
		
			
		
	
	
	
		1 participant
	
	
		
		
	Notifications
	
		
	
	
	
		
	
	
	Due date
No due date set.
	
		Dependencies
		
		
	
	
	No dependencies set.
		Reference: DGNum/netbox-agent#223
		
	
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	
	No description provided.
		
		Delete branch "illes/patch-1"
	
	Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix KeyError: 'pvid' in lldp.py #223
vid = value.replace('vlan-', '').replace('VLAN', '')
It still gives an error
Traceback (most recent call last):
File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/netbox_agent/netbox_agent/cli.py", line 54, in
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/server.py", line 413, 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 248, in reset_vlan_on_interface
pvid_vlan = [key for (key, value) in lldp_vlan.items() if value['pvid']]
File "/opt/netbox_agent/netbox_agent/network.py", line 248, in
pvid_vlan = [key for (key, value) in lldp_vlan.items() if value['pvid']]
KeyError: 'pvid'
You are right that
KeyError: 'pvid'can still happen, though not with the minimal example I provided. To catch that case, I added an example and tests.@illes @rosberen sorry for the delay, is this PR ready for you ?
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.