The _validate* methods should return an error message and
not raise an exception.
Commit
2794bb89d664355ae1194a0b1f8346c1538caef8 raised an
exception instead of returning a message with the invalid data.
TrivialFix
Change-Id: Id3cc44a4ed248415f19c73beec2b24fd295110c8
def _validate_ip_address(data, valid_values=None):
+ msg = None
try:
netaddr.IPAddress(_validate_no_whitespace(data))
# The followings are quick checks for IPv6 (has ':') and
# IPAddress('199.28.113.199')
# >>>
if ':' not in data and data.count('.') != 3:
- raise ValueError()
+ msg = _("'%s' is not a valid IP address") % data
except Exception:
msg = _("'%s' is not a valid IP address") % data
+ if msg:
LOG.debug(msg)
- return msg
+ return msg
def _validate_ip_pools(data, valid_values=None):