diff options
author | Ethan Jackson <ethan@nicira.com> | 2012-03-02 17:50:59 -0800 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2012-03-09 13:37:39 -0800 |
commit | bf42f674e77a4cb01863b3f975d3258b3c89dd58 (patch) | |
tree | a9684fb99b8256768871fcd9b298f65e82966e09 /xenserver | |
parent | 7b2d10c52926cf604273b8935c7bce07fe7868d0 (diff) | |
download | openvswitch-bf42f674e77a4cb01863b3f975d3258b3c89dd58.tar.gz |
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 <ethan@nicira.com>
Diffstat (limited to 'xenserver')
-rwxr-xr-x | xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index eea319a81..7c78251e2 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() |