Browse Source

Improve dns format validation

Currently, if variable dns-nameserver is a list which
contains extra spaces, e.g., '8.8.8.8, 8.8.4.4', then
validate_dns will fail and API will throw 400 Bad request.

This patch strips extra spaces before the dns format validation.

Change-Id: I8d7c94f42e9ea70009157c5de3dce75620ff5fe8
Story: 2006407
Task: 36291
changes/90/676690/2
Xingchao Yu 3 years ago
parent
commit
893e2cdf60
  1. 2
      magnum/common/utils.py

2
magnum/common/utils.py

@ -127,7 +127,7 @@ def validate_dns(dns_list):
dns_nameservers = dns_list.split(',')
try:
for dns in dns_nameservers:
netaddr.IPAddress(dns, version=4, flags=netaddr.INET_PTON)
netaddr.IPAddress(dns.strip(), version=4, flags=netaddr.INET_PTON)
except netaddr.AddrFormatError:
raise exception.InvalidDNS(dns=dns_list)
else:

Loading…
Cancel
Save