VPP-1144: PAPI Import leads to duplicate type definition. 41/10241/2
authorOle Troan <ot@cisco.com>
Thu, 25 Jan 2018 08:53:31 +0000 (09:53 +0100)
committerNeale Ranns <nranns@cisco.com>
Thu, 25 Jan 2018 13:43:34 +0000 (13:43 +0000)
Change-Id: I54c147004fd93681a6a9cf30fa5277c1dabce67c
Signed-off-by: Ole Troan <ot@cisco.com>
src/vpp-api/python/vpp_papi.py

index 4d39d5f..1d92a41 100644 (file)
@@ -515,8 +515,23 @@ class VPP():
             return self.messages[name]['return_tuple']
         return None
 
+    def duplicate_check_ok(self, name, msgdef):
+        crc = None
+        for c in msgdef:
+            if type(c) is dict and 'crc' in c:
+                crc = c['crc']
+                break
+        if crc:
+            # We can get duplicates because of imports
+            if crc == self.messages[name]['crc']:
+                return True
+        return False
+
     def add_message(self, name, msgdef, typeonly=False):
         if name in self.messages:
+            if typeonly:
+                if self.duplicate_check_ok(name, msgdef):
+                    return
             raise ValueError('Duplicate message name: ' + name)
 
         args = collections.OrderedDict()