Skip to content
Snippets Groups Projects
Commit ba96a952 authored by BENOIT JEAN's avatar BENOIT JEAN
Browse files

Improve error messages

parent 1bf803b4
Branches master
No related merge requests found
......@@ -131,11 +131,13 @@ class NameZoneValidator(CustomValidator):
# This check is necessary because of the prefix-DNS view relation of dns_sync
if not ipaddress_in_existing_prefix(ipaddress, request):
self.fail(f"IP address '{ipaddress}' is not in any existing prefix", field="address")
self.fail(f"Prefix for '{ipaddress}' not found in VRF '{ipaddress.vrf}'", field="address")
if not prefix_has_dns_view(ipaddress, request):
self.fail(f"IP address '{ipaddress}' is in a prefix for which there is no DNS view defined. Ask your NetBox administrator", field="address")
self.fail(f"Prefix for '{ipaddress}' has no DNS view defined. Ask your NetBox administrator", field="address")
if not name_has_valid_zone(dns_name, ipaddress, request):
self.fail(f"Name '{dns_name}' is in an non-existing zone name", field="dns_name")
words = dns_name.split(".")
supposed_zone = '.'.join(words[1:])
self.fail(f"Zone does not exist. Is '{supposed_zone}' correct?", field="dns_name")
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment