Fix bgp-speaker-network-remove error

Table name BgpSpeakerPeerBinding is missing in the filter

Change-Id: Icf3d8f41b64d2813517f3509c440c29c5c36681d
Closes-Bug: #1584661
This commit is contained in:
steve.ruan 2016-05-23 22:28:25 -05:00
parent fb4c68d620
commit 908feafbe5
2 changed files with 10 additions and 7 deletions

View File

@ -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',

View File

@ -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"