Ensure non-overlapping cidrs in subnetpools without galera
Ensure non-overlapping cidrs in subnetpools without galera

_get_allocated_cidrs[1] locks only allocated subnets in a subnetpool
(with mysql/postgresql at least). It ensures we don't allocate a cidr
overlapping with existent cidrs but nothing disallows a concurrent
subnet allocation to create a subnet in the same subnetpool.

This change replaces the lock on subnetpool subnets by a lock on the
subnetpool itself. It disallows to allocate concurrently 2 subnets in
the same subnetpool and ensure non-overlapping cidrs in the same
subnetpool.

Moreover this change solves a trouble with postgresql which disallows
to lock an empty select with an outer join: it happens on first subnet
allocation in a subnetpool when no specific cidr is provided. Moving
the lock ensures the lock is done on a non-empty select.

But this change does not ensure non-overlapping cidrs in subnetpools
with galera because galera doesn't support SELECT FOR UPDATE locks. A
follow-up change will (try to?) remove locks from subnet allocation[1]
in order to ensure non-overlapping cidrs in subnetpools also with galera.

[1] in neutron.ipam.subnet_alloc.SubnetAllocator

Closes-Bug: #1451558
Partial-Bug: #1451576
Change-Id: I73854f9863f44621ae0d89c5dc4893ccc16d07e4

eayunstack/neutron,SamYaple/neutron,bigswitch/neutron,igor-toga/local-snat,shahbazn/neutron,jacknjzhou/neutron,neoareslinux/neutron,takeshineshiro/neutron,wenhuizhang/neutron,NeCTAR-RC/neutron,mahak/neutron,cloudbase/neutron,vivekanand1101/neutron,huntxu/neutron,cisco-openstack/neutron,eonpatapon/neutron,dims/neutron,apporc/neutron,barnsnake351/neutron,javaos74/neutron,yanheven/neutron,sebrandon1/neutron,suneeth51/neutron,mattt416/neutron,jacknjzhou/neutron,MaximNevrov/neutron,mmnelemane/neutron,MaximNevrov/neutron,huntxu/neutron,eayunstack/neutron,glove747/liberty-neutron,chitr/neutron,mmnelemane/neutron,klmitch/neutron,swdream/neutron,watonyweng/neutron,jerryz1982/neutron,wolverineav/neutron,igor-toga/local-snat,JianyuWang/neutron,suneeth51/neutron,adelina-t/neutron,klmitch/neutron,barnsnake351/neutron,adelina-t/neutron,watonyweng/neutron,noironetworks/neutron,swdream/neutron,jumpojoy/neutron,jerryz1982/neutron,asgard-lab/neutron,chitr/neutron,skyddv/neutron,noironetworks/neutron,wolverineav/neutron,dhanunjaya/neutron,cloudbase/neutron,dims/neutron,bgxavier/neutron,paninetworks/neutron,glove747/liberty-neutron,vivekanand1101/neutron,bgxavier/neutron,SamYaple/neutron,shahbazn/neutron,dhanunjaya/neutron,skyddv/neutron,eonpatapon/neutron,asgard-lab/neutron,openstack/neutron,yanheven/neutron,apporc/neutron,openstack/neutron,takeshineshiro/neutron,bigswitch/neutron,mahak/neutron,mattt416/neutron,cisco-openstack/neutron,sasukeh/neutron,mahak/neutron,NeCTAR-RC/neutron,silenci/neutron,paninetworks/neutron,wenhuizhang/neutron,sebrandon1/neutron,JianyuWang/neutron,jumpojoy/neutron,silenci/neutron,mandeepdhami/neutron,javaos74/neutron,sasukeh/neutron,openstack/neutron,mandeepdhami/neutron,neoareslinux/neutron