Catch DBReferenceError in IPAM and convert to SubnetNotFound
Catch DBReferenceError in IPAM and convert to SubnetNotFound

If a subnet is removed after lookup but before IP allocation
insert, we can end up getting a DBReferenceError in the IPAM
system. Since this can occur on any flush we force a flush
with a session context manager to get the DBReference error
in a desired spot (in multi-writer galera this is a deadlock
much later, which we retry). We then convert it to SubnetNotFound,
which is an expected exception.

Closes-Bug: #1623402
Change-Id: I65632b174f8692cd465c721e285526827842a740

mahak/neutron,huntxu/neutron,openstack/neutron,eayunstack/neutron,cloudbase/neutron,mahak/neutron,sebrandon1/neutron,openstack/neutron,cloudbase/neutron,sebrandon1/neutron,noironetworks/neutron,openstack/neutron,huntxu/neutron,mahak/neutron,noironetworks/neutron,eayunstack/neutron