diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-07-11 19:25:43 -0400 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2019-07-12 08:33:05 +0000 |
commit | dfd57229e9427b9a34123a58f918446d82029a30 (patch) | |
tree | 9fe5bd2b59439efd28a76f4183eef1a8d160dbf0 /src/vpp-api/python/vpp_papi | |
parent | 719beb709818b70a1fd65f3c2a625d955678ceb6 (diff) |
papi: fix vpp_format from change in vl_api_prefix_t
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>
Diffstat (limited to 'src/vpp-api/python/vpp_papi')
-rw-r--r-- | src/vpp-api/python/vpp_papi/tests/test_vpp_format.py | 18 | ||||
-rw-r--r-- | src/vpp-api/python/vpp_papi/vpp_format.py | 4 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/vpp-api/python/vpp_papi/tests/test_vpp_format.py b/src/vpp-api/python/vpp_papi/tests/test_vpp_format.py index 54b4846b15b..5c179c02e0a 100644 --- a/src/vpp-api/python/vpp_papi/tests/test_vpp_format.py +++ b/src/vpp-api/python/vpp_papi/tests/test_vpp_format.py @@ -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) - diff --git a/src/vpp-api/python/vpp_papi/vpp_format.py b/src/vpp-api/python/vpp_papi/vpp_format.py index d54106b245c..b58dad3c1b5 100644 --- a/src/vpp-api/python/vpp_papi/vpp_format.py +++ b/src/vpp-api/python/vpp_papi/vpp_format.py @@ -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}, |