aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_gbp.py
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-10-22 09:30:26 +0200
committerDamjan Marion <dmarion@me.com>2018-10-22 11:52:20 +0000
commit31555a3475a37195938378217a635b3451e449de (patch)
treeb330d858fe6d8f1a0b236b608e8970d5114e015c /test/test_gbp.py
parent430634c457da5dd04f481da0118bab581ace732e (diff)
PAPI: Add support for format/unformat functions.
With the introduction of new types, like vl_api_address_t it is now possible to call a message using one of those functions with a string representation. E.g. for an IP address ip_add_address(address="1.1.1.1/24") The language wrapper will automatically convert the string into the vl_api_address_t representation. Currently the caller must do the reverse conversion from the returned named tuple with the unformat function. rv = get_address_on_interface(sw_if_index=1) print(VPPFormat.unformat(rv.address)) Change-Id: Ic872b4560b2f4836255bd5260289bfa38c75bc5d Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test/test_gbp.py')
-rw-r--r--test/test_gbp.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/test_gbp.py b/test/test_gbp.py
index 132bd247dd1..8e873f345e7 100644
--- a/test/test_gbp.py
+++ b/test/test_gbp.py
@@ -10,6 +10,7 @@ from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable
from vpp_ip import *
from vpp_mac import *
from vpp_papi_provider import L2_PORT_TYPE
+from vpp_papi.vpp_format import VPPFormat
from scapy.packet import Raw
from scapy.layers.l2 import Ether, ARP
@@ -162,7 +163,7 @@ class VppGbpSubnet(VppObject):
sw_if_index=None, epg=None):
self._test = test
self.table_id = table_id
- self.prefix = VppIpPrefix(address, address_len)
+ self.prefix = "{}/{}".format(address, address_len)
self.is_internal = is_internal
self.sw_if_index = sw_if_index
self.epg = epg
@@ -172,7 +173,7 @@ class VppGbpSubnet(VppObject):
1,
self.table_id,
self.is_internal,
- self.prefix.encode(),
+ self.prefix,
sw_if_index=self.sw_if_index if self.sw_if_index else 0xffffffff,
epg_id=self.epg if self.epg else 0xffff)
self._test.registry.register(self, self._test.logger)
@@ -182,7 +183,7 @@ class VppGbpSubnet(VppObject):
0,
self.table_id,
self.is_internal,
- self.prefix.encode())
+ self.prefix)
def __str__(self):
return self.object_id()
@@ -195,7 +196,7 @@ class VppGbpSubnet(VppObject):
ss = self._test.vapi.gbp_subnet_dump()
for s in ss:
if s.subnet.table_id == self.table_id and \
- s.subnet.prefix == self.prefix:
+ VPPFormat.unformat(s.subnet.prefix) == self.prefix:
return True
return False