Merge "Cosmetic: Change ._ovn to ._nb_ovn to match ._sb_ovn"
This commit is contained in:
commit
b189213d1e
@ -404,7 +404,7 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
|||||||
# Iterate over each acl in a lswitch and store the acl in
|
# Iterate over each acl in a lswitch and store the acl in
|
||||||
# a key:value representation for e.g. acl_string. This
|
# a key:value representation for e.g. acl_string. This
|
||||||
# key:value representation can invoke the code -
|
# key:value representation can invoke the code -
|
||||||
# self._ovn.add_acl(**acl_string)
|
# self.add_acl(**acl_string)
|
||||||
for acl in acls:
|
for acl in acls:
|
||||||
ext_ids = getattr(acl, 'external_ids', {})
|
ext_ids = getattr(acl, 'external_ids', {})
|
||||||
port_id = ext_ids.get('neutron:lport')
|
port_id = ext_ids.get('neutron:lport')
|
||||||
|
@ -86,7 +86,7 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
|
|||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if utils.is_ovn_l3(self.l3_plugin):
|
if utils.is_ovn_l3(self.l3_plugin):
|
||||||
self.l3_plugin._ovn.ovsdb_connection.stop()
|
self.l3_plugin._nb_ovn.ovsdb_connection.stop()
|
||||||
self.l3_plugin._sb_ovn.ovsdb_connection.stop()
|
self.l3_plugin._sb_ovn.ovsdb_connection.stop()
|
||||||
super(OvnNbSynchronizer, self).stop()
|
super(OvnNbSynchronizer, self).stop()
|
||||||
|
|
||||||
|
@ -114,12 +114,12 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
@property
|
@property
|
||||||
def _ovn_client(self):
|
def _ovn_client(self):
|
||||||
if self._ovn_client_inst is None:
|
if self._ovn_client_inst is None:
|
||||||
self._ovn_client_inst = ovn_client.OVNClient(self._ovn,
|
self._ovn_client_inst = ovn_client.OVNClient(self._nb_ovn,
|
||||||
self._sb_ovn)
|
self._sb_ovn)
|
||||||
return self._ovn_client_inst
|
return self._ovn_client_inst
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _ovn(self):
|
def _nb_ovn(self):
|
||||||
return self._plugin_driver.nb_ovn
|
return self._plugin_driver.nb_ovn
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -362,7 +362,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
if not self._plugin_driver.list_availability_zones(context):
|
if not self._plugin_driver.list_availability_zones(context):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
lrp = self._ovn.get_lrouter_port(lrp_name)
|
lrp = self._nb_ovn.get_lrouter_port(lrp_name)
|
||||||
router = self.get_router(
|
router = self.get_router(
|
||||||
context, lrp.external_ids[ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY])
|
context, lrp.external_ids[ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY])
|
||||||
az_hints = common_utils.get_az_hints(router)
|
az_hints = common_utils.get_az_hints(router)
|
||||||
@ -373,7 +373,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
port_physnet_dict = self._get_gateway_port_physnet_mapping()
|
port_physnet_dict = self._get_gateway_port_physnet_mapping()
|
||||||
# Filter out unwanted ports in case of event.
|
# Filter out unwanted ports in case of event.
|
||||||
if event_from_chassis:
|
if event_from_chassis:
|
||||||
gw_chassis = self._ovn.get_chassis_gateways(
|
gw_chassis = self._nb_ovn.get_chassis_gateways(
|
||||||
chassis_name=event_from_chassis)
|
chassis_name=event_from_chassis)
|
||||||
if not gw_chassis:
|
if not gw_chassis:
|
||||||
return
|
return
|
||||||
@ -394,17 +394,17 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
chassis_with_physnets = self._sb_ovn.get_chassis_and_physnets()
|
chassis_with_physnets = self._sb_ovn.get_chassis_and_physnets()
|
||||||
# All chassis with enable_as_gw_chassis set
|
# All chassis with enable_as_gw_chassis set
|
||||||
all_gw_chassis = self._sb_ovn.get_gateway_chassis_from_cms_options()
|
all_gw_chassis = self._sb_ovn.get_gateway_chassis_from_cms_options()
|
||||||
unhosted_gateways = self._ovn.get_unhosted_gateways(
|
unhosted_gateways = self._nb_ovn.get_unhosted_gateways(
|
||||||
port_physnet_dict, chassis_with_physnets,
|
port_physnet_dict, chassis_with_physnets,
|
||||||
all_gw_chassis)
|
all_gw_chassis)
|
||||||
for g_name in unhosted_gateways:
|
for g_name in unhosted_gateways:
|
||||||
physnet = port_physnet_dict.get(g_name[len(ovn_const.LRP_PREFIX):])
|
physnet = port_physnet_dict.get(g_name[len(ovn_const.LRP_PREFIX):])
|
||||||
# Remove any invalid gateway chassis from the list, otherwise
|
# Remove any invalid gateway chassis from the list, otherwise
|
||||||
# we can have a situation where all existing_chassis are invalid
|
# we can have a situation where all existing_chassis are invalid
|
||||||
existing_chassis = self._ovn.get_gateway_chassis_binding(g_name)
|
existing_chassis = self._nb_ovn.get_gateway_chassis_binding(g_name)
|
||||||
primary = existing_chassis[0] if existing_chassis else None
|
primary = existing_chassis[0] if existing_chassis else None
|
||||||
existing_chassis = self.scheduler.filter_existing_chassis(
|
existing_chassis = self.scheduler.filter_existing_chassis(
|
||||||
nb_idl=self._ovn, gw_chassis=all_gw_chassis,
|
nb_idl=self._nb_ovn, gw_chassis=all_gw_chassis,
|
||||||
physnet=physnet, chassis_physnets=chassis_with_physnets,
|
physnet=physnet, chassis_physnets=chassis_with_physnets,
|
||||||
existing_chassis=existing_chassis)
|
existing_chassis=existing_chassis)
|
||||||
az_hints = self._get_availability_zones_from_router_port(g_name)
|
az_hints = self._get_availability_zones_from_router_port(g_name)
|
||||||
@ -413,7 +413,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
chassis_physnets=chassis_with_physnets,
|
chassis_physnets=chassis_with_physnets,
|
||||||
availability_zone_hints=az_hints)
|
availability_zone_hints=az_hints)
|
||||||
chassis = self.scheduler.select(
|
chassis = self.scheduler.select(
|
||||||
self._ovn, self._sb_ovn, g_name, candidates=candidates,
|
self._nb_ovn, self._sb_ovn, g_name, candidates=candidates,
|
||||||
existing_chassis=existing_chassis)
|
existing_chassis=existing_chassis)
|
||||||
if primary and primary != chassis[0]:
|
if primary and primary != chassis[0]:
|
||||||
if primary not in chassis:
|
if primary not in chassis:
|
||||||
@ -433,8 +433,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
chassis[0], chassis[index] = chassis[index], chassis[0]
|
chassis[0], chassis[index] = chassis[index], chassis[0]
|
||||||
# NOTE(dalvarez): Let's commit the changes in separate transactions
|
# NOTE(dalvarez): Let's commit the changes in separate transactions
|
||||||
# as we will rely on those for scheduling subsequent gateways.
|
# as we will rely on those for scheduling subsequent gateways.
|
||||||
with self._ovn.transaction(check_error=True) as txn:
|
with self._nb_ovn.transaction(check_error=True) as txn:
|
||||||
txn.add(self._ovn.update_lrouter_port(
|
txn.add(self._nb_ovn.update_lrouter_port(
|
||||||
g_name, gateway_chassis=chassis))
|
g_name, gateway_chassis=chassis))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -460,7 +460,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
] if orig_gw_ip else []
|
] if orig_gw_ip else []
|
||||||
add = [{'destination': '0.0.0.0/0', 'nexthop': current_gw_ip}
|
add = [{'destination': '0.0.0.0/0', 'nexthop': current_gw_ip}
|
||||||
] if current_gw_ip else []
|
] if current_gw_ip else []
|
||||||
with l3plugin._ovn.transaction(check_error=True) as txn:
|
with l3plugin._nb_ovn.transaction(check_error=True) as txn:
|
||||||
for router_id in router_ids:
|
for router_id in router_ids:
|
||||||
l3plugin._ovn_client.update_router_routes(
|
l3plugin._ovn_client.update_router_routes(
|
||||||
context, router_id, add, remove, txn=txn)
|
context, router_id, add, remove, txn=txn)
|
||||||
@ -502,7 +502,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
current, if_exists=True)
|
current, if_exists=True)
|
||||||
|
|
||||||
def get_router_availability_zones(self, router):
|
def get_router_availability_zones(self, router):
|
||||||
lr = self._ovn.get_lrouter(router['id'])
|
lr = self._nb_ovn.get_lrouter(router['id'])
|
||||||
if not lr:
|
if not lr:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ class OVNPortForwarding(object):
|
|||||||
if not payload:
|
if not payload:
|
||||||
return
|
return
|
||||||
context = payload.context
|
context = payload.context
|
||||||
ovn_nb = self._l3_plugin._ovn
|
ovn_nb = self._l3_plugin._nb_ovn
|
||||||
with ovn_nb.transaction(check_error=True) as ovn_txn:
|
with ovn_nb.transaction(check_error=True) as ovn_txn:
|
||||||
if event_type == events.AFTER_CREATE:
|
if event_type == events.AFTER_CREATE:
|
||||||
self._handler.port_forwarding_created(ovn_txn, ovn_nb,
|
self._handler.port_forwarding_created(ovn_txn, ovn_nb,
|
||||||
@ -213,7 +213,7 @@ class OVNPortForwarding(object):
|
|||||||
pf_objs = self._get_pf_objs(context, fip_id)
|
pf_objs = self._get_pf_objs(context, fip_id)
|
||||||
LOG.debug("Maintenance port forwarding under fip %s : %s",
|
LOG.debug("Maintenance port forwarding under fip %s : %s",
|
||||||
fip_id, pf_objs)
|
fip_id, pf_objs)
|
||||||
ovn_nb = self._l3_plugin._ovn
|
ovn_nb = self._l3_plugin._nb_ovn
|
||||||
with ovn_nb.transaction(check_error=True) as ovn_txn:
|
with ovn_nb.transaction(check_error=True) as ovn_txn:
|
||||||
for lb_name in self._handler.lb_names(fip_id):
|
for lb_name in self._handler.lb_names(fip_id):
|
||||||
ovn_txn.add(ovn_nb.lb_del(lb_name, vip=None, if_exists=True))
|
ovn_txn.add(ovn_nb.lb_del(lb_name, vip=None, if_exists=True))
|
||||||
@ -240,7 +240,7 @@ class OVNPortForwarding(object):
|
|||||||
def maintenance_delete(self, _context, fip_id):
|
def maintenance_delete(self, _context, fip_id):
|
||||||
LOG.info("Maintenance DELETE port-forwarding entries under fip %s",
|
LOG.info("Maintenance DELETE port-forwarding entries under fip %s",
|
||||||
fip_id)
|
fip_id)
|
||||||
ovn_nb = self._l3_plugin._ovn
|
ovn_nb = self._l3_plugin._nb_ovn
|
||||||
with ovn_nb.transaction(check_error=True) as ovn_txn:
|
with ovn_nb.transaction(check_error=True) as ovn_txn:
|
||||||
for lb_name in self._handler.lb_names(fip_id):
|
for lb_name in self._handler.lb_names(fip_id):
|
||||||
ovn_txn.add(ovn_nb.lb_del(lb_name, vip=None, if_exists=True))
|
ovn_txn.add(ovn_nb.lb_del(lb_name, vip=None, if_exists=True))
|
||||||
@ -250,7 +250,7 @@ class OVNPortForwarding(object):
|
|||||||
# NOTE: Since the db_sync callback is not granular to the level
|
# NOTE: Since the db_sync callback is not granular to the level
|
||||||
# of the affected pfs AND the fact that pfs are all vips
|
# of the affected pfs AND the fact that pfs are all vips
|
||||||
# in a load balancer entry, it is cheap enough to simply rebuild.
|
# in a load balancer entry, it is cheap enough to simply rebuild.
|
||||||
ovn_nb = self._l3_plugin._ovn
|
ovn_nb = self._l3_plugin._nb_ovn
|
||||||
pf_objs = self._get_pf_objs(context, fip_id)
|
pf_objs = self._get_pf_objs(context, fip_id)
|
||||||
LOG.debug("Db sync port forwarding under fip %s : %s", fip_id, pf_objs)
|
LOG.debug("Db sync port forwarding under fip %s : %s", fip_id, pf_objs)
|
||||||
for lb_name in self._handler.lb_names(fip_id):
|
for lb_name in self._handler.lb_names(fip_id):
|
||||||
@ -262,7 +262,7 @@ class OVNPortForwarding(object):
|
|||||||
|
|
||||||
def db_sync_delete(self, context, fip_id, ovn_txn):
|
def db_sync_delete(self, context, fip_id, ovn_txn):
|
||||||
LOG.info("db_sync DELETE entries under fip %s", fip_id)
|
LOG.info("db_sync DELETE entries under fip %s", fip_id)
|
||||||
ovn_nb = self._l3_plugin._ovn
|
ovn_nb = self._l3_plugin._nb_ovn
|
||||||
for lb_name in self._handler.lb_names(fip_id):
|
for lb_name in self._handler.lb_names(fip_id):
|
||||||
ovn_txn.add(ovn_nb.lb_del(lb_name, vip=None, if_exists=True))
|
ovn_txn.add(ovn_nb.lb_del(lb_name, vip=None, if_exists=True))
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
'ports': [self.lb_vip_lsp, self.member_lsp],
|
'ports': [self.lb_vip_lsp, self.member_lsp],
|
||||||
'uuid': self.fake_network['id']})
|
'uuid': self.fake_network['id']})
|
||||||
self.nb_idl = self._start_mock(
|
self.nb_idl = self._start_mock(
|
||||||
'neutron.services.ovn_l3.plugin.OVNL3RouterPlugin._ovn',
|
'neutron.services.ovn_l3.plugin.OVNL3RouterPlugin._nb_ovn',
|
||||||
new_callable=mock.PropertyMock,
|
new_callable=mock.PropertyMock,
|
||||||
return_value=fake_resources.FakeOvsdbNbOvnIdl())
|
return_value=fake_resources.FakeOvsdbNbOvnIdl())
|
||||||
self.sb_idl = self._start_mock(
|
self.sb_idl = self._start_mock(
|
||||||
@ -322,9 +322,9 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
func.return_value = self.fake_router_interface_info
|
func.return_value = self.fake_router_interface_info
|
||||||
self.l3_inst.add_router_interface(self.context, router_id,
|
self.l3_inst.add_router_interface(self.context, router_id,
|
||||||
interface_info)
|
interface_info)
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**self.fake_router_port_assert)
|
**self.fake_router_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
@ -358,12 +358,13 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.add_router_interface(self.context, router_id,
|
self.l3_inst.add_router_interface(self.context, router_id,
|
||||||
interface_info)
|
interface_info)
|
||||||
called_args_dict = (
|
called_args_dict = (
|
||||||
self.l3_inst._ovn.update_lrouter_port.call_args_list[0][1])
|
self.l3_inst._nb_ovn.update_lrouter_port.call_args_list[0][1])
|
||||||
|
|
||||||
self.assertEqual(1, self.l3_inst._ovn.update_lrouter_port.call_count)
|
self.assertEqual(1,
|
||||||
|
self.l3_inst._nb_ovn.update_lrouter_port.call_count)
|
||||||
self.assertCountEqual(fake_rtr_intf_networks,
|
self.assertCountEqual(fake_rtr_intf_networks,
|
||||||
called_args_dict.get('networks', []))
|
called_args_dict.get('networks', []))
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
@ -377,7 +378,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.remove_router_interface(
|
self.l3_inst.remove_router_interface(
|
||||||
self.context, router_id, interface_info)
|
self.context, router_id, interface_info)
|
||||||
|
|
||||||
self.l3_inst._ovn.lrp_del.assert_called_once_with(
|
self.l3_inst._nb_ovn.lrp_del.assert_called_once_with(
|
||||||
'lrp-router-port-id', 'neutron-router-id', if_exists=True)
|
'lrp-router-port-id', 'neutron-router-id', if_exists=True)
|
||||||
self.del_rev_p.assert_called_once_with(
|
self.del_rev_p.assert_called_once_with(
|
||||||
self.context, 'router-port-id', ovn_const.TYPE_ROUTER_PORTS)
|
self.context, 'router-port-id', ovn_const.TYPE_ROUTER_PORTS)
|
||||||
@ -388,7 +389,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.remove_router_interface(
|
self.l3_inst.remove_router_interface(
|
||||||
self.context, router_id, interface_info)
|
self.context, router_id, interface_info)
|
||||||
|
|
||||||
self.l3_inst._ovn.update_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.update_lrouter_port.assert_called_once_with(
|
||||||
if_exists=False, name='lrp-router-port-id',
|
if_exists=False, name='lrp-router-port-id',
|
||||||
ipv6_ra_configs={},
|
ipv6_ra_configs={},
|
||||||
networks=['10.0.0.100/24'],
|
networks=['10.0.0.100/24'],
|
||||||
@ -411,7 +412,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.context, router_id, interface_info)
|
self.context, router_id, interface_info)
|
||||||
|
|
||||||
self.get_router.assert_called_once_with(self.context, 'router-id')
|
self.get_router.assert_called_once_with(self.context, 'router-id')
|
||||||
self.l3_inst._ovn.lrp_del.assert_called_once_with(
|
self.l3_inst._nb_ovn.lrp_del.assert_called_once_with(
|
||||||
'lrp-router-port-id', 'neutron-router-id', if_exists=True)
|
'lrp-router-port-id', 'neutron-router-id', if_exists=True)
|
||||||
self.del_rev_p.assert_called_once_with(
|
self.del_rev_p.assert_called_once_with(
|
||||||
self.context, 'router-port-id', ovn_const.TYPE_ROUTER_PORTS)
|
self.context, 'router-port-id', ovn_const.TYPE_ROUTER_PORTS)
|
||||||
@ -428,7 +429,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
func.return_value = new_router
|
func.return_value = new_router
|
||||||
self.l3_inst.update_router(self.context, router_id,
|
self.l3_inst.update_router(self.context, router_id,
|
||||||
{'router': updated_data})
|
{'router': updated_data})
|
||||||
self.l3_inst._ovn.update_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.update_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', enabled=True, external_ids={
|
'neutron-router-id', enabled=True, external_ids={
|
||||||
ovn_const.OVN_GW_PORT_EXT_ID_KEY: '',
|
ovn_const.OVN_GW_PORT_EXT_ID_KEY: '',
|
||||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
||||||
@ -447,7 +448,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
func.return_value = new_router
|
func.return_value = new_router
|
||||||
self.l3_inst.update_router(self.context, router_id,
|
self.l3_inst.update_router(self.context, router_id,
|
||||||
{'router': updated_data})
|
{'router': updated_data})
|
||||||
self.l3_inst._ovn.update_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.update_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', enabled=False,
|
'neutron-router-id', enabled=False,
|
||||||
external_ids={ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY: 'test',
|
external_ids={ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY: 'test',
|
||||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
||||||
@ -472,8 +473,8 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
update_data = {'router': {'routes': [{'destination': '1.1.1.0/24',
|
update_data = {'router': {'routes': [{'destination': '1.1.1.0/24',
|
||||||
'nexthop': '10.0.0.2'}]}}
|
'nexthop': '10.0.0.2'}]}}
|
||||||
self.l3_inst.update_router(self.context, router_id, update_data)
|
self.l3_inst.update_router(self.context, router_id, update_data)
|
||||||
self.assertFalse(self.l3_inst._ovn.add_static_route.called)
|
self.assertFalse(self.l3_inst._nb_ovn.add_static_route.called)
|
||||||
self.assertFalse(self.l3_inst._ovn.delete_static_route.called)
|
self.assertFalse(self.l3_inst._nb_ovn.delete_static_route.called)
|
||||||
|
|
||||||
@mock.patch.object(utils, 'get_lrouter_non_gw_routes')
|
@mock.patch.object(utils, 'get_lrouter_non_gw_routes')
|
||||||
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
||||||
@ -498,10 +499,10 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
func.return_value = new_router
|
func.return_value = new_router
|
||||||
self.l3_inst.update_router(self.context, router_id,
|
self.l3_inst.update_router(self.context, router_id,
|
||||||
{'router': updated_data})
|
{'router': updated_data})
|
||||||
self.l3_inst._ovn.add_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_static_route.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
ip_prefix='2.2.2.0/24', nexthop='10.0.0.3')
|
ip_prefix='2.2.2.0/24', nexthop='10.0.0.3')
|
||||||
self.l3_inst._ovn.delete_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.delete_static_route.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
ip_prefix='1.1.1.0/24', nexthop='10.0.0.2')
|
ip_prefix='1.1.1.0/24', nexthop='10.0.0.2')
|
||||||
|
|
||||||
@ -527,15 +528,15 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
func.return_value = new_router
|
func.return_value = new_router
|
||||||
self.l3_inst.update_router(self.context, router_id,
|
self.l3_inst.update_router(self.context, router_id,
|
||||||
{'router': updated_data})
|
{'router': updated_data})
|
||||||
self.l3_inst._ovn.add_static_route.assert_not_called()
|
self.l3_inst._nb_ovn.add_static_route.assert_not_called()
|
||||||
self.l3_inst._ovn.delete_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.delete_static_route.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
ip_prefix='1.1.1.0/24', nexthop='10.0.0.2')
|
ip_prefix='1.1.1.0/24', nexthop='10.0.0.2')
|
||||||
|
|
||||||
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.'
|
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.'
|
||||||
'ovn_client.OVNClient._get_v4_network_of_all_router_ports')
|
'ovn_client.OVNClient._get_v4_network_of_all_router_ports')
|
||||||
def test_create_router_with_ext_gw(self, get_rps):
|
def test_create_router_with_ext_gw(self, get_rps):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
router = {'router': {'name': 'router'}}
|
router = {'router': {'name': 'router'}}
|
||||||
self.get_subnet.return_value = self.fake_ext_subnet
|
self.get_subnet.return_value = self.fake_ext_subnet
|
||||||
self.get_port.return_value = self.fake_ext_gw_port
|
self.get_port.return_value = self.fake_ext_gw_port
|
||||||
@ -547,11 +548,11 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
||||||
ovn_const.OVN_GW_PORT_EXT_ID_KEY: 'gw-port-id',
|
ovn_const.OVN_GW_PORT_EXT_ID_KEY: 'gw-port-id',
|
||||||
ovn_const.OVN_AZ_HINTS_EXT_ID_KEY: ''}
|
ovn_const.OVN_AZ_HINTS_EXT_ID_KEY: ''}
|
||||||
self.l3_inst._ovn.create_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.create_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', external_ids=external_ids,
|
'neutron-router-id', external_ids=external_ids,
|
||||||
enabled=True, options={'always_learn_from_arp_request': 'false',
|
enabled=True, options={'always_learn_from_arp_request': 'false',
|
||||||
'dynamic_neigh_routers': 'true'})
|
'dynamic_neigh_routers': 'true'})
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**self.fake_ext_gw_port_assert)
|
**self.fake_ext_gw_port_assert)
|
||||||
expected_calls = [
|
expected_calls = [
|
||||||
mock.call('neutron-router-id', ip_prefix='0.0.0.0/0',
|
mock.call('neutron-router-id', ip_prefix='0.0.0.0/0',
|
||||||
@ -559,11 +560,11 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
external_ids={
|
external_ids={
|
||||||
ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'})]
|
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'})]
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_static_route.assert_has_calls(expected_calls)
|
self.l3_inst._nb_ovn.add_static_route.assert_has_calls(expected_calls)
|
||||||
|
|
||||||
bump_rev_calls = [mock.call(mock.ANY, self.fake_ext_gw_port,
|
bump_rev_calls = [mock.call(mock.ANY, self.fake_ext_gw_port,
|
||||||
ovn_const.TYPE_ROUTER_PORTS),
|
ovn_const.TYPE_ROUTER_PORTS),
|
||||||
@ -583,7 +584,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
|
|
||||||
self.l3_inst.delete_router(self.context, 'router-id')
|
self.l3_inst.delete_router(self.context, 'router-id')
|
||||||
|
|
||||||
self.l3_inst._ovn.delete_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.delete_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id')
|
'neutron-router-id')
|
||||||
|
|
||||||
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
||||||
@ -598,13 +599,13 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.add_router_interface(self.context, router_id,
|
self.l3_inst.add_router_interface(self.context, router_id,
|
||||||
interface_info)
|
interface_info)
|
||||||
|
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**self.fake_router_port_assert)
|
**self.fake_router_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', logical_ip='10.0.0.0/24',
|
'neutron-router-id', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1', type='snat')
|
external_ip='192.168.1.1', type='snat')
|
||||||
self.bump_rev_p.assert_called_with(
|
self.bump_rev_p.assert_called_with(
|
||||||
@ -626,13 +627,13 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.add_router_interface(self.context, router_id,
|
self.l3_inst.add_router_interface(self.context, router_id,
|
||||||
interface_info)
|
interface_info)
|
||||||
|
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**self.fake_router_port_assert)
|
**self.fake_router_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_not_called()
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_not_called()
|
||||||
|
|
||||||
@mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_network')
|
@mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_network')
|
||||||
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
||||||
@ -658,13 +659,13 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
fake_router_port_assert['options'] = {
|
fake_router_port_assert['options'] = {
|
||||||
'reside-on-redirect-chassis': 'true'}
|
'reside-on-redirect-chassis': 'true'}
|
||||||
|
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**fake_router_port_assert)
|
**fake_router_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
'router-port-id', 'lrp-router-port-id', is_gw_port=False,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', logical_ip='10.0.0.0/24',
|
'neutron-router-id', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1', type='snat')
|
external_ip='192.168.1.1', type='snat')
|
||||||
|
|
||||||
@ -681,9 +682,10 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
port_id='router-port-id')
|
port_id='router-port-id')
|
||||||
self.l3_inst.remove_router_interface(
|
self.l3_inst.remove_router_interface(
|
||||||
self.context, router_id, interface_info)
|
self.context, router_id, interface_info)
|
||||||
self.l3_inst._ovn.lrp_del.assert_called_once_with(
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
|
nb_ovn.lrp_del.assert_called_once_with(
|
||||||
'lrp-router-port-id', 'neutron-router-id', if_exists=True)
|
'lrp-router-port-id', 'neutron-router-id', if_exists=True)
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
nb_ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', logical_ip='10.0.0.0/24',
|
'neutron-router-id', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1', type='snat')
|
external_ip='192.168.1.1', type='snat')
|
||||||
self.del_rev_p.assert_called_with(
|
self.del_rev_p.assert_called_with(
|
||||||
@ -694,7 +696,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
||||||
'update_router')
|
'update_router')
|
||||||
def test_update_router_with_ext_gw(self, ur, grps):
|
def test_update_router_with_ext_gw(self, ur, grps):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
router = {'router': {'name': 'router'}}
|
router = {'router': {'name': 'router'}}
|
||||||
self.get_router.return_value = self.fake_router_without_ext_gw
|
self.get_router.return_value = self.fake_router_without_ext_gw
|
||||||
ur.return_value = self.fake_router_with_ext_gw
|
ur.return_value = self.fake_router_with_ext_gw
|
||||||
@ -705,18 +707,18 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
|
|
||||||
self.l3_inst.update_router(self.context, 'router-id', router)
|
self.l3_inst.update_router(self.context, 'router-id', router)
|
||||||
|
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**self.fake_ext_gw_port_assert)
|
**self.fake_ext_gw_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_static_route.assert_called_once_with(
|
||||||
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
||||||
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'},
|
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'},
|
||||||
nexthop='192.168.1.254')
|
nexthop='192.168.1.254')
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', type='snat',
|
'neutron-router-id', type='snat',
|
||||||
logical_ip='10.0.0.0/24', external_ip='192.168.1.1')
|
logical_ip='10.0.0.0/24', external_ip='192.168.1.1')
|
||||||
self.bump_rev_p.assert_called_with(
|
self.bump_rev_p.assert_called_with(
|
||||||
@ -730,7 +732,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
'update_router')
|
'update_router')
|
||||||
def test_update_router_ext_gw_change_subnet(self, ur,
|
def test_update_router_ext_gw_change_subnet(self, ur,
|
||||||
grps, mock_get_gw):
|
grps, mock_get_gw):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
mock_get_gw.return_value = [mock.sentinel.GwRoute]
|
mock_get_gw.return_value = [mock.sentinel.GwRoute]
|
||||||
router = {'router': {'name': 'router'}}
|
router = {'router': {'name': 'router'}}
|
||||||
fake_old_ext_subnet = {'id': 'old-ext-subnet-id',
|
fake_old_ext_subnet = {'id': 'old-ext-subnet-id',
|
||||||
@ -755,22 +757,22 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.update_router(self.context, 'router-id', router)
|
self.l3_inst.update_router(self.context, 'router-id', router)
|
||||||
|
|
||||||
# Check deleting old router gateway
|
# Check deleting old router gateway
|
||||||
self.l3_inst._ovn.delete_lrouter_ext_gw.assert_called_once_with(
|
self.l3_inst._nb_ovn.delete_lrouter_ext_gw.assert_called_once_with(
|
||||||
'neutron-router-id')
|
'neutron-router-id')
|
||||||
|
|
||||||
# Check adding new router gateway
|
# Check adding new router gateway
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**self.fake_ext_gw_port_assert)
|
**self.fake_ext_gw_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_static_route.assert_called_once_with(
|
||||||
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
||||||
nexthop='192.168.1.254',
|
nexthop='192.168.1.254',
|
||||||
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'})
|
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'})
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1')
|
external_ip='192.168.1.1')
|
||||||
|
|
||||||
@ -787,7 +789,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
'update_router')
|
'update_router')
|
||||||
def test_update_router_ext_gw_change_ip_address(self, ur,
|
def test_update_router_ext_gw_change_ip_address(self, ur,
|
||||||
grps, mock_get_gw):
|
grps, mock_get_gw):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
mock_get_gw.return_value = [mock.sentinel.GwRoute]
|
mock_get_gw.return_value = [mock.sentinel.GwRoute]
|
||||||
router = {'router': {'name': 'router'}}
|
router = {'router': {'name': 'router'}}
|
||||||
# Old gateway info with same subnet and different ip address
|
# Old gateway info with same subnet and different ip address
|
||||||
@ -805,21 +807,21 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.update_router(self.context, 'router-id', router)
|
self.l3_inst.update_router(self.context, 'router-id', router)
|
||||||
|
|
||||||
# Check deleting old router gateway
|
# Check deleting old router gateway
|
||||||
self.l3_inst._ovn.delete_lrouter_ext_gw.assert_called_once_with(
|
self.l3_inst._nb_ovn.delete_lrouter_ext_gw.assert_called_once_with(
|
||||||
'neutron-router-id')
|
'neutron-router-id')
|
||||||
# Check adding new router gateway
|
# Check adding new router gateway
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**self.fake_ext_gw_port_assert)
|
**self.fake_ext_gw_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
'gw-port-id', 'lrp-gw-port-id', is_gw_port=True,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_static_route.assert_called_once_with(
|
||||||
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
||||||
nexthop='192.168.1.254',
|
nexthop='192.168.1.254',
|
||||||
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'})
|
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'})
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1')
|
external_ip='192.168.1.1')
|
||||||
|
|
||||||
@ -829,28 +831,29 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
'update_router')
|
'update_router')
|
||||||
def test_update_router_ext_gw_no_change(self, ur, get_rps):
|
def test_update_router_ext_gw_no_change(self, ur, get_rps):
|
||||||
router = {'router': {'name': 'router'}}
|
router = {'router': {'name': 'router'}}
|
||||||
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
self.get_router.return_value = self.fake_router_with_ext_gw
|
self.get_router.return_value = self.fake_router_with_ext_gw
|
||||||
ur.return_value = self.fake_router_with_ext_gw
|
ur.return_value = self.fake_router_with_ext_gw
|
||||||
self.l3_inst._ovn.get_lrouter.return_value = (
|
nb_ovn.get_lrouter.return_value = (
|
||||||
fake_resources.FakeOVNRouter.from_neutron_router(
|
fake_resources.FakeOVNRouter.from_neutron_router(
|
||||||
self.fake_router_with_ext_gw))
|
self.fake_router_with_ext_gw))
|
||||||
|
|
||||||
self.l3_inst.update_router(self.context, 'router-id', router)
|
self.l3_inst.update_router(self.context, 'router-id', router)
|
||||||
|
|
||||||
self.l3_inst._ovn.lrp_del.assert_not_called()
|
nb_ovn.lrp_del.assert_not_called()
|
||||||
self.l3_inst._ovn.delete_static_route.assert_not_called()
|
nb_ovn.delete_static_route.assert_not_called()
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
nb_ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_not_called()
|
nb_ovn.add_lrouter_port.assert_not_called()
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.assert_not_called()
|
nb_ovn.set_lrouter_port_in_lswitch_port.assert_not_called()
|
||||||
self.l3_inst._ovn.add_static_route.assert_not_called()
|
nb_ovn.add_static_route.assert_not_called()
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_not_called()
|
nb_ovn.add_nat_rule_in_lrouter.assert_not_called()
|
||||||
|
|
||||||
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
||||||
'.OVNClient._get_v4_network_of_all_router_ports')
|
'.OVNClient._get_v4_network_of_all_router_ports')
|
||||||
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
||||||
'update_router')
|
'update_router')
|
||||||
def test_update_router_with_ext_gw_and_disabled_snat(self, ur, grps):
|
def test_update_router_with_ext_gw_and_disabled_snat(self, ur, grps):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
router = {'router': {'name': 'router'}}
|
router = {'router': {'name': 'router'}}
|
||||||
self.get_router.return_value = self.fake_router_without_ext_gw
|
self.get_router.return_value = self.fake_router_without_ext_gw
|
||||||
ur.return_value = self.fake_router_with_ext_gw
|
ur.return_value = self.fake_router_with_ext_gw
|
||||||
@ -863,12 +866,12 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
self.l3_inst.update_router(self.context, 'router-id', router)
|
self.l3_inst.update_router(self.context, 'router-id', router)
|
||||||
|
|
||||||
# Need not check lsp and lrp here, it has been tested in other cases
|
# Need not check lsp and lrp here, it has been tested in other cases
|
||||||
self.l3_inst._ovn.add_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_static_route.assert_called_once_with(
|
||||||
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
'neutron-router-id', ip_prefix='0.0.0.0/0',
|
||||||
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
external_ids={ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'},
|
ovn_const.OVN_SUBNET_EXT_ID_KEY: 'ext-subnet-id'},
|
||||||
nexthop='192.168.1.254')
|
nexthop='192.168.1.254')
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_not_called()
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_not_called()
|
||||||
|
|
||||||
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.ovn_client'
|
||||||
'.OVNClient._get_router_ports')
|
'.OVNClient._get_router_ports')
|
||||||
@ -880,7 +883,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
gr_value['external_gateway_info']['enable_snat'] = False
|
gr_value['external_gateway_info']['enable_snat'] = False
|
||||||
self.get_router.return_value = gr_value
|
self.get_router.return_value = gr_value
|
||||||
ur.return_value = self.fake_router_with_ext_gw
|
ur.return_value = self.fake_router_with_ext_gw
|
||||||
self.l3_inst._ovn.get_lrouter.return_value = (
|
self.l3_inst._nb_ovn.get_lrouter.return_value = (
|
||||||
fake_resources.FakeOVNRouter.from_neutron_router(
|
fake_resources.FakeOVNRouter.from_neutron_router(
|
||||||
self.fake_router_with_ext_gw))
|
self.fake_router_with_ext_gw))
|
||||||
self.get_subnet.side_effect = lambda ctx, sid: {
|
self.get_subnet.side_effect = lambda ctx, sid: {
|
||||||
@ -890,10 +893,10 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
|
|
||||||
self.l3_inst.update_router(self.context, 'router-id', router)
|
self.l3_inst.update_router(self.context, 'router-id', router)
|
||||||
|
|
||||||
self.l3_inst._ovn.delete_static_route.assert_not_called()
|
self.l3_inst._nb_ovn.delete_static_route.assert_not_called()
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
self.l3_inst._nb_ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
||||||
self.l3_inst._ovn.add_static_route.assert_not_called()
|
self.l3_inst._nb_ovn.add_static_route.assert_not_called()
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1')
|
external_ip='192.168.1.1')
|
||||||
|
|
||||||
@ -921,15 +924,16 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
|
|
||||||
self.l3_inst.update_router(self.context, 'router-id', router)
|
self.l3_inst.update_router(self.context, 'router-id', router)
|
||||||
|
|
||||||
self.l3_inst._ovn.delete_static_route.assert_not_called()
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
nb_ovn.delete_static_route.assert_not_called()
|
||||||
|
nb_ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
'neutron-router-id', type='snat', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1')
|
external_ip='192.168.1.1')
|
||||||
self.l3_inst._ovn.add_static_route.assert_not_called()
|
nb_ovn.add_static_route.assert_not_called()
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_not_called()
|
nb_ovn.add_nat_rule_in_lrouter.assert_not_called()
|
||||||
|
|
||||||
def test_create_floatingip(self):
|
def test_create_floatingip(self):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
||||||
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||||
expected_ext_ids = {
|
expected_ext_ids = {
|
||||||
@ -942,7 +946,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -952,7 +956,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
options={'stateless': 'true'})
|
options={'stateless': 'true'})
|
||||||
|
|
||||||
def test_create_floatingip_distributed(self):
|
def test_create_floatingip_distributed(self):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self.get_port.return_value = {'mac_address': '00:01:02:03:04:05',
|
self.get_port.return_value = {'mac_address': '00:01:02:03:04:05',
|
||||||
'network_id': 'port-network-id'}
|
'network_id': 'port-network-id'}
|
||||||
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
||||||
@ -969,7 +973,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: '00:01:02:03:04:05',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: '00:01:02:03:04:05',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', type='dnat_and_snat', logical_ip='10.0.0.10',
|
'neutron-router-id', type='dnat_and_snat', logical_ip='10.0.0.10',
|
||||||
external_ip='192.168.0.10', external_mac='00:01:02:03:04:05',
|
external_ip='192.168.0.10', external_mac='00:01:02:03:04:05',
|
||||||
logical_port='port_id',
|
logical_port='port_id',
|
||||||
@ -980,8 +984,8 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
# Check that when the port is down, the external_mac field is not
|
# Check that when the port is down, the external_mac field is not
|
||||||
# populated. This falls back to centralized routing for ports that
|
# populated. This falls back to centralized routing for ports that
|
||||||
# are not bound to a chassis.
|
# are not bound to a chassis.
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self.l3_inst._ovn.lsp_get_up.return_value.execute.return_value = (
|
self.l3_inst._nb_ovn.lsp_get_up.return_value.execute.return_value = (
|
||||||
False)
|
False)
|
||||||
self.get_port.return_value = {'mac_address': '00:01:02:03:04:05'}
|
self.get_port.return_value = {'mac_address': '00:01:02:03:04:05'}
|
||||||
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
||||||
@ -998,7 +1002,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: '00:01:02:03:04:05',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: '00:01:02:03:04:05',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', type='dnat_and_snat', logical_ip='10.0.0.10',
|
'neutron-router-id', type='dnat_and_snat', logical_ip='10.0.0.10',
|
||||||
external_ip='192.168.0.10',
|
external_ip='192.168.0.10',
|
||||||
logical_port='port_id',
|
logical_port='port_id',
|
||||||
@ -1006,9 +1010,9 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
options={'stateless': 'true'})
|
options={'stateless': 'true'})
|
||||||
|
|
||||||
def test_create_floatingip_external_ip_present_in_nat_rule(self):
|
def test_create_floatingip_external_ip_present_in_nat_rule(self):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
||||||
self.l3_inst._ovn.get_lrouter_nat_rules.return_value = [
|
self.l3_inst._nb_ovn.get_lrouter_nat_rules.return_value = [
|
||||||
{'external_ip': '192.168.0.10', 'logical_ip': '10.0.0.6',
|
{'external_ip': '192.168.0.10', 'logical_ip': '10.0.0.6',
|
||||||
'type': 'dnat_and_snat', 'uuid': 'uuid1'}]
|
'type': 'dnat_and_snat', 'uuid': 'uuid1'}]
|
||||||
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||||
@ -1022,7 +1026,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -1032,13 +1036,13 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
options={'stateless': 'true'})
|
options={'stateless': 'true'})
|
||||||
|
|
||||||
def test_create_floatingip_external_ip_present_type_snat(self):
|
def test_create_floatingip_external_ip_present_type_snat(self):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
self._get_floatingip.return_value = {'floating_port_id': 'fip-port-id'}
|
||||||
self.l3_inst._ovn.get_lrouter_nat_rules.return_value = [
|
self.l3_inst._nb_ovn.get_lrouter_nat_rules.return_value = [
|
||||||
{'external_ip': '192.168.0.10', 'logical_ip': '10.0.0.0/24',
|
{'external_ip': '192.168.0.10', 'logical_ip': '10.0.0.0/24',
|
||||||
'type': 'snat', 'uuid': 'uuid1'}]
|
'type': 'snat', 'uuid': 'uuid1'}]
|
||||||
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||||
self.l3_inst._ovn.set_nat_rule_in_lrouter.assert_not_called()
|
self.l3_inst._nb_ovn.set_nat_rule_in_lrouter.assert_not_called()
|
||||||
expected_ext_ids = {
|
expected_ext_ids = {
|
||||||
ovn_const.OVN_FIP_EXT_ID_KEY: self.fake_floating_ip['id'],
|
ovn_const.OVN_FIP_EXT_ID_KEY: self.fake_floating_ip['id'],
|
||||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
||||||
@ -1049,7 +1053,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -1061,14 +1065,14 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
def test_create_floatingip_lsp_external_id(self):
|
def test_create_floatingip_lsp_external_id(self):
|
||||||
foo_lport = fake_resources.FakeOvsdbRow.create_one_ovsdb_row()
|
foo_lport = fake_resources.FakeOvsdbRow.create_one_ovsdb_row()
|
||||||
foo_lport.uuid = 'foo-port'
|
foo_lport.uuid = 'foo-port'
|
||||||
self.l3_inst._ovn.get_lswitch_port.return_value = foo_lport
|
self.l3_inst._nb_ovn.get_lswitch_port.return_value = foo_lport
|
||||||
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||||
calls = [mock.call(
|
calls = [mock.call(
|
||||||
'Logical_Switch_Port',
|
'Logical_Switch_Port',
|
||||||
'foo-port',
|
'foo-port',
|
||||||
('external_ids', {ovn_const.OVN_PORT_FIP_EXT_ID_KEY:
|
('external_ids', {ovn_const.OVN_PORT_FIP_EXT_ID_KEY:
|
||||||
'192.168.0.10'}))]
|
'192.168.0.10'}))]
|
||||||
self.l3_inst._ovn.db_set.assert_has_calls(calls)
|
self.l3_inst._nb_ovn.db_set.assert_has_calls(calls)
|
||||||
|
|
||||||
def test_create_floatingip_lb_member_fip(self):
|
def test_create_floatingip_lb_member_fip(self):
|
||||||
config.cfg.CONF.set_override(
|
config.cfg.CONF.set_override(
|
||||||
@ -1076,9 +1080,9 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
# Stop this mock.
|
# Stop this mock.
|
||||||
self.mock_is_lb_member_fip.stop()
|
self.mock_is_lb_member_fip.stop()
|
||||||
self.get_port.return_value = self.member_port
|
self.get_port.return_value = self.member_port
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self.l3_inst._ovn.lookup.return_value = self.lb_network
|
self.l3_inst._nb_ovn.lookup.return_value = self.lb_network
|
||||||
self.l3_inst._ovn.get_lswitch_port.return_value = self.member_lsp
|
self.l3_inst._nb_ovn.get_lswitch_port.return_value = self.member_lsp
|
||||||
fip = self.l3_inst.create_floatingip(self.context, 'floatingip')
|
fip = self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||||
# Validate that there is no external_mac and logical_port while
|
# Validate that there is no external_mac and logical_port while
|
||||||
# setting the NAT entry.
|
# setting the NAT entry.
|
||||||
@ -1089,7 +1093,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY: 'neutron-router-id',
|
ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY: 'neutron-router-id',
|
||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: self.member_port['mac_address'],
|
ovn_const.OVN_FIP_EXT_MAC_KEY: self.member_port['mac_address'],
|
||||||
ovn_const.OVN_FIP_NET_ID: fip['floating_network_id']}
|
ovn_const.OVN_FIP_NET_ID: fip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
external_ip='192.168.0.10',
|
external_ip='192.168.0.10',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -1101,14 +1105,14 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
config.cfg.CONF.set_override(
|
config.cfg.CONF.set_override(
|
||||||
'enable_distributed_floating_ip', True, group='ovn')
|
'enable_distributed_floating_ip', True, group='ovn')
|
||||||
self.get_subnet.return_value = self.member_subnet
|
self.get_subnet.return_value = self.member_subnet
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self.l3_inst._ovn.get_lswitch_port.return_value = self.lb_vip_lsp
|
self.l3_inst._nb_ovn.get_lswitch_port.return_value = self.lb_vip_lsp
|
||||||
self.l3_inst._ovn.db_find_rows.return_value.execute.side_effect = [
|
self.l3_inst._nb_ovn.db_find_rows.return_value.execute.side_effect = [
|
||||||
[self.ovn_lb],
|
[self.ovn_lb],
|
||||||
[self.lb_network],
|
[self.lb_network],
|
||||||
[self.fake_ovn_nat_rule],
|
[self.fake_ovn_nat_rule],
|
||||||
]
|
]
|
||||||
self.l3_inst._ovn.lookup.return_value = self.lb_network
|
self.l3_inst._nb_ovn.lookup.return_value = self.lb_network
|
||||||
fip = self.l3_inst.create_floatingip(self.context, 'floatingip')
|
fip = self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||||
expected_ext_ids = {
|
expected_ext_ids = {
|
||||||
ovn_const.OVN_FIP_EXT_ID_KEY: fip['id'],
|
ovn_const.OVN_FIP_EXT_ID_KEY: fip['id'],
|
||||||
@ -1118,7 +1122,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: self.member_port['mac_address'],
|
ovn_const.OVN_FIP_EXT_MAC_KEY: self.member_port['mac_address'],
|
||||||
ovn_const.OVN_FIP_NET_ID: fip['floating_network_id']}
|
ovn_const.OVN_FIP_NET_ID: fip['floating_network_id']}
|
||||||
|
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
external_ip='192.168.0.10',
|
external_ip='192.168.0.10',
|
||||||
external_mac='aa:aa:aa:aa:aa:aa',
|
external_mac='aa:aa:aa:aa:aa:aa',
|
||||||
@ -1127,20 +1131,21 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
external_ids=expected_ext_ids,
|
external_ids=expected_ext_ids,
|
||||||
options={'stateless': 'true'})
|
options={'stateless': 'true'})
|
||||||
self.l3_inst._ovn.db_find_rows.assert_called_with(
|
self.l3_inst._nb_ovn.db_find_rows.assert_called_with(
|
||||||
'NAT', ('external_ids', '=', {ovn_const.OVN_FIP_PORT_EXT_ID_KEY:
|
'NAT', ('external_ids', '=', {ovn_const.OVN_FIP_PORT_EXT_ID_KEY:
|
||||||
self.member_lsp.name}))
|
self.member_lsp.name}))
|
||||||
# Validate that it clears external_mac/logical_port for member NAT.
|
# Validate that it clears external_mac/logical_port for member NAT.
|
||||||
self.l3_inst._ovn.db_clear.assert_has_calls([
|
self.l3_inst._nb_ovn.db_clear.assert_has_calls([
|
||||||
mock.call('NAT', self.fake_ovn_nat_rule.uuid, 'external_mac'),
|
mock.call('NAT', self.fake_ovn_nat_rule.uuid, 'external_mac'),
|
||||||
mock.call('NAT', self.fake_ovn_nat_rule.uuid, 'logical_port')])
|
mock.call('NAT', self.fake_ovn_nat_rule.uuid, 'logical_port')])
|
||||||
|
|
||||||
@mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_floatingip')
|
@mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_floatingip')
|
||||||
def test_delete_floatingip(self, df):
|
def test_delete_floatingip(self, df):
|
||||||
self.l3_inst._ovn.get_floatingip.return_value = (
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
|
nb_ovn.get_floatingip.return_value = (
|
||||||
self.fake_ovn_nat_rule)
|
self.fake_ovn_nat_rule)
|
||||||
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
nb_ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -1151,29 +1156,30 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
config.cfg.CONF.set_override(
|
config.cfg.CONF.set_override(
|
||||||
'enable_distributed_floating_ip', True, group='ovn')
|
'enable_distributed_floating_ip', True, group='ovn')
|
||||||
self.get_subnet.return_value = self.member_subnet
|
self.get_subnet.return_value = self.member_subnet
|
||||||
self.l3_inst._ovn.get_floatingip.return_value = (
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
|
nb_ovn.get_floatingip.return_value = (
|
||||||
self.fake_ovn_nat_rule)
|
self.fake_ovn_nat_rule)
|
||||||
self.l3_inst._ovn.get_lswitch_port.return_value = self.lb_vip_lsp
|
nb_ovn.get_lswitch_port.return_value = self.lb_vip_lsp
|
||||||
self.l3_inst._ovn.db_find_rows.return_value.execute.side_effect = [
|
nb_ovn.db_find_rows.return_value.execute.side_effect = [
|
||||||
[self.ovn_lb],
|
[self.ovn_lb],
|
||||||
[self.lb_network],
|
[self.lb_network],
|
||||||
[self.fake_ovn_nat_rule],
|
[self.fake_ovn_nat_rule],
|
||||||
]
|
]
|
||||||
self.l3_inst._ovn.lookup.return_value = self.lb_network
|
nb_ovn.lookup.return_value = self.lb_network
|
||||||
|
|
||||||
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
nb_ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
external_ip='192.168.0.10')
|
external_ip='192.168.0.10')
|
||||||
self.l3_inst._ovn.db_find_rows.assert_called_with(
|
nb_ovn.db_find_rows.assert_called_with(
|
||||||
'NAT', ('external_ids', '=',
|
'NAT', ('external_ids', '=',
|
||||||
{ovn_const.OVN_FIP_PORT_EXT_ID_KEY: self.member_lsp.name}))
|
{ovn_const.OVN_FIP_PORT_EXT_ID_KEY: self.member_lsp.name}))
|
||||||
self.l3_inst._plugin.get_port.assert_called_once_with(
|
self.l3_inst._plugin.get_port.assert_called_once_with(
|
||||||
mock.ANY, self.member_lsp.name)
|
mock.ANY, self.member_lsp.name)
|
||||||
# Validate that it adds external_mac/logical_port back.
|
# Validate that it adds external_mac/logical_port back.
|
||||||
self.l3_inst._ovn.db_set.assert_has_calls([
|
nb_ovn.db_set.assert_has_calls([
|
||||||
mock.call('NAT', self.fake_ovn_nat_rule.uuid,
|
mock.call('NAT', self.fake_ovn_nat_rule.uuid,
|
||||||
('logical_port', self.member_lsp.name)),
|
('logical_port', self.member_lsp.name)),
|
||||||
mock.call('NAT', self.fake_ovn_nat_rule.uuid,
|
mock.call('NAT', self.fake_ovn_nat_rule.uuid,
|
||||||
@ -1181,38 +1187,39 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
|
|
||||||
@mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_floatingip')
|
@mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_floatingip')
|
||||||
def test_delete_floatingip_lsp_external_id(self, df):
|
def test_delete_floatingip_lsp_external_id(self, df):
|
||||||
self.l3_inst._ovn.get_floatingip.return_value = (
|
self.l3_inst._nb_ovn.get_floatingip.return_value = (
|
||||||
self.fake_ovn_nat_rule)
|
self.fake_ovn_nat_rule)
|
||||||
|
|
||||||
foo_lport = fake_resources.FakeOvsdbRow.create_one_ovsdb_row()
|
foo_lport = fake_resources.FakeOvsdbRow.create_one_ovsdb_row()
|
||||||
foo_lport.uuid = 'foo-port'
|
foo_lport.uuid = 'foo-port'
|
||||||
foo_lport.external_ids = {
|
foo_lport.external_ids = {
|
||||||
ovn_const.OVN_PORT_FIP_EXT_ID_KEY: 'foo-port'}
|
ovn_const.OVN_PORT_FIP_EXT_ID_KEY: 'foo-port'}
|
||||||
self.l3_inst._ovn.get_lswitch_port.return_value = foo_lport
|
self.l3_inst._nb_ovn.get_lswitch_port.return_value = foo_lport
|
||||||
|
|
||||||
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
||||||
calls = [mock.call(
|
calls = [mock.call(
|
||||||
'Logical_Switch_Port', 'foo-port',
|
'Logical_Switch_Port', 'foo-port',
|
||||||
'external_ids', ovn_const.OVN_PORT_FIP_EXT_ID_KEY)]
|
'external_ids', ovn_const.OVN_PORT_FIP_EXT_ID_KEY)]
|
||||||
self.l3_inst._ovn.db_remove.assert_has_calls(calls)
|
self.l3_inst._nb_ovn.db_remove.assert_has_calls(calls)
|
||||||
|
|
||||||
@mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_floatingip')
|
@mock.patch('neutron.db.l3_db.L3_NAT_dbonly_mixin.delete_floatingip')
|
||||||
def test_delete_floatingip_no_lsp_external_id(self, df):
|
def test_delete_floatingip_no_lsp_external_id(self, df):
|
||||||
self.l3_inst._ovn.get_floatingip.return_value = (
|
self.l3_inst._nb_ovn.get_floatingip.return_value = (
|
||||||
self.fake_ovn_nat_rule)
|
self.fake_ovn_nat_rule)
|
||||||
self.l3_inst._ovn.get_lswitch_port.return_value = None
|
self.l3_inst._nb_ovn.get_lswitch_port.return_value = None
|
||||||
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
self.l3_inst.delete_floatingip(self.context, 'floatingip-id')
|
||||||
self.l3_inst._ovn.db_remove.assert_not_called()
|
self.l3_inst._nb_ovn.db_remove.assert_not_called()
|
||||||
|
|
||||||
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
||||||
'update_floatingip')
|
'update_floatingip')
|
||||||
def test_update_floatingip(self, uf):
|
def test_update_floatingip(self, uf):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
|
nb_ovn.is_col_present.return_value = True
|
||||||
uf.return_value = self.fake_floating_ip_new
|
uf.return_value = self.fake_floating_ip_new
|
||||||
self.l3_inst._ovn.get_floatingip.return_value = (
|
nb_ovn.get_floatingip.return_value = (
|
||||||
self.fake_ovn_nat_rule)
|
self.fake_ovn_nat_rule)
|
||||||
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
nb_ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -1227,7 +1234,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-new-router-id',
|
'neutron-new-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.10.10.10',
|
logical_ip='10.10.10.10',
|
||||||
@ -1239,11 +1246,11 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
||||||
'update_floatingip')
|
'update_floatingip')
|
||||||
def test_update_floatingip_associate(self, uf):
|
def test_update_floatingip_associate(self, uf):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self.fake_floating_ip.update({'fixed_port_id': None})
|
self.fake_floating_ip.update({'fixed_port_id': None})
|
||||||
uf.return_value = self.fake_floating_ip_new
|
uf.return_value = self.fake_floating_ip_new
|
||||||
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
self.l3_inst._nb_ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
||||||
expected_ext_ids = {
|
expected_ext_ids = {
|
||||||
ovn_const.OVN_FIP_EXT_ID_KEY: self.fake_floating_ip_new['id'],
|
ovn_const.OVN_FIP_EXT_ID_KEY: self.fake_floating_ip_new['id'],
|
||||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
||||||
@ -1254,7 +1261,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-new-router-id',
|
'neutron-new-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.10.10.10',
|
logical_ip='10.10.10.10',
|
||||||
@ -1267,7 +1274,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
||||||
'update_floatingip')
|
'update_floatingip')
|
||||||
def test_update_floatingip_associate_distributed(self, uf, gn):
|
def test_update_floatingip_associate_distributed(self, uf, gn):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
self.l3_inst._nb_ovn.is_col_present.return_value = True
|
||||||
self.fake_floating_ip.update({'fixed_port_id': None})
|
self.fake_floating_ip.update({'fixed_port_id': None})
|
||||||
self.get_port.return_value = {'mac_address': '00:01:02:03:04:05',
|
self.get_port.return_value = {'mac_address': '00:01:02:03:04:05',
|
||||||
'network_id': 'port-network-id'}
|
'network_id': 'port-network-id'}
|
||||||
@ -1280,7 +1287,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
config.cfg.CONF.set_override(
|
config.cfg.CONF.set_override(
|
||||||
'enable_distributed_floating_ip', True, group='ovn')
|
'enable_distributed_floating_ip', True, group='ovn')
|
||||||
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
self.l3_inst._nb_ovn.delete_nat_rule_in_lrouter.assert_not_called()
|
||||||
expected_ext_ids = {
|
expected_ext_ids = {
|
||||||
ovn_const.OVN_FIP_EXT_ID_KEY: self.fake_floating_ip_new['id'],
|
ovn_const.OVN_FIP_EXT_ID_KEY: self.fake_floating_ip_new['id'],
|
||||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
|
||||||
@ -1291,7 +1298,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: '00:01:02:03:04:05',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: '00:01:02:03:04:05',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-new-router-id', type='dnat_and_snat',
|
'neutron-new-router-id', type='dnat_and_snat',
|
||||||
logical_ip='10.10.10.10', external_ip='192.168.0.10',
|
logical_ip='10.10.10.10', external_ip='192.168.0.10',
|
||||||
external_mac='00:01:02:03:04:05', logical_port='new-port_id',
|
external_mac='00:01:02:03:04:05', logical_port='new-port_id',
|
||||||
@ -1300,14 +1307,15 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
@mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'
|
||||||
'update_floatingip')
|
'update_floatingip')
|
||||||
def test_update_floatingip_association_empty_update(self, uf):
|
def test_update_floatingip_association_empty_update(self, uf):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
self.l3_inst._ovn.get_floatingip.return_value = (
|
nb_ovn.is_col_present.return_value = True
|
||||||
|
nb_ovn.get_floatingip.return_value = (
|
||||||
self.fake_ovn_nat_rule)
|
self.fake_ovn_nat_rule)
|
||||||
self.fake_floating_ip.update({'fixed_port_id': 'foo'})
|
self.fake_floating_ip.update({'fixed_port_id': 'foo'})
|
||||||
self.fake_floating_ip_new.update({'port_id': 'foo'})
|
self.fake_floating_ip_new.update({'port_id': 'foo'})
|
||||||
uf.return_value = self.fake_floating_ip_new
|
uf.return_value = self.fake_floating_ip_new
|
||||||
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
nb_ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -1322,7 +1330,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-new-router-id',
|
'neutron-new-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.10.10.10',
|
logical_ip='10.10.10.10',
|
||||||
@ -1335,15 +1343,16 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
'update_floatingip')
|
'update_floatingip')
|
||||||
def test_update_floatingip_reassociate_to_same_port_diff_fixed_ip(
|
def test_update_floatingip_reassociate_to_same_port_diff_fixed_ip(
|
||||||
self, uf):
|
self, uf):
|
||||||
self.l3_inst._ovn.is_col_present.return_value = True
|
nb_ovn = self.l3_inst._nb_ovn
|
||||||
self.l3_inst._ovn.get_floatingip.return_value = (
|
nb_ovn.is_col_present.return_value = True
|
||||||
|
nb_ovn.get_floatingip.return_value = (
|
||||||
self.fake_ovn_nat_rule)
|
self.fake_ovn_nat_rule)
|
||||||
self.fake_floating_ip_new.update({'port_id': 'port_id',
|
self.fake_floating_ip_new.update({'port_id': 'port_id',
|
||||||
'fixed_port_id': 'port_id'})
|
'fixed_port_id': 'port_id'})
|
||||||
uf.return_value = self.fake_floating_ip_new
|
uf.return_value = self.fake_floating_ip_new
|
||||||
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
self.l3_inst.update_floatingip(self.context, 'id', 'floatingip')
|
||||||
|
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
nb_ovn.delete_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id',
|
'neutron-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.0.0.10',
|
logical_ip='10.0.0.10',
|
||||||
@ -1358,7 +1367,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
ovn_const.OVN_FIP_EXT_MAC_KEY: 'aa:aa:aa:aa:aa:aa',
|
||||||
ovn_const.OVN_FIP_NET_ID:
|
ovn_const.OVN_FIP_NET_ID:
|
||||||
self.fake_floating_ip['floating_network_id']}
|
self.fake_floating_ip['floating_network_id']}
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-new-router-id',
|
'neutron-new-router-id',
|
||||||
type='dnat_and_snat',
|
type='dnat_and_snat',
|
||||||
logical_ip='10.10.10.10',
|
logical_ip='10.10.10.10',
|
||||||
@ -1393,8 +1402,8 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
for fip in gfs.return_value]
|
for fip in gfs.return_value]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(delete_nat_calls),
|
len(delete_nat_calls),
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.call_count)
|
self.l3_inst._nb_ovn.delete_nat_rule_in_lrouter.call_count)
|
||||||
self.l3_inst._ovn.delete_nat_rule_in_lrouter.assert_has_calls(
|
self.l3_inst._nb_ovn.delete_nat_rule_in_lrouter.assert_has_calls(
|
||||||
delete_nat_calls, any_order=True)
|
delete_nat_calls, any_order=True)
|
||||||
|
|
||||||
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.'
|
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.'
|
||||||
@ -1597,13 +1606,13 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
ovn_const.OVN_ROUTER_PORT_GW_MTU_OPTION:
|
ovn_const.OVN_ROUTER_PORT_GW_MTU_OPTION:
|
||||||
str(prov_net['mtu'])}
|
str(prov_net['mtu'])}
|
||||||
|
|
||||||
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
|
||||||
**fake_router_port_assert)
|
**fake_router_port_assert)
|
||||||
self.l3_inst._ovn.set_lrouter_port_in_lswitch_port.\
|
self.l3_inst._nb_ovn.set_lrouter_port_in_lswitch_port.\
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
'router-port-id', 'lrp-router-port-id', is_gw_port=True,
|
'router-port-id', 'lrp-router-port-id', is_gw_port=True,
|
||||||
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
lsp_address=ovn_const.DEFAULT_ADDR_FOR_LSP_WITH_PEER)
|
||||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||||
'neutron-router-id', logical_ip='10.0.0.0/24',
|
'neutron-router-id', logical_ip='10.0.0.0/24',
|
||||||
external_ip='192.168.1.1', type='snat')
|
external_ip='192.168.1.1', type='snat')
|
||||||
|
|
||||||
@ -1615,7 +1624,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||||||
lr = fake_resources.FakeOvsdbRow.create_one_ovsdb_row(
|
lr = fake_resources.FakeOvsdbRow.create_one_ovsdb_row(
|
||||||
attrs={'id': 'fake-router', 'external_ids': {
|
attrs={'id': 'fake-router', 'external_ids': {
|
||||||
ovn_const.OVN_AZ_HINTS_EXT_ID_KEY: azs}})
|
ovn_const.OVN_AZ_HINTS_EXT_ID_KEY: azs}})
|
||||||
self.l3_inst._ovn.get_lrouter.return_value = lr
|
self.l3_inst._nb_ovn.get_lrouter.return_value = lr
|
||||||
azs_list = self.l3_inst.get_router_availability_zones(lr)
|
azs_list = self.l3_inst.get_router_availability_zones(lr)
|
||||||
self.assertEqual(sorted(expected), sorted(azs_list))
|
self.assertEqual(sorted(expected), sorted(azs_list))
|
||||||
|
|
||||||
@ -1690,7 +1699,7 @@ class OVNL3ExtrarouteTests(test_l3_gw.ExtGwModeIntTestCase,
|
|||||||
test_extensions.setup_extensions_middleware(l3_gw_mgr)
|
test_extensions.setup_extensions_middleware(l3_gw_mgr)
|
||||||
self.l3_inst = directory.get_plugin(plugin_constants.L3)
|
self.l3_inst = directory.get_plugin(plugin_constants.L3)
|
||||||
self._start_mock(
|
self._start_mock(
|
||||||
'neutron.services.ovn_l3.plugin.OVNL3RouterPlugin._ovn',
|
'neutron.services.ovn_l3.plugin.OVNL3RouterPlugin._nb_ovn',
|
||||||
new_callable=mock.PropertyMock,
|
new_callable=mock.PropertyMock,
|
||||||
return_value=fake_resources.FakeOvsdbNbOvnIdl())
|
return_value=fake_resources.FakeOvsdbNbOvnIdl())
|
||||||
self._start_mock(
|
self._start_mock(
|
||||||
@ -1744,9 +1753,9 @@ class OVNL3ExtrarouteTests(test_l3_gw.ExtGwModeIntTestCase,
|
|||||||
def test_update_subnet_gateway_for_external_net(self):
|
def test_update_subnet_gateway_for_external_net(self):
|
||||||
super(OVNL3ExtrarouteTests, self). \
|
super(OVNL3ExtrarouteTests, self). \
|
||||||
test_update_subnet_gateway_for_external_net()
|
test_update_subnet_gateway_for_external_net()
|
||||||
self.l3_inst._ovn.add_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.add_static_route.assert_called_once_with(
|
||||||
'neutron-fake_device', ip_prefix='0.0.0.0/0', nexthop='120.0.0.2')
|
'neutron-fake_device', ip_prefix='0.0.0.0/0', nexthop='120.0.0.2')
|
||||||
self.l3_inst._ovn.delete_static_route.assert_called_once_with(
|
self.l3_inst._nb_ovn.delete_static_route.assert_called_once_with(
|
||||||
'neutron-fake_device', ip_prefix='0.0.0.0/0', nexthop='120.0.0.1')
|
'neutron-fake_device', ip_prefix='0.0.0.0/0', nexthop='120.0.0.1')
|
||||||
|
|
||||||
def test_router_update_gateway_upon_subnet_create_max_ips_ipv6(self):
|
def test_router_update_gateway_upon_subnet_create_max_ips_ipv6(self):
|
||||||
@ -1760,5 +1769,5 @@ class OVNL3ExtrarouteTests(test_l3_gw.ExtGwModeIntTestCase,
|
|||||||
external_ids=expected_ext_ids),
|
external_ids=expected_ext_ids),
|
||||||
mock.call(mock.ANY, ip_prefix='::/0', nexthop='2001:db8::',
|
mock.call(mock.ANY, ip_prefix='::/0', nexthop='2001:db8::',
|
||||||
external_ids=expected_ext_ids)]
|
external_ids=expected_ext_ids)]
|
||||||
self.l3_inst._ovn.add_static_route.assert_has_calls(
|
self.l3_inst._nb_ovn.add_static_route.assert_has_calls(
|
||||||
add_static_route_calls, any_order=True)
|
add_static_route_calls, any_order=True)
|
||||||
|
@ -34,8 +34,8 @@ class TestOVNPortForwardingBase(base.BaseTestCase):
|
|||||||
super(TestOVNPortForwardingBase, self).setUp()
|
super(TestOVNPortForwardingBase, self).setUp()
|
||||||
self.context = mock.Mock()
|
self.context = mock.Mock()
|
||||||
self.l3_plugin = mock.Mock()
|
self.l3_plugin = mock.Mock()
|
||||||
self.l3_plugin._ovn = fake_resources.FakeOvsdbNbOvnIdl()
|
self.l3_plugin._nb_ovn = fake_resources.FakeOvsdbNbOvnIdl()
|
||||||
self.txn = self.l3_plugin._ovn.transaction
|
self.txn = self.l3_plugin._nb_ovn.transaction
|
||||||
|
|
||||||
def _fake_pf_obj(self, **kwargs):
|
def _fake_pf_obj(self, **kwargs):
|
||||||
pf_obj_defaults_dict = {
|
pf_obj_defaults_dict = {
|
||||||
@ -108,7 +108,7 @@ class TestOVNPortForwardingHandler(TestOVNPortForwardingBase):
|
|||||||
_get_lb_attributes(fake_pf_obj))
|
_get_lb_attributes(fake_pf_obj))
|
||||||
exp_protocol = self.handler._get_lb_protocol(fake_pf_obj)
|
exp_protocol = self.handler._get_lb_protocol(fake_pf_obj)
|
||||||
self.handler.port_forwarding_created(
|
self.handler.port_forwarding_created(
|
||||||
self.txn, self.l3_plugin._ovn, fake_pf_obj)
|
self.txn, self.l3_plugin._nb_ovn, fake_pf_obj)
|
||||||
info_args, _info_kwargs = m_info.call_args_list[0]
|
info_args, _info_kwargs = m_info.call_args_list[0]
|
||||||
self.assertIn('CREATE for port-forwarding', info_args[0])
|
self.assertIn('CREATE for port-forwarding', info_args[0])
|
||||||
self.assertEqual(2, len(self.txn.add.call_args_list))
|
self.assertEqual(2, len(self.txn.add.call_args_list))
|
||||||
@ -117,10 +117,10 @@ class TestOVNPortForwardingHandler(TestOVNPortForwardingBase):
|
|||||||
ovn_const.OVN_FIP_EXT_ID_KEY: fake_pf_obj.floatingip_id,
|
ovn_const.OVN_FIP_EXT_ID_KEY: fake_pf_obj.floatingip_id,
|
||||||
ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY: exp_rtr_name,
|
ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY: exp_rtr_name,
|
||||||
}
|
}
|
||||||
self.l3_plugin._ovn.lb_add.assert_called_once_with(
|
self.l3_plugin._nb_ovn.lb_add.assert_called_once_with(
|
||||||
exp_lb_name, exp_vip, exp_internal_ips, exp_protocol,
|
exp_lb_name, exp_vip, exp_internal_ips, exp_protocol,
|
||||||
may_exist=True, external_ids=exp_external_ids)
|
may_exist=True, external_ids=exp_external_ids)
|
||||||
self.l3_plugin._ovn.lr_lb_add.assert_called_once_with(
|
self.l3_plugin._nb_ovn.lr_lb_add.assert_called_once_with(
|
||||||
exp_rtr_name, exp_lb_name, may_exist=True)
|
exp_rtr_name, exp_lb_name, may_exist=True)
|
||||||
|
|
||||||
@mock.patch.object(port_forwarding.LOG, 'info')
|
@mock.patch.object(port_forwarding.LOG, 'info')
|
||||||
@ -132,12 +132,12 @@ class TestOVNPortForwardingHandler(TestOVNPortForwardingBase):
|
|||||||
fake_pf_obj = self._fake_pf_obj(protocol='udp')
|
fake_pf_obj = self._fake_pf_obj(protocol='udp')
|
||||||
fake_orig_pf_obj = self._fake_pf_obj(protocol='tcp')
|
fake_orig_pf_obj = self._fake_pf_obj(protocol='tcp')
|
||||||
self.handler.port_forwarding_updated(
|
self.handler.port_forwarding_updated(
|
||||||
self.txn, self.l3_plugin._ovn, fake_pf_obj, fake_orig_pf_obj)
|
self.txn, self.l3_plugin._nb_ovn, fake_pf_obj, fake_orig_pf_obj)
|
||||||
info_args, _info_kwargs = m_info.call_args_list[0]
|
info_args, _info_kwargs = m_info.call_args_list[0]
|
||||||
self.assertIn('UPDATE for port-forwarding', info_args[0])
|
self.assertIn('UPDATE for port-forwarding', info_args[0])
|
||||||
m_deleted.assert_called_once_with(self.txn, self.l3_plugin._ovn,
|
m_deleted.assert_called_once_with(self.txn, self.l3_plugin._nb_ovn,
|
||||||
fake_orig_pf_obj)
|
fake_orig_pf_obj)
|
||||||
m_created.assert_called_once_with(self.txn, self.l3_plugin._ovn,
|
m_created.assert_called_once_with(self.txn, self.l3_plugin._nb_ovn,
|
||||||
fake_pf_obj)
|
fake_pf_obj)
|
||||||
|
|
||||||
@mock.patch.object(port_forwarding.LOG, 'info')
|
@mock.patch.object(port_forwarding.LOG, 'info')
|
||||||
@ -146,11 +146,11 @@ class TestOVNPortForwardingHandler(TestOVNPortForwardingBase):
|
|||||||
exp_lb_name, exp_vip, _, _ = self.handler._get_lb_attributes(
|
exp_lb_name, exp_vip, _, _ = self.handler._get_lb_attributes(
|
||||||
fake_pf_obj)
|
fake_pf_obj)
|
||||||
self.handler.port_forwarding_deleted(
|
self.handler.port_forwarding_deleted(
|
||||||
self.txn, self.l3_plugin._ovn, fake_pf_obj)
|
self.txn, self.l3_plugin._nb_ovn, fake_pf_obj)
|
||||||
info_args, _info_kwargs = m_info.call_args_list[0]
|
info_args, _info_kwargs = m_info.call_args_list[0]
|
||||||
self.assertIn('DELETE for port-forwarding', info_args[0])
|
self.assertIn('DELETE for port-forwarding', info_args[0])
|
||||||
self.assertEqual(1, len(self.txn.add.call_args_list))
|
self.assertEqual(1, len(self.txn.add.call_args_list))
|
||||||
self.l3_plugin._ovn.lb_del.assert_called_once_with(
|
self.l3_plugin._nb_ovn.lb_del.assert_called_once_with(
|
||||||
exp_lb_name, exp_vip, if_exists=mock.ANY)
|
exp_lb_name, exp_vip, if_exists=mock.ANY)
|
||||||
|
|
||||||
|
|
||||||
@ -248,7 +248,8 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
mock_get_fip_objs.assert_called_once_with(self.context, payload)
|
mock_get_fip_objs.assert_called_once_with(self.context, payload)
|
||||||
if fip_objs:
|
if fip_objs:
|
||||||
calls = [
|
calls = [
|
||||||
mock.call(mock.ANY, self.l3_plugin._ovn, fip_id, fip_obj)
|
mock.call(mock.ANY, self.l3_plugin._nb_ovn, fip_id,
|
||||||
|
fip_obj)
|
||||||
for fip_id, fip_obj in fip_objs.items()]
|
for fip_id, fip_obj in fip_objs.items()]
|
||||||
self.fake_check_rev.assert_has_calls(calls)
|
self.fake_check_rev.assert_has_calls(calls)
|
||||||
self.fake_db_rev.assert_called_once_with(
|
self.fake_db_rev.assert_called_once_with(
|
||||||
@ -265,7 +266,7 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
self._handle_notification_common(events.AFTER_CREATE,
|
self._handle_notification_common(events.AFTER_CREATE,
|
||||||
fake_payload_entry)
|
fake_payload_entry)
|
||||||
self.handler.port_forwarding_created.assert_called_once_with(
|
self.handler.port_forwarding_created.assert_called_once_with(
|
||||||
mock.ANY, self.l3_plugin._ovn, fake_payload_entry.latest_state)
|
mock.ANY, self.l3_plugin._nb_ovn, fake_payload_entry.latest_state)
|
||||||
|
|
||||||
def test_handle_notification_create(self):
|
def test_handle_notification_create(self):
|
||||||
fip_objs = {1: {'description': 'one'},
|
fip_objs = {1: {'description': 'one'},
|
||||||
@ -275,7 +276,7 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
self._handle_notification_common(events.AFTER_CREATE,
|
self._handle_notification_common(events.AFTER_CREATE,
|
||||||
fake_payload,
|
fake_payload,
|
||||||
fip_objs)
|
fip_objs)
|
||||||
calls = [mock.call(mock.ANY, self.l3_plugin._ovn,
|
calls = [mock.call(mock.ANY, self.l3_plugin._nb_ovn,
|
||||||
fake_payload.latest_state)]
|
fake_payload.latest_state)]
|
||||||
self.handler.port_forwarding_created.assert_has_calls(calls)
|
self.handler.port_forwarding_created.assert_has_calls(calls)
|
||||||
update_calls = [mock.call(
|
update_calls = [mock.call(
|
||||||
@ -289,7 +290,7 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
fake_payload = self._fake_pf_payload_entry(100, 100)
|
fake_payload = self._fake_pf_payload_entry(100, 100)
|
||||||
self._handle_notification_common(events.AFTER_UPDATE, fake_payload,
|
self._handle_notification_common(events.AFTER_UPDATE, fake_payload,
|
||||||
fip_objs)
|
fip_objs)
|
||||||
calls = [mock.call(mock.ANY, self.l3_plugin._ovn,
|
calls = [mock.call(mock.ANY, self.l3_plugin._nb_ovn,
|
||||||
fake_payload.latest_state,
|
fake_payload.latest_state,
|
||||||
fake_payload.states[0])]
|
fake_payload.states[0])]
|
||||||
self.handler.port_forwarding_updated.assert_has_calls(calls)
|
self.handler.port_forwarding_updated.assert_has_calls(calls)
|
||||||
@ -297,7 +298,7 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
fake_payload = self._fake_pf_payload_entry(101, 101)
|
fake_payload = self._fake_pf_payload_entry(101, 101)
|
||||||
self._handle_notification_common(events.AFTER_UPDATE, fake_payload,
|
self._handle_notification_common(events.AFTER_UPDATE, fake_payload,
|
||||||
fip_objs)
|
fip_objs)
|
||||||
calls = [mock.call(mock.ANY, self.l3_plugin._ovn,
|
calls = [mock.call(mock.ANY, self.l3_plugin._nb_ovn,
|
||||||
fake_payload.latest_state,
|
fake_payload.latest_state,
|
||||||
fake_payload.states[0])]
|
fake_payload.states[0])]
|
||||||
self.handler.port_forwarding_updated.assert_has_calls(calls)
|
self.handler.port_forwarding_updated.assert_has_calls(calls)
|
||||||
@ -314,7 +315,7 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
self._handle_notification_common(events.AFTER_DELETE,
|
self._handle_notification_common(events.AFTER_DELETE,
|
||||||
fake_payload, fip_objs)
|
fake_payload, fip_objs)
|
||||||
calls = [mock.call(
|
calls = [mock.call(
|
||||||
mock.ANY, self.l3_plugin._ovn, fake_payload.states[0])]
|
mock.ANY, self.l3_plugin._nb_ovn, fake_payload.states[0])]
|
||||||
self.handler.port_forwarding_deleted.assert_has_calls(calls)
|
self.handler.port_forwarding_deleted.assert_has_calls(calls)
|
||||||
update_calls = [mock.call(
|
update_calls = [mock.call(
|
||||||
self.context, fake_payload.states[0].floatingip_id,
|
self.context, fake_payload.states[0].floatingip_id,
|
||||||
@ -333,12 +334,12 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
with mock.patch.object(self._ovn_pf, '_get_pf_objs',
|
with mock.patch.object(self._ovn_pf, '_get_pf_objs',
|
||||||
return_value=pf_objs) as mock_get_pf_objs:
|
return_value=pf_objs) as mock_get_pf_objs:
|
||||||
self._ovn_pf._maintenance_create_update(self.context, fip_id)
|
self._ovn_pf._maintenance_create_update(self.context, fip_id)
|
||||||
self.l3_plugin._ovn.transaction.assert_called_once_with(
|
self.l3_plugin._nb_ovn.transaction.assert_called_once_with(
|
||||||
check_error=True)
|
check_error=True)
|
||||||
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
||||||
for lb_name in fake_lb_names]
|
for lb_name in fake_lb_names]
|
||||||
self.l3_plugin._ovn.lb_del.assert_has_calls(calls)
|
self.l3_plugin._nb_ovn.lb_del.assert_has_calls(calls)
|
||||||
calls = [mock.call(mock.ANY, self.l3_plugin._ovn, pf_obj)
|
calls = [mock.call(mock.ANY, self.l3_plugin._nb_ovn, pf_obj)
|
||||||
for pf_obj in pf_objs]
|
for pf_obj in pf_objs]
|
||||||
self.handler.port_forwarding_created.assert_has_calls(calls)
|
self.handler.port_forwarding_created.assert_has_calls(calls)
|
||||||
mock_get_pf_objs.assert_called_once_with(self.context, fip_id)
|
mock_get_pf_objs.assert_called_once_with(self.context, fip_id)
|
||||||
@ -358,11 +359,11 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
with mock.patch.object(self._ovn_pf, '_get_pf_objs',
|
with mock.patch.object(self._ovn_pf, '_get_pf_objs',
|
||||||
return_value=pf_objs) as mock_get_pf_objs:
|
return_value=pf_objs) as mock_get_pf_objs:
|
||||||
self._ovn_pf.maintenance_delete(self.context, fip_id)
|
self._ovn_pf.maintenance_delete(self.context, fip_id)
|
||||||
self.l3_plugin._ovn.transaction.assert_called_once_with(
|
self.l3_plugin._nb_ovn.transaction.assert_called_once_with(
|
||||||
check_error=True)
|
check_error=True)
|
||||||
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
||||||
for lb_name in fake_lb_names]
|
for lb_name in fake_lb_names]
|
||||||
self.l3_plugin._ovn.lb_del.assert_has_calls(calls)
|
self.l3_plugin._nb_ovn.lb_del.assert_has_calls(calls)
|
||||||
self.handler.port_forwarding_created.assert_not_called()
|
self.handler.port_forwarding_created.assert_not_called()
|
||||||
mock_get_pf_objs.assert_not_called()
|
mock_get_pf_objs.assert_not_called()
|
||||||
self.l3_plugin.get_floatingip.assert_not_called()
|
self.l3_plugin.get_floatingip.assert_not_called()
|
||||||
@ -386,14 +387,14 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
mock_get_pf_objs.assert_called_once_with(self.context, fip_id)
|
mock_get_pf_objs.assert_called_once_with(self.context, fip_id)
|
||||||
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
||||||
for lb_name in fake_lb_names]
|
for lb_name in fake_lb_names]
|
||||||
self.l3_plugin._ovn.lb_del.assert_has_calls(calls)
|
self.l3_plugin._nb_ovn.lb_del.assert_has_calls(calls)
|
||||||
calls = [mock.call(mock.ANY, self.l3_plugin._ovn, pf_obj)
|
calls = [mock.call(mock.ANY, self.l3_plugin._nb_ovn, pf_obj)
|
||||||
for pf_obj in pf_objs]
|
for pf_obj in pf_objs]
|
||||||
self.handler.port_forwarding_created.assert_has_calls(calls)
|
self.handler.port_forwarding_created.assert_has_calls(calls)
|
||||||
self.l3_plugin.get_floatingip.assert_called_once_with(
|
self.l3_plugin.get_floatingip.assert_called_once_with(
|
||||||
self.context, fip_id)
|
self.context, fip_id)
|
||||||
self.fake_check_rev.assert_called_once_with(
|
self.fake_check_rev.assert_called_once_with(
|
||||||
self.txn, self.l3_plugin._ovn, fip_id, fake_fip_obj)
|
self.txn, self.l3_plugin._nb_ovn, fip_id, fake_fip_obj)
|
||||||
|
|
||||||
@mock.patch.object(port_forwarding.LOG, 'info')
|
@mock.patch.object(port_forwarding.LOG, 'info')
|
||||||
def test_db_sync_delete(self, m_info):
|
def test_db_sync_delete(self, m_info):
|
||||||
@ -405,4 +406,4 @@ class TestOVNPortForwarding(TestOVNPortForwardingBase):
|
|||||||
self.assertIn('db_sync DELETE entries', info_args[0])
|
self.assertIn('db_sync DELETE entries', info_args[0])
|
||||||
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
calls = [mock.call(lb_name, vip=None, if_exists=True)
|
||||||
for lb_name in fake_lb_names]
|
for lb_name in fake_lb_names]
|
||||||
self.l3_plugin._ovn.lb_del.assert_has_calls(calls)
|
self.l3_plugin._nb_ovn.lb_del.assert_has_calls(calls)
|
||||||
|
Loading…
Reference in New Issue
Block a user