Merge "Remove support for OVS versions <= 2.8.2"
This commit is contained in:
commit
dda4dc5386
|
@ -372,15 +372,10 @@ def is_lsp_router_port(port):
|
|||
|
||||
|
||||
def get_lrouter_ext_gw_static_route(ovn_router):
|
||||
# TODO(lucasagomes): Remove the try...except block after OVS 2.8.2
|
||||
# is tagged.
|
||||
try:
|
||||
return [route for route in getattr(ovn_router, 'static_routes', []) if
|
||||
strutils.bool_from_string(getattr(
|
||||
route, 'external_ids', {}).get(
|
||||
constants.OVN_ROUTER_IS_EXT_GW, 'false'))]
|
||||
except KeyError:
|
||||
pass
|
||||
return [route for route in getattr(ovn_router, 'static_routes', []) if
|
||||
strutils.bool_from_string(getattr(
|
||||
route, 'external_ids', {}).get(
|
||||
constants.OVN_ROUTER_IS_EXT_GW, 'false'))]
|
||||
|
||||
|
||||
def get_lrouter_snats(ovn_router):
|
||||
|
@ -389,19 +384,14 @@ def get_lrouter_snats(ovn_router):
|
|||
|
||||
def get_lrouter_non_gw_routes(ovn_router):
|
||||
routes = []
|
||||
# TODO(lucasagomes): Remove the try...except block after OVS 2.8.2
|
||||
# is tagged.
|
||||
try:
|
||||
for route in getattr(ovn_router, 'static_routes', []):
|
||||
external_ids = getattr(route, 'external_ids', {})
|
||||
if strutils.bool_from_string(
|
||||
external_ids.get(constants.OVN_ROUTER_IS_EXT_GW, 'false')):
|
||||
continue
|
||||
for route in getattr(ovn_router, 'static_routes', []):
|
||||
external_ids = getattr(route, 'external_ids', {})
|
||||
if strutils.bool_from_string(
|
||||
external_ids.get(constants.OVN_ROUTER_IS_EXT_GW, 'false')):
|
||||
continue
|
||||
|
||||
routes.append({'destination': route.ip_prefix,
|
||||
'nexthop': route.nexthop})
|
||||
except KeyError:
|
||||
pass
|
||||
routes.append({'destination': route.ip_prefix,
|
||||
'nexthop': route.nexthop})
|
||||
return routes
|
||||
|
||||
|
||||
|
|
|
@ -347,14 +347,7 @@ class UpdateLRouterPortCommand(command.BaseCommand):
|
|||
msg = _("Logical Router Port %s does not exist") % self.name
|
||||
raise RuntimeError(msg)
|
||||
|
||||
# TODO(lucasagomes): Remove this check once we drop the support
|
||||
# for OVS versions <= 2.8
|
||||
ipv6_ra_configs_supported = self.api.is_col_present(
|
||||
'Logical_Router_Port', 'ipv6_ra_configs')
|
||||
for col, val in self.columns.items():
|
||||
if col == 'ipv6_ra_configs' and not ipv6_ra_configs_supported:
|
||||
continue
|
||||
|
||||
if col == 'gateway_chassis':
|
||||
col, val = _add_gateway_chassis(self.api, txn, self.name,
|
||||
val)
|
||||
|
@ -746,12 +739,6 @@ class CheckRevisionNumberCommand(command.BaseCommand):
|
|||
def run_idl(self, txn):
|
||||
try:
|
||||
ovn_table = RESOURCE_TYPE_MAP[self.resource_type]
|
||||
# TODO(lucasagomes): After OVS 2.8.2 is released all tables should
|
||||
# have the external_ids column. We can remove this conditional
|
||||
# here by then.
|
||||
if not self.api.is_col_present(ovn_table, 'external_ids'):
|
||||
return
|
||||
|
||||
ovn_resource = None
|
||||
if self.resource_type == ovn_const.TYPE_FLOATINGIPS:
|
||||
ovn_resource = self._get_floatingip_or_pf()
|
||||
|
@ -791,13 +778,6 @@ class DeleteLRouterExtGwCommand(command.BaseCommand):
|
|||
self.if_exists = if_exists
|
||||
|
||||
def run_idl(self, txn):
|
||||
# TODO(lucasagomes): Remove this check after OVS 2.8.2 is tagged
|
||||
# (prior to that, the external_ids column didn't exist in this
|
||||
# table).
|
||||
if not self.api.is_col_present('Logical_Router_Static_Route',
|
||||
'external_ids'):
|
||||
return
|
||||
|
||||
try:
|
||||
lrouter = idlutils.row_by_value(self.api.idl, 'Logical_Router',
|
||||
'name', self.lrouter)
|
||||
|
|
|
@ -555,12 +555,7 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
|||
|
||||
nat_rules = []
|
||||
for nat_rule in getattr(lrouter, 'nat', []):
|
||||
ext_ids = {}
|
||||
# TODO(dalvarez): remove this check once the minimum OVS required
|
||||
# version contains the column (when OVS 2.8.2 is released).
|
||||
if self.is_col_present('NAT', 'external_ids'):
|
||||
ext_ids = dict(getattr(nat_rule, 'external_ids', {}))
|
||||
|
||||
ext_ids = dict(getattr(nat_rule, 'external_ids', {}))
|
||||
nat_rules.append({'external_ip': nat_rule.external_ip,
|
||||
'logical_ip': nat_rule.logical_ip,
|
||||
'type': nat_rule.type,
|
||||
|
@ -631,11 +626,6 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
|||
return result[0] if result else None
|
||||
|
||||
def get_floatingip(self, fip_id):
|
||||
# TODO(dalvarez): remove this check once the minimum OVS required
|
||||
# version contains the column (when OVS 2.8.2 is released).
|
||||
if not self.is_col_present('NAT', 'external_ids'):
|
||||
return
|
||||
|
||||
fip = self.db_find('NAT', ('external_ids', '=',
|
||||
{ovn_const.OVN_FIP_EXT_ID_KEY: fip_id}))
|
||||
result = fip.execute(check_error=True)
|
||||
|
|
|
@ -648,17 +648,13 @@ class OVNClient(object):
|
|||
columns = {'type': 'dnat_and_snat',
|
||||
'logical_ip': floatingip['fixed_ip_address'],
|
||||
'external_ip': floatingip['floating_ip_address'],
|
||||
'logical_port': floatingip['port_id']}
|
||||
'logical_port': floatingip['port_id'],
|
||||
'external_ids': ext_ids}
|
||||
|
||||
if ovn_conf.is_ovn_distributed_floating_ip():
|
||||
if self._nb_idl.lsp_get_up(floatingip['port_id']).execute():
|
||||
columns['external_mac'] = port_db['mac_address']
|
||||
|
||||
# TODO(dalvarez): remove this check once the minimum OVS required
|
||||
# version contains the column (when OVS 2.8.2 is released).
|
||||
if self._nb_idl.is_col_present('NAT', 'external_ids'):
|
||||
columns['external_ids'] = ext_ids
|
||||
|
||||
# TODO(mjozefcz): Remove this workaround when OVN LB
|
||||
# will support both decentralized FIPs on LB and member.
|
||||
lb_member_fip = self._is_lb_member_fip(admin_context, floatingip)
|
||||
|
@ -1026,22 +1022,12 @@ class OVNClient(object):
|
|||
port = self._plugin.get_port(context, gw_port_id)
|
||||
self._create_lrouter_port(context, router, port, txn=txn)
|
||||
|
||||
def _build_extids(gw_info):
|
||||
# TODO(lucasagomes): Remove this check after OVS 2.8.2 is tagged
|
||||
# (prior to that, the external_ids column didn't exist in this
|
||||
# table).
|
||||
columns = {}
|
||||
if self._nb_idl.is_col_present('Logical_Router_Static_Route',
|
||||
'external_ids'):
|
||||
columns['external_ids'] = {
|
||||
ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: gw_info.subnet_id}
|
||||
return columns
|
||||
|
||||
# 2. Add default route with nexthop as gateway ip
|
||||
lrouter_name = utils.ovn_name(router['id'])
|
||||
for gw_info in gateways:
|
||||
columns = _build_extids(gw_info)
|
||||
columns = {'external_ids': {
|
||||
ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: gw_info.subnet_id}}
|
||||
txn.add(self._nb_idl.add_static_route(
|
||||
lrouter_name, ip_prefix=gw_info.ip_prefix,
|
||||
nexthop=gw_info.gateway_ip, **columns))
|
||||
|
|
|
@ -355,6 +355,7 @@ class TestNBImplIdlOvn(TestDBImplIdlOvn):
|
|||
self._tables['DHCP_Options'] = self.dhcp_table
|
||||
self._tables['Address_Set'] = self.address_set_table
|
||||
self._tables['Load_Balancer'] = self.lb_table
|
||||
self._tables['NAT'] = self.nat_table
|
||||
|
||||
with mock.patch.object(impl_idl_ovn.OvsdbNbOvnIdl, 'from_worker',
|
||||
return_value=mock.Mock()):
|
||||
|
|
|
@ -1045,14 +1045,22 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||
self.get_port.return_value = self.member_port
|
||||
self.l3_inst._ovn.lookup.return_value = self.lb_network
|
||||
self.l3_inst._ovn.get_lswitch_port.return_value = self.member_lsp
|
||||
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
|
||||
# setting the NAT entry.
|
||||
expected_ext_ids = {
|
||||
ovn_const.OVN_FIP_EXT_ID_KEY: fip['id'],
|
||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: mock.ANY,
|
||||
ovn_const.OVN_FIP_PORT_EXT_ID_KEY: fip['port_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_NET_ID: fip['floating_network_id']}
|
||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||
'neutron-router-id',
|
||||
external_ip='192.168.0.10',
|
||||
logical_ip='10.0.0.10',
|
||||
type='dnat_and_snat')
|
||||
type='dnat_and_snat',
|
||||
external_ids=expected_ext_ids)
|
||||
|
||||
def test_create_floatingip_lb_vip_fip(self):
|
||||
config.cfg.CONF.set_override(
|
||||
|
@ -1065,15 +1073,23 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
|
|||
[self.fake_ovn_nat_rule],
|
||||
]
|
||||
self.l3_inst._ovn.lookup.return_value = self.lb_network
|
||||
fip = self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||
expected_ext_ids = {
|
||||
ovn_const.OVN_FIP_EXT_ID_KEY: fip['id'],
|
||||
ovn_const.OVN_REV_NUM_EXT_ID_KEY: mock.ANY,
|
||||
ovn_const.OVN_FIP_PORT_EXT_ID_KEY: fip['port_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_NET_ID: fip['floating_network_id']}
|
||||
|
||||
self.l3_inst.create_floatingip(self.context, 'floatingip')
|
||||
self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
|
||||
'neutron-router-id',
|
||||
external_ip='192.168.0.10',
|
||||
external_mac='aa:aa:aa:aa:aa:aa',
|
||||
logical_ip='10.0.0.10',
|
||||
logical_port='port_id',
|
||||
type='dnat_and_snat')
|
||||
type='dnat_and_snat',
|
||||
external_ids=expected_ext_ids)
|
||||
self.l3_inst._ovn.db_find_rows.assert_called_with(
|
||||
'NAT', ('external_ids', '=', {ovn_const.OVN_FIP_PORT_EXT_ID_KEY:
|
||||
self.member_lsp.name}))
|
||||
|
@ -1664,8 +1680,13 @@ class OVNL3ExtrarouteTests(test_l3_gw.ExtGwModeIntTestCase,
|
|||
def test_router_update_gateway_upon_subnet_create_max_ips_ipv6(self):
|
||||
super(OVNL3ExtrarouteTests, self). \
|
||||
test_router_update_gateway_upon_subnet_create_max_ips_ipv6()
|
||||
expected_ext_ids = {
|
||||
ovn_const.OVN_ROUTER_IS_EXT_GW: 'true',
|
||||
ovn_const.OVN_SUBNET_EXT_ID_KEY: mock.ANY}
|
||||
add_static_route_calls = [
|
||||
mock.call(mock.ANY, ip_prefix='0.0.0.0/0', nexthop='10.0.0.1'),
|
||||
mock.call(mock.ANY, ip_prefix='::/0', nexthop='2001:db8::')]
|
||||
mock.call(mock.ANY, ip_prefix='0.0.0.0/0', nexthop='10.0.0.1',
|
||||
external_ids=expected_ext_ids),
|
||||
mock.call(mock.ANY, ip_prefix='::/0', nexthop='2001:db8::',
|
||||
external_ids=expected_ext_ids)]
|
||||
self.l3_inst._ovn.add_static_route.assert_has_calls(
|
||||
add_static_route_calls, any_order=True)
|
||||
|
|
Loading…
Reference in New Issue