Merge "Raise exception when put CIDR into address pairs"

This commit is contained in:
Jenkins 2016-07-13 17:01:27 +00:00 committed by Gerrit Code Review
commit c23468f9e7
2 changed files with 15 additions and 1 deletions

View File

@ -1163,8 +1163,12 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
return net_res
def _validate_address_pairs(self, attrs, db_port):
# Check that the MAC address is the same as the port
for ap in attrs[addr_pair.ADDRESS_PAIRS]:
# Check that the IP address is a subnet
if len(ap['ip_address'].split('/')) > 1:
msg = _('NSXv does not support CIDR as address pairs')
raise n_exc.BadRequest(resource='address_pairs', msg=msg)
# Check that the MAC address is the same as the port
if ('mac_address' in ap and
ap['mac_address'] != db_port['mac_address']):
msg = _('Address pairs should have same MAC as the port')

View File

@ -21,6 +21,7 @@ from neutron.api.rpc.callbacks import events as callbacks_events
from neutron.api.v2 import attributes
from neutron.common import utils
from neutron import context
from neutron.extensions import allowedaddresspairs as addr_pair
from neutron.extensions import dvr as dist_router
from neutron.extensions import external_net
from neutron.extensions import l3
@ -3556,6 +3557,15 @@ class TestNSXvAllowedAddressPairs(NsxVPluginV2TestCase,
def test_get_vlan_network_name(self):
pass
def test_create_port_with_cidr_address_pair(self):
with self.network() as net:
address_pairs = [{'mac_address': '00:00:00:00:00:01',
'ip_address': '192.168.1.0/24'}]
self._create_port(self.fmt, net['network']['id'],
expected_res_status=webob.exc.HTTPBadRequest.code,
arg_list=(addr_pair.ADDRESS_PAIRS,),
allowed_address_pairs=address_pairs)
class TestNSXPortSecurity(test_psec.TestPortSecurity,
NsxVPluginV2TestCase):