Browse Source

Get only FIP ID on network delete

Get FloatingIP object results in a quite heavy DB request.
delete_disassociated_floatingips() only needs IDs.

Change-Id: I6a40e6e3f937fa30bbb29768211ec8e689d4f82a
(cherry picked from commit 282dc73e12)
changes/87/787487/1
Oleg Bondarev 4 weeks ago
committed by Oleg Bondarev
parent
commit
d9047ec5db
2 changed files with 13 additions and 5 deletions
  1. +4
    -5
      neutron/db/l3_db.py
  2. +9
    -0
      neutron/objects/router.py

+ 4
- 5
neutron/db/l3_db.py View File

@ -1519,12 +1519,11 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
@db_api.retry_if_session_inactive()
def delete_disassociated_floatingips(self, context, network_id):
fip_objs = l3_obj.FloatingIP.get_objects(
context,
floating_network_id=network_id, router_id=None, fixed_port_id=None)
fip_ids = l3_obj.FloatingIP.get_disassociated_ids_for_net(
context, network_id)
for fip in fip_objs:
self.delete_floatingip(context, fip.id)
for fip_id in fip_ids:
self.delete_floatingip(context, fip_id)
@db_api.retry_if_session_inactive()
def get_floatingips_count(self, context, filters=None):


+ 9
- 0
neutron/objects/router.py View File

@ -310,6 +310,15 @@ class FloatingIP(base.NeutronDbObject):
row = [r for r in six.next(value)]
yield (cls._load_object(context, row[0]), row[1])
@classmethod
def get_disassociated_ids_for_net(cls, context, network_id):
query = context.session.query(cls.db_model.id)
query = query.filter_by(
floating_network_id=network_id,
router_id=None,
fixed_port_id=None)
return [f.id for f in query]
@base.NeutronObjectRegistry.register
class DvrFipGatewayPortAgentBinding(base.NeutronDbObject):


Loading…
Cancel
Save