papi: fix vpp_format from change in vl_api_prefix_t 18/20618/2
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Thu, 11 Jul 2019 23:25:43 +0000 (19:25 -0400)
committerNeale Ranns <nranns@cisco.com>
Fri, 12 Jul 2019 08:33:05 +0000 (08:33 +0000)
cherry picking fix for bug introduced by https://gerrit.fd.io/r/#/c/20011/

- also fixes unit tests.

Type: fix
Fixes: ab05508e1eb96749b68de8ccd2f6f88ff3e64fad

Change-Id: I8287385f094911ea70de4751a716a7e0e6521b64
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
src/vpp-api/python/vpp_papi/tests/test_vpp_format.py
src/vpp-api/python/vpp_papi/vpp_format.py

index 54b4846..5c179c0 100644 (file)
@@ -15,6 +15,7 @@
 import ipaddress
 import socket
 import unittest
+
 try:
     text_type = unicode
 except NameError:
@@ -31,11 +32,11 @@ ip4_prefix = '%s/%s' % (ip4_addr, ip4_prefix_len)
 ipv4_network = ipaddress.IPv4Network(text_type(ip4_prefix))
 ip4_addr_format_vl_api_address_t = {'un': {'ip4': b'\x01\x02\x03\x04'},
                                     'af': 0}
-ip4_addr_format_vl_api_prefix_t = {'prefix':
+ip4_addr_format_vl_api_prefix_t = {'address':                                # noqa: E127,E501
                                        {'un': {'ip4': b'\x01\x02\x03\x04'},
                                         'af': 0},
                                    'len': ip4_prefix_len}
-ip4_addr_format_vl_api_prefix_packed_t = {'prefix': b'\x01\x02\x03\x04',
+ip4_addr_format_vl_api_prefix_packed_t = {'address': b'\x01\x02\x03\x04',
                                           'len': ip4_prefix_len}
 
 ip6_addr = 'dead::'
@@ -49,7 +50,7 @@ ip6_addr_format_vl_api_address_t = {'un': {'ip6': b'\xde\xad\x00\x00'
                                                   b'\x00\x00\x00\x00'
                                                   b'\x00\x00\x00\x00'},
                                     'af': 1}
-ip6_addr_format_vl_api_prefix_t = {'prefix':
+ip6_addr_format_vl_api_prefix_t = {'address':       # noqa: E127
                                        {'af': 1,
                                         'un': {
                                             'ip6': b'\xde\xad\x00\x00'
@@ -57,10 +58,10 @@ ip6_addr_format_vl_api_prefix_t = {'prefix':
                                                    b'\x00\x00\x00\x00'
                                                    b'\x00\x00\x00\x00'}},
                                    'len': ip6_prefix_len}
-ip6_addr_format_vl_api_prefix_packed_t = {'prefix': b'\xde\xad\x00\x00'
-                                                    b'\x00\x00\x00\x00'
-                                                    b'\x00\x00\x00\x00'
-                                                    b'\x00\x00\x00\x00',
+ip6_addr_format_vl_api_prefix_packed_t = {'address': b'\xde\xad\x00\x00'   # noqa: E127,E501
+                                                     b'\x00\x00\x00\x00'
+                                                     b'\x00\x00\x00\x00'
+                                                     b'\x00\x00\x00\x00',
                                           'len': ip6_prefix_len}
 
 
@@ -97,7 +98,6 @@ class TestVppFormat(unittest.TestCase):
                             ip6_addr_format_vl_api_prefix_t),
                            ])
     def test_format_vl_api_prefix_t(self, _, arg, expected):
-
         res = vpp_format.format_vl_api_prefix_t(arg)
         self.assertEqual(res, expected)
 
@@ -115,7 +115,6 @@ class TestVppFormat(unittest.TestCase):
         res = vpp_format.format_vl_api_ip4_prefix_t(ipv4_network)
         self.assertEqual(res, ip4_addr_format_vl_api_prefix_packed_t)
 
-
     def test_format_vl_api_ip6_prefix_t_raises(self):
         # PY2: raises socket.error
         # PY3: raises OSError
@@ -127,4 +126,3 @@ class TestVppFormat(unittest.TestCase):
         # PY3: raises OSError
         with self.assertRaises((socket.error, OSError)):
             res = vpp_format.format_vl_api_ip4_prefix_t(ip6_prefix)
-
index d54106b..b58dad3 100644 (file)
@@ -102,11 +102,11 @@ conversion_table = {
     },
     'vl_api_prefix_t':
     {
-        'IPv4Network': lambda o: {'prefix':
+        'IPv4Network': lambda o: {'address':
                                   {'af': ADDRESS_IP4, 'un':
                                    {'ip4': o.network_address.packed}},
                                   'len': o.prefixlen},
-        'IPv6Network': lambda o: {'prefix':
+        'IPv6Network': lambda o: {'address':
                                   {'af': ADDRESS_IP6, 'un':
                                    {'ip6': o.network_address.packed}},
                                   'len': o.prefixlen},