[OVN] Don't set virtual port type on ports with similar addresses
Because of broken check why one port has similar address to the other
one, the first one by mistake could be set as virtual.
Example:
port_1: 10.11.1.100
port_2: 10.11.1.10
On create of port_2 it is set as 'virtual', but shouldn't.
This patch fixes that bug by using common function
utils.get_ovn_port_addresses().
Change-Id: Ia4b986146c77edf0616015380359e37233df80fc
Closes-Bug: #1881759
(cherry picked from commit e6023ecb48
)
This commit is contained in:
parent
d09b1b40b6
commit
a0dfb50a9a
|
@ -205,8 +205,9 @@ class OVNClient(object):
|
||||||
def get_virtual_port_parents(self, virtual_ip, port):
|
def get_virtual_port_parents(self, virtual_ip, port):
|
||||||
ls = self._nb_idl.ls_get(utils.ovn_name(port['network_id'])).execute(
|
ls = self._nb_idl.ls_get(utils.ovn_name(port['network_id'])).execute(
|
||||||
check_error=True)
|
check_error=True)
|
||||||
return [lsp.name for lsp in ls.ports for ps in lsp.port_security
|
return [lsp.name for lsp in ls.ports
|
||||||
if lsp.name != port['id'] and virtual_ip in ps]
|
if lsp.name != port['id'] and
|
||||||
|
virtual_ip in utils.get_ovn_port_addresses(lsp)]
|
||||||
|
|
||||||
def _get_port_options(self, port):
|
def _get_port_options(self, port):
|
||||||
context = n_context.get_admin_context()
|
context = n_context.get_admin_context()
|
||||||
|
|
|
@ -438,6 +438,21 @@ class TestVirtualPorts(base.TestOVNFunctionalBase):
|
||||||
self.assertNotIn(ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY,
|
self.assertNotIn(ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY,
|
||||||
ovn_vport.options)
|
ovn_vport.options)
|
||||||
|
|
||||||
|
def test_virtual_port_not_set_similiar_address(self):
|
||||||
|
# Create one port
|
||||||
|
self._create_port(fixed_ip='10.0.0.110')
|
||||||
|
# Create second port with similar IP, so that
|
||||||
|
# string matching will return True
|
||||||
|
second_port = self._create_port(fixed_ip='10.0.0.11')
|
||||||
|
|
||||||
|
# Assert the virtual port has not been set.
|
||||||
|
ovn_vport = self._find_port_row(second_port['id'])
|
||||||
|
self.assertEqual("", ovn_vport.type)
|
||||||
|
self.assertNotIn(ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY,
|
||||||
|
ovn_vport.options)
|
||||||
|
self.assertNotIn(ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY,
|
||||||
|
ovn_vport.options)
|
||||||
|
|
||||||
|
|
||||||
class TestExternalPorts(base.TestOVNFunctionalBase):
|
class TestExternalPorts(base.TestOVNFunctionalBase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue