NSX|V3+P: Fix address pairs validation

1. /32 cidr is allowed
2. ipv6 validation is not necessary as the backend supports cidrs.

Change-Id: If8027db6190486a2a0c6410ad119810f4938f13d
This commit is contained in:
Adit Sarfaty 2019-07-21 09:56:30 +03:00
parent 4cadc580ae
commit db088c6e9c
1 changed files with 6 additions and 3 deletions

View File

@ -323,9 +323,12 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
def _validate_address_pairs(self, address_pairs):
for pair in address_pairs:
ip = pair.get('ip_address')
if len(ip.split('/')) > 1:
LOG.error("cidr is not supported in allowed address pairs")
raise nsx_exc.InvalidIPAddress(ip_address=ip)
# Validate ipv4 cidrs (No limitation on ipv6):
if ':' not in ip:
if len(ip.split('/')) > 1 and ip.split('/')[1] != '32':
LOG.error("cidr %s is not supported in allowed address "
"pairs", ip)
raise nsx_exc.InvalidIPAddress(ip_address=ip)
def _validate_number_of_address_pairs(self, port):
address_pairs = port.get(addr_apidef.ADDRESS_PAIRS)