def _validate_cidr_format(self, cidr, logger):
"""Validate that CIDR have a correct format. Example "10.10.10.10/24"
:param str cidr:
:param logging.Logger logger:
:return: True/False whether CIDR is valid or not
:rtype: bool
"""
try:
netaddr.IPNetwork(cidr)
except netaddr.AddrFormatError:
logger.info("CIDR {} is in invalid format", exc_info=1)
return False
if '/' not in cidr:
return False
return True
评论列表
文章目录