[ovs-dev] [python idl 16/16] python: Implement write support in Python IDL for OVSDB.
Ben Pfaff
blp at nicira.com
Wed Sep 21 17:24:51 UTC 2011
On Tue, Sep 20, 2011 at 10:05:21PM -0700, Ethan Jackson wrote:
> Offline we discussed that it might be simpler to just read the schema based on
> its path according to the dirs module.
OK, here's an incremental. It passes the unit tests but I still
haven't tested ovs-xapi-sync or ovs-monitor-ipsec.
diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec
index 4ef2141..15fbd3b 100755
--- a/debian/ovs-monitor-ipsec
+++ b/debian/ovs-monitor-ipsec
@@ -33,10 +33,10 @@ import socket
import subprocess
import sys
+import ovs.dirs
from ovs.db import error
from ovs.db import types
import ovs.util
-import ovs.vswitchd.ovsschema
import ovs.daemon
import ovs.db.idl
@@ -457,7 +457,9 @@ def main(argv):
remote = args[0]
- idl = ovs.db.idl.Idl(remote, prune_schema(ovs.vswitchd.ovsschema.copy()))
+ schema_file = "%s/vswitch.ovsschema" % ovs.dirs.PKGDATADIR
+ schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_file(schema_file))
+ idl = ovs.db.idl.Idl(remote, prune_schema(schema))
ovs.daemon.daemonize()
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index d8ab68f..cce6197 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -41,7 +41,7 @@ m4_define([OVSDB_CHECK_IDL_PY],
AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
m4_if([$2], [], [],
[AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
- AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl unix:socket $3],
+ AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
[0], [stdout], [ignore], [kill `cat pid`])
AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
[0], [$4], [], [kill `cat pid`])
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index f9b0aa6..4b85c71 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -302,8 +302,9 @@ def idl_set(idl, commands, step):
sys.stdout.write("\n")
sys.stdout.flush()
-def do_idl(remote, *commands):
- idl = ovs.db.idl.Idl(remote, idltest.schema)
+def do_idl(schema_file, remote, *commands):
+ schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_file(schema_file))
+ idl = ovs.db.idl.Idl(remote, schema)
if commands:
error, stream = ovs.stream.Stream.open_block(
@@ -407,10 +408,10 @@ parse-table NAME OBJECT [DEFAULT-IS-ROOT]
parse table NAME with info OBJECT
parse-schema JSON
parse JSON as an OVSDB schema, and re-serialize
-idl SERVER [TRANSACTION...]
- connect to SERVER and dump the contents of the database
- as seen initially by the IDL implementation and after
- executing each TRANSACTION. (Each TRANSACTION must modify
+idl SCHEMA SERVER [TRANSACTION...]
+ connect to SERVER (which has the specified SCHEMA) and dump the
+ contents of the database as seen initially by the IDL implementation
+ and after executing each TRANSACTION. (Each TRANSACTION must modify
the database or this command will hang.)
The following options are also available:
@@ -459,7 +460,7 @@ def main(argv):
"parse-column": (do_parse_column, 2),
"parse-table": (do_parse_table, (2, 3)),
"parse-schema": (do_parse_schema, 1),
- "idl": (do_idl, (1,))}
+ "idl": (do_idl, (2,))}
command_name = args[0]
args = args[1:]
diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
index 251a208..79e54d2 100755
--- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
+++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
@@ -32,6 +32,7 @@ import time
import XenAPI
+import ovs.dirs
from ovs.db import error
from ovs.db import types
import ovs.util
@@ -255,7 +256,9 @@ def main(argv):
sys.exit(1)
remote = args[0]
- idl = ovs.db.idl.Idl(remote, prune_schema(ovs.vswitchd.ovsschema.copy()))
+ schema_file = "%s/vswitch.ovsschema" % ovs.dirs.PKGDATADIR
+ schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_file(schema_file))
+ idl = ovs.db.idl.Idl(remote, prune_schema(schema))
ovs.daemon.daemonize()
More information about the dev
mailing list