diff options
| author | Ben Pfaff <blp@nicira.com> | 2011-08-22 17:12:59 -0700 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2011-08-24 11:57:43 -0700 |
| commit | 4c0f62718ff9f83613c7f87805ee40495f642583 (patch) | |
| tree | a2835aff0f63b14e5c11de571185154cdb309dc6 /python/ovs | |
| parent | 6a6f8d167357a1f1751cdd54b9491c531a371ae1 (diff) | |
| download | openvswitch-4c0f62718ff9f83613c7f87805ee40495f642583.tar.gz | |
ovs.db.idl: Improve error reporting for bad <row-update>s.
Strangely malformed <row-update>s could hypothetically get confusing error
message. Using the Parser class should avoid that.
Reported-by: Reid Price <reid@nicira.com>
Diffstat (limited to 'python/ovs')
| -rw-r--r-- | python/ovs/db/idl.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py index 8ce17515a..2a04a98f4 100644 --- a/python/ovs/db/idl.py +++ b/python/ovs/db/idl.py @@ -15,6 +15,7 @@ import logging import ovs.jsonrpc +import ovs.db.parser import ovs.db.schema from ovs.db import error import ovs.ovsuuid @@ -206,16 +207,11 @@ class Idl: 'is not an object' % (table_name, uuid_string)) - old = row_update.get("old", None) - new = row_update.get("new", None) + parser = ovs.db.parser.Parser(json, "row-update") + old = parser.get_optional("old", [dict]) + new = parser.get_optional("new", [dict]) + parser.finish() - if old is not None and type(old) != dict: - raise error.Error('"old" <row> is not an object', old) - if new is not None and type(new) != dict: - raise error.Error('"new" <row> is not an object', new) - if (old is not None) + (new is not None) != len(row_update): - raise error.Error("<row-update> contains unexpected " - "member", row_update) if not old and not new: raise error.Error('<row-update> missing "old" and ' '"new" members', row_update) |
