Optimize get_ports query by filtering on subnet
Optimize get_ports query by filtering on subnet

Current code gets all ports from DB and then for each port it checks
if it has a PD subnet. With this, we get ports which are not needed
and again we need to check for subnet in these ports.

We can optimize this by querying the DB by filtering on subnet.

Closes-bug: #1566676
Change-Id: I2451f9a2c6a64ce27a607b193900caa05742273d

cloudbase/neutron,huntxu/neutron,huntxu/neutron,openstack/neutron,mahak/neutron,noironetworks/neutron,sebrandon1/neutron,mahak/neutron,igor-toga/local-snat,mahak/neutron,noironetworks/neutron,igor-toga/local-snat,eayunstack/neutron,openstack/neutron,cloudbase/neutron,eayunstack/neutron,sebrandon1/neutron,openstack/neutron,bigswitch/neutron,bigswitch/neutron