Merge "Modify LSP List command to return all ports"
This commit is contained in:
commit
a0123e3799
|
@ -139,8 +139,8 @@ class API(api.API):
|
|||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def lsp_list(self, switch):
|
||||
"""Get the logical ports on switch
|
||||
def lsp_list(self, switch=None):
|
||||
"""Get the logical ports on switch or all ports if switch is None
|
||||
|
||||
:param switch: The name or uuid of the switch
|
||||
:type switch: string or uuid.UUID
|
||||
|
|
|
@ -256,13 +256,16 @@ class LspDelCommand(cmd.BaseCommand):
|
|||
|
||||
|
||||
class LspListCommand(cmd.BaseCommand):
|
||||
def __init__(self, api, switch):
|
||||
def __init__(self, api, switch=None):
|
||||
super(LspListCommand, self).__init__(api)
|
||||
self.switch = switch
|
||||
|
||||
def run_idl(self, txn):
|
||||
sw = self.api.lookup('Logical_Switch', self.switch)
|
||||
self.result = [ovs_idl.RowView(r) for r in sw.ports]
|
||||
if self.switch:
|
||||
ports = self.api.lookup('Logical_Switch', self.switch).ports
|
||||
else:
|
||||
ports = self.api.tables['Logical_Switch_Port'].rows.values()
|
||||
self.result = [ovs_idl.RowView(r) for r in ports]
|
||||
|
||||
|
||||
class LspGetParentCommand(cmd.BaseCommand):
|
||||
|
|
|
@ -87,7 +87,7 @@ class OvnNbApiIdlImpl(ovs_idl.Backend, api.API):
|
|||
def lsp_del(self, port, switch=None, if_exists=False):
|
||||
return cmd.LspDelCommand(self, port, switch, if_exists)
|
||||
|
||||
def lsp_list(self, switch):
|
||||
def lsp_list(self, switch=None):
|
||||
return cmd.LspListCommand(self, switch)
|
||||
|
||||
def lsp_get_parent(self, port):
|
||||
|
|
|
@ -290,6 +290,14 @@ class TestLspOps(OvnNorthboundTest):
|
|||
check_error=True))
|
||||
self.assertTrue(ports.issubset(port_set))
|
||||
|
||||
def test_lsp_list_no_switch(self):
|
||||
ports = {self._lsp_add(self.switch, None) for _ in range(3)}
|
||||
other_switch = self.useFixture(fixtures.LogicalSwitchFixture(
|
||||
name=utils.get_rand_device_name())).obj
|
||||
other_port = self._lsp_add(other_switch, None)
|
||||
all_ports = set(self.api.lsp_list().execute(check_error=True))
|
||||
self.assertTrue((ports.union(set([other_port]))).issubset(all_ports))
|
||||
|
||||
def test_lsp_get_parent(self):
|
||||
ls1 = self._lsp_add(self.switch, None)
|
||||
ls2 = self._lsp_add(self.switch, None, parent=ls1.name, tag=0)
|
||||
|
|
Loading…
Reference in New Issue