From bf42f674e77a4cb01863b3f975d3258b3c89dd58 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Fri, 2 Mar 2012 17:50:59 -0800 Subject: idl: Convert python daemons to utilize SchemaHelper. The recently added SchemaHelper class significantly simplifies IDL instantiation in Python. This commit converts all users of the old method to the new method, and removes support for the old method. Signed-off-by: Ethan Jackson --- .../usr_share_openvswitch_scripts_ovs-xapi-sync | 35 ++++------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'xenserver') diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index eea319a8..7c78251e 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -205,32 +205,6 @@ def update_in_band_mgmt(row): row.other_config = other_config -def keep_table_columns(schema, table_name, columns): - table = schema.tables.get(table_name) - if not table: - raise error.Error("schema has no %s table" % table_name) - - new_columns = {} - for column_name in columns: - column = table.columns.get(column_name) - if not column: - raise error.Error("%s table schema lacks %s column" - % (table_name, column_name)) - new_columns[column_name] = column - table.columns = new_columns - return table - - -def prune_schema(schema): - new_tables = {} - new_tables["Bridge"] = keep_table_columns( - schema, "Bridge", ("name", "external_ids", "other_config", - "fail_mode")) - new_tables["Interface"] = keep_table_columns( - schema, "Interface", ("name", "external_ids")) - schema.tables = new_tables - - def main(): global flush_cache @@ -248,10 +222,11 @@ def main(): ovs.daemon.handle_args(args) remote = args.database - schema_file = "%s/vswitch.ovsschema" % ovs.dirs.PKGDATADIR - schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_file(schema_file)) - prune_schema(schema) - idl = ovs.db.idl.Idl(remote, schema) + schema_helper = ovs.db.idl.SchemaHelper() + schema_helper.register_columns("Bridge", ["name", "external_ids", + "other_config", "fail_mode"]) + schema_helper.register_columns("Interface", ["name", "external_ids"]) + idl = ovs.db.idl.Idl(remote, schema_helper) ovs.daemon.daemonize() -- cgit v1.2.3