From c09c4e87a0fa201f7d1aee7ee7535e0b3b030723 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Thu, 20 Oct 2016 16:48:13 +0900 Subject: ovs: Add API corresponding to ovs-vsctl list command Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/lib/ovs/vsctl.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ryu/lib/ovs/vsctl.py b/ryu/lib/ovs/vsctl.py index 8235be25..0f7e031d 100644 --- a/ryu/lib/ovs/vsctl.py +++ b/ryu/lib/ovs/vsctl.py @@ -1098,7 +1098,7 @@ class VSCtl(object): # 'emer-reset': # Database commands. - # 'list': + 'list': (self._pre_cmd_list, self._cmd_list), 'find': (self._pre_cmd_find, self._cmd_find), 'get': (self._pre_cmd_get, self._cmd_get), 'set': (self._pre_cmd_set, self._cmd_set), @@ -1810,6 +1810,27 @@ class VSCtl(object): id_, if_exists) command.result = values + def _pre_cmd_list(self, ctx, command): + table_name = command.args[0] + self._pre_get_table(ctx, table_name) + + def _list(self, ctx, table_name, record_id=None): + result = [] + for ovsrec_row in ctx.idl.tables[table_name].rows.values(): + if record_id is not None and ovsrec_row.name != record_id: + continue + result.append(ovsrec_row) + + return result + + def _cmd_list(self, ctx, command): + table_name = command.args[0] + record_id = None + if len(command.args) > 1: + record_id = command.args[1] + + command.result = self._list(ctx, table_name, record_id) + def _pre_cmd_find(self, ctx, command): table_name = command.args[0] table_schema = self.schema.tables[table_name] -- cgit v1.2.3