make old query api work on OFPMatch instances created with from_jsondict.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/ofproto/ofproto_v1_2_parser.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_2_parser.py 
b/ryu/ofproto/ofproto_v1_2_parser.py
index da98770..0f18d51 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -1660,14 +1660,23 @@ class OFPMatch(StringifyMixin):
 
     @classmethod
     def from_jsondict(cls, dict_):
-        return super(OFPMatch, cls).from_jsondict(dict_, lambda x: x)
+        o = super(OFPMatch, cls).from_jsondict(dict_, lambda x: x)
+        # XXX old api compat
+        # serialize and parse to fill OFPMatch.fields
+        buf = bytearray()
+        o.serialize(buf, 0)
+        return OFPMatch.parser(str(buf), 0)
 
     def append_field(self, header, value, mask=None):
         self.fields.append(OFPMatchField.make(header, value, mask))
 
+    def _composed_with_old_api(self):
+        return (self.fields and not self._fields2) or \
+            self._wc.__dict__ != FlowWildcards().__dict__
+
     def serialize(self, buf, offset):
         # XXX compat
-        if self.fields or self._wc.__dict__ != FlowWildcards().__dict__:
+        if self._composed_with_old_api():
             return self.serialize_old(buf, offset)
 
         fields = [ofproto_v1_2.oxm_from_user(k, v) for (k, v)
-- 
1.8.1.5


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to