forked from mirrors/thatmattlove-hyperglass
throw error if a query is received for a disabled afi
This commit is contained in:
parent
70de22ff95
commit
52d02640f5
1 changed files with 12 additions and 7 deletions
|
|
@ -76,13 +76,11 @@ def validate_ip(value, query_type, query_vrf): # noqa: C901
|
|||
query_type=query_type_params.display_name,
|
||||
)
|
||||
|
||||
"""
|
||||
Test the valid IP address to determine if it is:
|
||||
- Unspecified (See RFC5735, RFC2373)
|
||||
- Loopback (See RFC5735, RFC2373)
|
||||
- Otherwise IETF Reserved
|
||||
...and returns an error if so.
|
||||
"""
|
||||
# Test the valid IP address to determine if it is:
|
||||
# - Unspecified (See RFC5735, RFC2373)
|
||||
# - Loopback (See RFC5735, RFC2373)
|
||||
# - Otherwise IETF Reserved
|
||||
# ...and returns an error if so.
|
||||
if valid_ip.is_reserved or valid_ip.is_unspecified or valid_ip.is_loopback:
|
||||
raise InputInvalid(
|
||||
params.messages.invalid_input,
|
||||
|
|
@ -92,6 +90,13 @@ def validate_ip(value, query_type, query_vrf): # noqa: C901
|
|||
|
||||
ip_version = valid_ip.version
|
||||
|
||||
if getattr(query_vrf, f"ipv{ip_version}") is None:
|
||||
raise InputInvalid(
|
||||
params.messages.feature_not_enabled,
|
||||
feature=f"IPv{ip_version}",
|
||||
device_name=f"VRF {query_vrf.display_name}",
|
||||
)
|
||||
|
||||
vrf_acl = operator.attrgetter(f"ipv{ip_version}.access_list")(query_vrf)
|
||||
|
||||
for ace in [a for a in vrf_acl if a.network.version == ip_version]:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue