python/ovs/db/idl: add counterpart of ovsdb_idl_add_table()
authorIsaku Yamahata <yamahata@valinux.co.jp>
Thu, 13 Sep 2012 02:22:53 +0000 (11:22 +0900)
committerBen Pfaff <blp@nicira.com>
Thu, 13 Sep 2012 03:40:59 +0000 (20:40 -0700)
Add register_table method to SchemaHelper as Python counterpart of
ovsdb_idl_add_table() in the C version of the IDL.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
python/ovs/db/idl.py

index e4b98e8..5b06d91 100644 (file)
@@ -1224,6 +1224,15 @@ class SchemaHelper(object):
         columns = set(columns) | self._tables.get(table, set())
         self._tables[table] = columns
 
+    def register_table(self, table):
+        """Registers interest in the given all columns of 'table'. Future calls
+        to get_idl_schema() will include all columns of 'table'.
+
+        'table' must be a string
+        """
+        assert type(table) is str
+        self._tables[table] = set()  # empty set means all columns in the table
+
     def register_all(self):
         """Registers interest in every column of every table."""
         self._all = True
@@ -1249,6 +1258,10 @@ class SchemaHelper(object):
         assert table_name in schema.tables
         table = schema.tables[table_name]
 
+        if not columns:
+            # empty set means all columns in the table
+            return table
+
         new_columns = {}
         for column_name in columns:
             assert type(column_name) is str