diff --git a/neutron_dynamic_routing/db/bgp_db.py b/neutron_dynamic_routing/db/bgp_db.py index 21976adc..61d6fb7f 100644 --- a/neutron_dynamic_routing/db/bgp_db.py +++ b/neutron_dynamic_routing/db/bgp_db.py @@ -436,8 +436,9 @@ class BgpDbMixin(common_db.CommonDbMixin): def _get_bgp_speaker_network_binding(self, context, bgp_speaker_id, network_id): query = self._model_query(context, BgpSpeakerNetworkBinding) - return query.filter(bgp_speaker_id == bgp_speaker_id, - network_id == network_id).one() + return query.filter( + BgpSpeakerNetworkBinding.bgp_speaker_id == bgp_speaker_id, + BgpSpeakerNetworkBinding.network_id == network_id).one() def _make_bgp_peer_dict(self, bgp_peer, fields=None): attrs = ['tenant_id', 'id', 'name', 'peer_ip', 'remote_as', diff --git a/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py b/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py index 910ecad8..18348490 100644 --- a/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py +++ b/neutron_dynamic_routing/tests/unit/db/test_bgp_db.py @@ -356,19 +356,21 @@ class BgpTests(test_plugin.Ml2PluginV2TestCase, self.assertTrue(network['id'] in speaker['networks']) def test_remove_gateway_network(self): - with self.network() as network,\ + with self.network() as network1,\ + self.network() as network2,\ self.subnetpool_with_address_scope(4, prefixes=['8.0.0.0/8']) as sp: - network_id = network['network']['id'] + network1_id = network1['network']['id'] + network2_id = network2['network']['id'] with self.bgp_speaker(sp['ip_version'], 1234, - networks=[network_id]) as speaker: + networks=[network1_id, network2_id]) as speaker: self.bgp_plugin.remove_gateway_network( self.context, speaker['id'], - {'network_id': network_id}) + {'network_id': network1_id}) new_speaker = self.bgp_plugin.get_bgp_speaker(self.context, speaker['id']) - self.assertEqual(0, len(new_speaker['networks'])) + self.assertEqual(1, len(new_speaker['networks'])) def test_add_non_existent_gateway_network(self): network_id = "imaginary"