Merge "Add localport const and refactor"
This commit is contained in:
commit
b08310df9f
@ -273,6 +273,7 @@ PORT_SECURITYGROUPS = 'security_groups'
|
|||||||
LSP_TYPE_LOCALNET = 'localnet'
|
LSP_TYPE_LOCALNET = 'localnet'
|
||||||
LSP_TYPE_VIRTUAL = 'virtual'
|
LSP_TYPE_VIRTUAL = 'virtual'
|
||||||
LSP_TYPE_EXTERNAL = 'external'
|
LSP_TYPE_EXTERNAL = 'external'
|
||||||
|
LSP_TYPE_LOCALPORT = 'localport'
|
||||||
LSP_OPTIONS_VIRTUAL_PARENTS_KEY = 'virtual-parents'
|
LSP_OPTIONS_VIRTUAL_PARENTS_KEY = 'virtual-parents'
|
||||||
LSP_OPTIONS_VIRTUAL_IP_KEY = 'virtual-ip'
|
LSP_OPTIONS_VIRTUAL_IP_KEY = 'virtual-ip'
|
||||||
LSP_OPTIONS_MCAST_FLOOD_REPORTS = 'mcast_flood_reports'
|
LSP_OPTIONS_MCAST_FLOOD_REPORTS = 'mcast_flood_reports'
|
||||||
|
@ -887,7 +887,7 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend):
|
|||||||
except idlutils.RowNotFound:
|
except idlutils.RowNotFound:
|
||||||
return None
|
return None
|
||||||
cmd = self.db_find_rows('Port_Binding', ('datapath', '=', dp),
|
cmd = self.db_find_rows('Port_Binding', ('datapath', '=', dp),
|
||||||
('type', '=', 'localport'))
|
('type', '=', ovn_const.LSP_TYPE_LOCALPORT))
|
||||||
return next(iter(cmd.execute(check_error=True)), None)
|
return next(iter(cmd.execute(check_error=True)), None)
|
||||||
|
|
||||||
def set_chassis_neutron_description(self, chassis, description,
|
def set_chassis_neutron_description(self, chassis, description,
|
||||||
|
@ -673,7 +673,7 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
|
|||||||
cmds = []
|
cmds = []
|
||||||
for port in self._nb_idl.lsp_list().execute(check_error=True):
|
for port in self._nb_idl.lsp_list().execute(check_error=True):
|
||||||
port_type = port.type.strip()
|
port_type = port.type.strip()
|
||||||
if port_type in ("vtep", "localport", "router"):
|
if port_type in ("vtep", ovn_const.LSP_TYPE_LOCALPORT, "router"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
options = port.options
|
options = port.options
|
||||||
|
@ -268,7 +268,7 @@ class OVNClient(object):
|
|||||||
const.DEVICE_OWNER_DISTRIBUTED,
|
const.DEVICE_OWNER_DISTRIBUTED,
|
||||||
const.DEVICE_OWNER_DHCP] and
|
const.DEVICE_OWNER_DHCP] and
|
||||||
not utils.is_neutron_dhcp_agent_port(port)):
|
not utils.is_neutron_dhcp_agent_port(port)):
|
||||||
port_type = 'localport'
|
port_type = ovn_const.LSP_TYPE_LOCALPORT
|
||||||
|
|
||||||
if utils.is_port_external(port):
|
if utils.is_port_external(port):
|
||||||
if self.is_external_ports_supported():
|
if self.is_external_ports_supported():
|
||||||
@ -311,7 +311,7 @@ class OVNClient(object):
|
|||||||
# and will be ignored when mcast_snoop is False. We can revise
|
# and will be ignored when mcast_snoop is False. We can revise
|
||||||
# this once https://bugzilla.redhat.com/show_bug.cgi?id=1933990
|
# this once https://bugzilla.redhat.com/show_bug.cgi?id=1933990
|
||||||
# (see comment #3) is fixed in Core OVN.
|
# (see comment #3) is fixed in Core OVN.
|
||||||
if port_type not in ('vtep', 'localport', 'router'):
|
if port_type not in ('vtep', ovn_const.LSP_TYPE_LOCALPORT, 'router'):
|
||||||
options.update({ovn_const.LSP_OPTIONS_MCAST_FLOOD_REPORTS: 'true'})
|
options.update({ovn_const.LSP_OPTIONS_MCAST_FLOOD_REPORTS: 'true'})
|
||||||
|
|
||||||
device_owner = port.get('device_owner', '')
|
device_owner = port.get('device_owner', '')
|
||||||
|
@ -131,7 +131,7 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
|
|||||||
self.nb_api.lsp_add(
|
self.nb_api.lsp_add(
|
||||||
lswitch_name,
|
lswitch_name,
|
||||||
mdt_port_name,
|
mdt_port_name,
|
||||||
type='localport',
|
type=ovn_const.LSP_TYPE_LOCALPORT,
|
||||||
addresses='AA:AA:AA:AA:AA:AA 192.168.122.123',
|
addresses='AA:AA:AA:AA:AA:AA 192.168.122.123',
|
||||||
external_ids={
|
external_ids={
|
||||||
ovn_const.OVN_CIDRS_EXT_ID_KEY: '192.168.122.123/24'}))
|
ovn_const.OVN_CIDRS_EXT_ID_KEY: '192.168.122.123/24'}))
|
||||||
|
@ -99,7 +99,8 @@ class TestSbApi(BaseOvnIdlTest):
|
|||||||
self.assertGreaterEqual(set(mapping.keys()),
|
self.assertGreaterEqual(set(mapping.keys()),
|
||||||
{c['name'] for c in self.data['chassis']})
|
{c['name'] for c in self.data['chassis']})
|
||||||
|
|
||||||
def _add_switch_port(self, chassis_name, type='localport'):
|
def _add_switch_port(self, chassis_name,
|
||||||
|
type=ovn_const.LSP_TYPE_LOCALPORT):
|
||||||
sname, pname = (utils.get_rand_device_name(prefix=p)
|
sname, pname = (utils.get_rand_device_name(prefix=p)
|
||||||
for p in ('switch', 'port'))
|
for p in ('switch', 'port'))
|
||||||
chassis = self.api.lookup('Chassis', chassis_name)
|
chassis = self.api.lookup('Chassis', chassis_name)
|
||||||
|
@ -963,7 +963,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
|||||||
_plugin_nb_ovn = self.mech_driver._nb_ovn
|
_plugin_nb_ovn = self.mech_driver._nb_ovn
|
||||||
plugin_metadata_ports = [row.name for row in (
|
plugin_metadata_ports = [row.name for row in (
|
||||||
_plugin_nb_ovn._tables['Logical_Switch_Port'].rows.values())
|
_plugin_nb_ovn._tables['Logical_Switch_Port'].rows.values())
|
||||||
if row.type == 'localport']
|
if row.type == ovn_const.LSP_TYPE_LOCALPORT]
|
||||||
|
|
||||||
if should_match:
|
if should_match:
|
||||||
# Check that metadata ports exist in both Neutron and OVN dbs.
|
# Check that metadata ports exist in both Neutron and OVN dbs.
|
||||||
@ -1481,7 +1481,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
|||||||
_plugin_nb_ovn = self.mech_driver._nb_ovn
|
_plugin_nb_ovn = self.mech_driver._nb_ovn
|
||||||
plugin_metadata_ports = [row.name for row in (
|
plugin_metadata_ports = [row.name for row in (
|
||||||
_plugin_nb_ovn._tables['Logical_Switch_Port'].rows.values())
|
_plugin_nb_ovn._tables['Logical_Switch_Port'].rows.values())
|
||||||
if row.type == 'localport']
|
if row.type == ovn_const.LSP_TYPE_LOCALPORT]
|
||||||
|
|
||||||
with self.nb_api.transaction(check_error=True) as txn:
|
with self.nb_api.transaction(check_error=True) as txn:
|
||||||
for port in plugin_metadata_ports:
|
for port in plugin_metadata_ports:
|
||||||
|
@ -421,7 +421,7 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
|
|||||||
'type': "vtep"})
|
'type': "vtep"})
|
||||||
lsp3 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
|
lsp3 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
|
||||||
attrs={'name': 'lsp3', 'options': {},
|
attrs={'name': 'lsp3', 'options': {},
|
||||||
'type': "localport"})
|
'type': constants.LSP_TYPE_LOCALPORT})
|
||||||
lsp4 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
|
lsp4 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
|
||||||
attrs={'name': 'lsp4', 'options': {},
|
attrs={'name': 'lsp4', 'options': {},
|
||||||
'type': "router"})
|
'type': "router"})
|
||||||
|
@ -3316,7 +3316,8 @@ class TestOVNMechanismDriverMetadataPort(test_plugin.Ml2PluginV2TestCase):
|
|||||||
with self.network():
|
with self.network():
|
||||||
self.assertEqual(1, self.nb_ovn.create_lswitch_port.call_count)
|
self.assertEqual(1, self.nb_ovn.create_lswitch_port.call_count)
|
||||||
args, kwargs = self.nb_ovn.create_lswitch_port.call_args
|
args, kwargs = self.nb_ovn.create_lswitch_port.call_args
|
||||||
self.assertEqual('localport', kwargs['type'])
|
self.assertEqual(ovn_const.LSP_TYPE_LOCALPORT,
|
||||||
|
kwargs['type'])
|
||||||
|
|
||||||
def test_metadata_port_not_created_if_exists(self):
|
def test_metadata_port_not_created_if_exists(self):
|
||||||
"""Check that metadata port is not created if it already exists.
|
"""Check that metadata port is not created if it already exists.
|
||||||
@ -3349,7 +3350,8 @@ class TestOVNMechanismDriverMetadataPort(test_plugin.Ml2PluginV2TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
2, self.nb_ovn.set_lswitch_port.call_count)
|
2, self.nb_ovn.set_lswitch_port.call_count)
|
||||||
args, kwargs = self.nb_ovn.set_lswitch_port.call_args
|
args, kwargs = self.nb_ovn.set_lswitch_port.call_args
|
||||||
self.assertEqual('localport', kwargs['type'])
|
self.assertEqual(ovn_const.LSP_TYPE_LOCALPORT,
|
||||||
|
kwargs['type'])
|
||||||
self.assertEqual('10.0.0.2/24 20.0.0.2/24',
|
self.assertEqual('10.0.0.2/24 20.0.0.2/24',
|
||||||
kwargs['external_ids'].get(
|
kwargs['external_ids'].get(
|
||||||
ovn_const.OVN_CIDRS_EXT_ID_KEY,
|
ovn_const.OVN_CIDRS_EXT_ID_KEY,
|
||||||
|
Loading…
Reference in New Issue
Block a user