[ovs-discuss] ovs python binary get schema_json dict type error

肖海飚 haibiao.xiao at zstack.io
Sat Jan 16 11:06:23 UTC 2021


Hi, I am tring to use ovs python library to connect ovsdb. However, when i create a new Schema object  like this:
 ```python
 from ovs.db import idl
 vswitchd_schema = idl.SchemaHelper(
      "/usr/local/share/openvswitch/vswitch.ovsschema")
 vswitchd_schema.register_all()
 ```
 I got an Type mismatch error:

 Then I read the source code, and found the root cause.
 firstly, idl.SchemaHelper get schema_json by function "ovs.json.from_file()", and the type of the elements in the schema_json dict is 'unicode' . you can see the prefix 'u' in the picture:

 then, get schema from schema_json by function "ovs.db.schema.DbSchema.from_json()", and in the function call "parser.get()" get the DB name and version. However in function "parser.get()", it will identifier the name type by "is_identifier()": 

 the "is_identifier()" want type 'str' but not 'unicode'. so the error has occurred.

I workaround by convert the schema_json dict's keys & values from 'unicode' to 'str'.

best wishes,
haibiao.xiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-discuss/attachments/20210116/351525ec/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: temp4cj.png
Type: application/octet-stream
Size: 75950 bytes
Desc: not available
URL: <http://mail.openvswitch.org/pipermail/ovs-discuss/attachments/20210116/351525ec/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: temp4cj.png
Type: application/octet-stream
Size: 56807 bytes
Desc: not available
URL: <http://mail.openvswitch.org/pipermail/ovs-discuss/attachments/20210116/351525ec/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: temp4cj.png
Type: application/octet-stream
Size: 6039 bytes
Desc: not available
URL: <http://mail.openvswitch.org/pipermail/ovs-discuss/attachments/20210116/351525ec/attachment-0005.obj>


More information about the discuss mailing list