]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Fix duplicate entry catch for allowed address pairs
authorWei Wang <wangwei@unitedstack.com>
Thu, 25 Sep 2014 09:49:59 +0000 (17:49 +0800)
committerWei Wang <wangwei@unitedstack.com>
Fri, 10 Jul 2015 10:55:58 +0000 (18:55 +0800)
commit1025baec55235bf4981872390f1bb65f4e3ae7e6
tree62b91636aaf3002d176bf1812d00a3c0f2dbe6e6
parent043f6c3091192f721f0181fbcfa8eec361730fdc
Fix duplicate entry catch for allowed address pairs

If None is submitted as a MAC address in an allowed_address_pair,
the port MAC will be used. So if two entries are submitted with the
same IP and one's MAC is None while the others is the port's MAC,
they will pass the API duplication check and fail to insert into the DB
due to a unique constraint violation.

This patch catches the db error and turns it into the same exception
the API uses on duplicate entries.

Closes-bug: #1373756
Change-Id: Ide995810d6fe0481d3add206bf0674cbbde7f05f
neutron/db/allowedaddresspairs_db.py
neutron/tests/unit/db/test_allowedaddresspairs_db.py