Payload changes for FLOATING_IP events

Depends-On: https://review.opendev.org/#/c/798009

Signed-off-by: Manu B <manu.b@est.tech>
Change-Id: I4c6e04b82426ebbe41273fbc584ee3e8df70aead
(cherry picked from commit 630678b5f9)
This commit is contained in:
Manu B 2021-09-06 06:58:06 +00:00 committed by Bernard Cafarelli
parent 891ca86212
commit f226215611
2 changed files with 13 additions and 9 deletions

View File

@ -231,15 +231,18 @@ class BgpPlugin(service_base.ServicePluginBase,
if event not in [events.AFTER_CREATE, events.AFTER_UPDATE]:
return
ctx = context.get_admin_context()
fip = payload.latest_state
new_router_id = fip['router_id']
last_router_id = fip.get('last_known_router_id')
floating_ip_address = fip['floating_ip_address']
new_fip = payload.latest_state
new_router_id = new_fip['router_id']
floating_ip_address = new_fip['floating_ip_address']
dest = str(floating_ip_address) + '/32'
bgp_speakers = self._bgp_speakers_for_gw_network_by_family(
ctx,
fip['floating_network_id'],
new_fip['floating_network_id'],
n_const.IP_VERSION_4)
last_router_id = None
if event == events.AFTER_UPDATE:
old_fip = payload.states[0]
last_router_id = old_fip['router_id']
if last_router_id and new_router_id != last_router_id:
# Here gives the old route next_hop a `None` value, then

View File

@ -94,9 +94,10 @@ class TestBgpPlugin(base.BaseTestCase):
payload=payload)
def test_floatingip_update_callback(self):
fip = {'floating_ip_address': netaddr.IPAddress('10.10.10.10'),
'last_known_router_id': 'old-router-id',
'router_id': '', 'floating_network_id': 'a-b-c-d-e'}
new_fip = {'floating_ip_address': netaddr.IPAddress('10.10.10.10'),
'router_id': '', 'floating_network_id': 'a-b-c-d-e'}
old_fip = new_fip.copy()
old_fip.update(router_id='old-router-id')
test_context = 'test_context'
@ -112,7 +113,7 @@ class TestBgpPlugin(base.BaseTestCase):
self.plugin.floatingip_update_callback(
test_context, events.AFTER_UPDATE, None,
payload=events.DBEventPayload(
test_context, states=(fip,)))
test_context, states=(old_fip, new_fip)))
get_bgp.assert_called_once_with(self.fake_admin_ctx,
'a-b-c-d-e',