summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2016-10-20 16:48:13 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-10-25 16:22:13 +0900
commitc09c4e87a0fa201f7d1aee7ee7535e0b3b030723 (patch)
tree744b4055cfd6aae98e418f021ac67243d76a75f6
parentd19e7a321375a6716905893dcc041b58a6135da3 (diff)
ovs: Add API corresponding to ovs-vsctl list command
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/ovs/vsctl.py23
1 files changed, 22 insertions, 1 deletions
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]