From d1a3c2a379fc1d2879ea46e3689ca39c9419e397 Mon Sep 17 00:00:00 2001 From: Hongbin Lu <hongbin.lu@huawei.com> Date: Fri, 12 Oct 2018 23:06:11 +0000 Subject: [PATCH] Convert Subnet to OVO in ipam_pluggable_backend.py Change-Id: Ie3531ce47cff6efeb8a14a974e6587e63740148b Partial-Implements: blueprint adopt-oslo-versioned-objects-for-db --- neutron/db/ipam_backend_mixin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neutron/db/ipam_backend_mixin.py b/neutron/db/ipam_backend_mixin.py index 6da20ddd4d1..cd205e5f115 100644 --- a/neutron/db/ipam_backend_mixin.py +++ b/neutron/db/ipam_backend_mixin.py @@ -314,9 +314,9 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): def _validate_segment(self, context, network_id, segment_id, action=None, old_segment_id=None): - query = context.session.query(models_v2.Subnet.segment_id) - query = query.filter(models_v2.Subnet.network_id == network_id) - associated_segments = set(row.segment_id for row in query) + segments = subnet_obj.Subnet.get_values( + context, 'segment_id', network_id=network_id) + associated_segments = set(segments) if None in associated_segments and len(associated_segments) > 1: raise segment_exc.SubnetsNotAllAssociatedWithSegments( network_id=network_id) @@ -324,7 +324,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): if action == 'update' and old_segment_id != segment_id: # Check the current state of segments and subnets on the network # before allowing migration from non-routed to routed network. - if query.count() > 1: + if len(segments) > 1: raise segment_exc.SubnetsNotAllAssociatedWithSegments( network_id=network_id) if (None not in associated_segments and