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
This commit is contained in:
parent
891ca86212
commit
630678b5f9
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue