IP should be optional in lsp_set_addresses

ovsdbapp, unlike ovn-nbctl, does not allow address in lsp_set_addresses
to be a MAC alone without an IP.

ovn-nbctl.8 manual:
"an  Ethernet  address, optionally followed by a space and one or
more IP addresses"

With this patch, IP address is optional.

Change-Id: I6a3708b22b7f9c11af1960bfa6be7413e497534c
This commit is contained in:
Petr Horáček 2017-11-30 19:30:06 +02:00
parent eac5d2dcf7
commit 124b52c425
2 changed files with 5 additions and 4 deletions

View File

@ -296,13 +296,14 @@ class LspGetTagCommand(cmd.BaseCommand):
class LspSetAddressesCommand(cmd.BaseCommand):
addr_re = re.compile(
r'^(router|unknown|dynamic|([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2} .+)$')
r'^(router|unknown|dynamic|([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}( .+)*)$')
def __init__(self, api, port, addresses):
for addr in addresses:
if not self.addr_re.match(addr):
raise TypeError(
"address must be router/unknown/dynamic/ethaddr ipaddr...")
"address must be router/unknown/dynamic/"
"ethaddr[ ipaddr...]")
super(LspSetAddressesCommand, self).__init__(api)
self.port = port
self.addresses = addresses

View File

@ -342,7 +342,7 @@ class TestLspOps(OvnNorthboundTest):
def test_lsp_set_addresses(self):
lsp = self._lsp_add(self.switch, None)
for addr in ('dynamic', 'unknown', 'router',
for addr in ('dynamic', 'unknown', 'router', 'de:ad:be:ef:4d:ad',
'de:ad:be:ef:4d:ad 192.0.2.1'):
self.api.lsp_set_addresses(lsp.name, [addr]).execute(
check_error=True)
@ -351,7 +351,7 @@ class TestLspOps(OvnNorthboundTest):
def test_lsp_set_addresses_invalid(self):
self.assertRaises(
TypeError,
self.api.lsp_set_addresses, 'fake', '01:02:03:04:05:06')
self.api.lsp_set_addresses, 'fake', 'invalidaddress')
def test_lsp_get_addresses(self):
addresses = [