-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v3.1.4
Python version
3.8
Steps to Reproduce
- Go to IPAM > FHRP Group > +
- Protocol: Other
- Group ID: 1
- Address: 1.2.3.4/24
- Status: Active
- Create
Expected Behavior
A new FHRP group to be created, together with a new IP address assigned to it.
Observed Behavior
Server Error
There was a problem with your request. Please contact an administrator.
The complete exception is provided below:
<class 'KeyError'>
'other'
Python version: 3.8.10
NetBox version: 3.1.4
If further assistance is required, please post to the NetBox discussion forum on GitHub.
Backtrace:
Traceback (most recent call last):
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/netbox/netbox/netbox/views/generic.py", line 321, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/opt/netbox/netbox/netbox/views/generic.py", line 353, in post
obj = form.save()
File "/opt/netbox/netbox/ipam/forms/models.py", line 583, in save
role=FHRP_PROTOCOL_ROLE_MAPPINGS[self.cleaned_data['protocol']],
Exception Type: KeyError at /ipam/fhrp-groups/add/
Exception Value: 'other'
It appears that it's trying to map the FHRP type to an IP Address role in FHRP_PROTOCOL_ROLE_MAPPINGS, but is missing a choice for "other". I think ROLE_VIP is the most appropriate choice, although None would be OK.
This could be done either by adding a new entry to FHRP_PROTOCOL_ROLE_MAPPINGS:
--- a/netbox/ipam/constants.py
+++ b/netbox/ipam/constants.py
@@ -65,6 +65,7 @@ FHRP_PROTOCOL_ROLE_MAPPINGS = {
FHRPGroupProtocolChoices.PROTOCOL_HSRP: IPAddressRoleChoices.ROLE_HSRP,
FHRPGroupProtocolChoices.PROTOCOL_GLBP: IPAddressRoleChoices.ROLE_GLBP,
FHRPGroupProtocolChoices.PROTOCOL_CARP: IPAddressRoleChoices.ROLE_CARP,
+ FHRPGroupProtocolChoices.PROTOCOL_OTHER: IPAddressRoleChoices.ROLE_VIP,
}
or by having a default:
role=FHRP_PROTOCOL_ROLE_MAPPINGS.get(self.cleaned_data['protocol'], IPAddressRoleChoices.ROLE_VIP),
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application