aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/IPUtil.py71
-rw-r--r--resources/libraries/python/IPsecUtil.py56
-rw-r--r--resources/libraries/python/InterfaceUtil.py140
-rw-r--r--resources/libraries/python/TestConfig.py27
-rw-r--r--resources/libraries/python/VPPUtil.py17
5 files changed, 214 insertions, 97 deletions
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py
index 2109997e99..de018b9565 100644
--- a/resources/libraries/python/IPUtil.py
+++ b/resources/libraries/python/IPUtil.py
@@ -149,7 +149,9 @@ class IPUtil(object):
"""Get dump of all IP FIB tables on a VPP node.
:param node: VPP node.
+ :param address: IP address.
:type node: dict
+ :type address: str
"""
addr = ip_address(unicode(address))
@@ -174,11 +176,11 @@ class IPUtil(object):
"""
sw_if_index = InterfaceUtil.get_interface_index(node, interface)
- is_ipv6 = 1 if ip_version == 'ipv6' else 0
-
cmd = 'sw_interface_get_table'
- args = dict(sw_if_index=sw_if_index,
- is_ipv6=is_ipv6)
+ args = dict(
+ sw_if_index=sw_if_index,
+ is_ipv6=True if ip_version == 'ipv6' else False
+ )
err_msg = 'Failed to get VRF id assigned to interface {ifc}'.format(
ifc=interface)
@@ -200,7 +202,8 @@ class IPUtil(object):
args = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, if_name),
is_add=1,
- loose=0)
+ loose=0
+ )
err_msg = 'Failed to enable source check on interface {ifc}'.format(
ifc=if_name)
with PapiSocketExecutor(node) as papi_exec:
@@ -393,12 +396,13 @@ class IPUtil(object):
cmd = 'sw_interface_add_del_address'
args = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, interface),
- is_add=1,
- is_ipv6=1 if ip_addr.version == 6 else 0,
- del_all=0,
- address_length=int(prefix_length) if prefix_length else 128
- if ip_addr.version == 6 else 32,
- address=ip_addr.packed)
+ is_add=True,
+ del_all=False,
+ prefix=IPUtil.create_prefix_object(
+ ip_addr,
+ prefix_length if prefix_length else 128
+ if ip_addr.version == 6 else 32)
+ )
err_msg = 'Failed to add IP address on interface {ifc}'.format(
ifc=interface)
with PapiSocketExecutor(node) as papi_exec:
@@ -461,6 +465,24 @@ class IPUtil(object):
un=IPUtil.union_addr(ip_addr))
@staticmethod
+ def create_prefix_object(ip_addr, addr_len):
+ """Create prefix object.
+
+ :param ip_addr: IPv4 or IPv6 address.
+ :para, addr_len: Length of IP address.
+ :type ip_addr: IPv4Address or IPv6Address
+ :type addr_len: int
+ :returns: Prefix object.
+ :rtype: dict
+ """
+ addr = IPUtil.create_ip_address_object(ip_addr)
+
+ return dict(
+ len=int(addr_len),
+ address=addr
+ )
+
+ @staticmethod
def compose_vpp_route_structure(node, network, prefix_len, **kwargs):
"""Create route object for ip_route_add_del api call.
@@ -491,17 +513,15 @@ class IPUtil(object):
net_addr = ip_address(unicode(network))
- addr = IPUtil.create_ip_address_object(net_addr)
- prefix = dict(
- len=int(prefix_len),
- address=addr)
+ prefix = IPUtil.create_prefix_object(net_addr, prefix_len)
paths = list()
n_hop = dict(
address=IPUtil.union_addr(ip_address(unicode(gateway))) if gateway
else 0,
via_label=MPLS_LABEL_INVALID,
- obj_id=Constants.BITWISE_NON_ZERO)
+ obj_id=Constants.BITWISE_NON_ZERO
+ )
path = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, interface)
if interface else Constants.BITWISE_NON_ZERO,
@@ -520,14 +540,16 @@ class IPUtil(object):
else 'FIB_PATH_NH_PROTO_IP4').value,
nh=n_hop,
n_labels=0,
- label_stack=list(0 for _ in range(16)))
+ label_stack=list(0 for _ in range(16))
+ )
paths.append(path)
route = dict(
table_id=int(kwargs.get('vrf', 0)),
prefix=prefix,
n_paths=len(paths),
- paths=paths)
+ paths=paths
+ )
return route
@staticmethod
@@ -578,19 +600,18 @@ class IPUtil(object):
net_addr = ip_address(unicode(network))
cmd = 'ip_route_add_del'
- route = IPUtil.compose_vpp_route_structure(
- node, network, prefix_len, **kwargs)
args = dict(
is_add=1,
is_multipath=int(kwargs.get('multipath', False)),
- route=route)
+ route=None
+ )
err_msg = 'Failed to add route(s) on host {host}'.format(
host=node['host'])
with PapiSocketExecutor(node) as papi_exec:
for i in xrange(kwargs.get('count', 1)):
- args['route']['prefix']['address']['un'] = \
- IPUtil.union_addr(net_addr + i)
+ args['route'] = IPUtil.compose_vpp_route_structure(
+ node, net_addr + i, prefix_len, **kwargs)
history = False if 1 < i < kwargs.get('count', 1) else True
papi_exec.add(cmd, history=history, **args)
papi_exec.get_replies(err_msg)
@@ -607,7 +628,9 @@ class IPUtil(object):
cmd = 'sw_interface_add_del_address'
args = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, interface),
- del_all=1)
+ is_add=False,
+ del_all=True
+ )
err_msg = 'Failed to flush IP address on interface {ifc}'.format(
ifc=interface)
with PapiSocketExecutor(node) as papi_exec:
diff --git a/resources/libraries/python/IPsecUtil.py b/resources/libraries/python/IPsecUtil.py
index dd6ba181e8..c109f417e5 100644
--- a/resources/libraries/python/IPsecUtil.py
+++ b/resources/libraries/python/IPsecUtil.py
@@ -22,7 +22,8 @@ from enum import Enum, IntEnum
from ipaddress import ip_network, ip_address
from resources.libraries.python.IPUtil import IPUtil
-from resources.libraries.python.InterfaceUtil import InterfaceUtil
+from resources.libraries.python.InterfaceUtil import InterfaceUtil, \
+ InterfaceStatusFlags
from resources.libraries.python.PapiExecutor import PapiSocketExecutor
from resources.libraries.python.topology import Topology
from resources.libraries.python.VatExecutor import VatExecutor
@@ -518,11 +519,9 @@ class IPsecUtil(object):
cmd1 = 'sw_interface_add_del_address'
args1 = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, interface),
- is_add=1,
- is_ipv6=1 if laddr.version == 6 else 0,
- del_all=0,
- address_length=raddr_range,
- address=None
+ is_add=True,
+ del_all=False,
+ prefix=None
)
cmd2 = 'ip_route_add_del'
args2 = dict(
@@ -536,7 +535,8 @@ class IPsecUtil(object):
with PapiSocketExecutor(node) as papi_exec:
for i in xrange(n_tunnels):
- args1['address'] = getattr(laddr + i * addr_incr, 'packed')
+ args1['prefix'] = IPUtil.create_prefix_object(
+ laddr + i * addr_incr, raddr_range)
args2['route'] = IPUtil.compose_vpp_route_structure(
node,
taddr + i,
@@ -951,7 +951,7 @@ class IPsecUtil(object):
cmd1 = 'sw_interface_set_flags'
args1 = dict(
sw_if_index=loop_sw_if_idx,
- admin_up_down=1)
+ flags=InterfaceStatusFlags.IF_STATUS_API_FLAG_ADMIN_UP.value)
err_msg = 'Failed to set loopback interface state up on host ' \
'{host}'.format(host=nodes['DUT1']['host'])
papi_exec.add(cmd1, **args1).get_reply(err_msg)
@@ -960,22 +960,21 @@ class IPsecUtil(object):
args1 = dict(
sw_if_index=InterfaceUtil.get_interface_index(
nodes['DUT1'], if1_key),
- is_add=1,
- is_ipv6=1 if if2_ip.version == 6 else 0,
- del_all=0,
- address_length=96 if if2_ip.version == 6 else 24,
- address=getattr(if2_ip - 1, 'packed'))
+ is_add=True,
+ del_all=False,
+ prefix=IPUtil.create_prefix_object(
+ if2_ip - 1, 96 if if2_ip.version == 6 else 24)
+ )
err_msg = 'Failed to set IP address on interface {ifc} on host ' \
'{host}'.format(ifc=if1_key, host=nodes['DUT1']['host'])
papi_exec.add(cmd1, **args1).get_reply(err_msg)
# Configure IPsec tunnel interfaces
args1 = dict(
sw_if_index=loop_sw_if_idx,
- is_add=1,
- is_ipv6=1 if if1_ip.version == 6 else 0,
- del_all=0,
- address_length=128 if if1_ip.version == 6 else 32,
- address='')
+ is_add=True,
+ del_all=False,
+ prefix=None
+ )
cmd2 = 'ipsec_tunnel_if_add_del'
args2 = dict(
is_add=1,
@@ -1006,7 +1005,8 @@ class IPsecUtil(object):
if integ_alg:
ikeys.append(
gen_key(IPsecUtil.get_integ_alg_key_len(integ_alg)))
- args1['address'] = getattr(if1_ip + i * addr_incr, 'packed')
+ args1['prefix'] = IPUtil.create_prefix_object(
+ if1_ip + i * addr_incr, 128 if if1_ip.version == 6 else 32)
args2['local_spi'] = spi_1 + i
args2['remote_spi'] = spi_2 + i
args2['local_ip'] = IPUtil.create_ip_address_object(
@@ -1031,7 +1031,7 @@ class IPsecUtil(object):
# Configure IP routes
cmd1 = 'sw_interface_set_unnumbered'
args1 = dict(
- is_add=1,
+ is_add=True,
sw_if_index=InterfaceUtil.get_interface_index(
nodes['DUT1'], if1_key),
unnumbered_sw_if_index=0
@@ -1039,7 +1039,7 @@ class IPsecUtil(object):
cmd2 = 'sw_interface_set_flags'
args2 = dict(
sw_if_index=0,
- admin_up_down=1)
+ flags=InterfaceStatusFlags.IF_STATUS_API_FLAG_ADMIN_UP.value)
cmd3 = 'ip_route_add_del'
args3 = dict(
is_add=1,
@@ -1069,11 +1069,11 @@ class IPsecUtil(object):
args1 = dict(
sw_if_index=InterfaceUtil.get_interface_index(
nodes['DUT2'], if2_key),
- is_add=1,
- is_ipv6=1 if if2_ip.version == 6 else 0,
- del_all=0,
- address_length=96 if if2_ip.version == 6 else 24,
- address=if2_ip.packed)
+ is_add=True,
+ del_all=False,
+ prefix=IPUtil.create_prefix_object(
+ if2_ip, 96 if if2_ip.version == 6 else 24)
+ )
err_msg = 'Failed to set IP address on interface {ifc} on host ' \
'{host}'.format(ifc=if2_key, host=nodes['DUT2']['host'])
papi_exec.add(cmd1, **args1).get_reply(err_msg)
@@ -1137,7 +1137,7 @@ class IPsecUtil(object):
papi_exec.add(cmd1, **args1)
cmd1 = 'sw_interface_set_unnumbered'
args1 = dict(
- is_add=1,
+ is_add=True,
sw_if_index=InterfaceUtil.get_interface_index(
nodes['DUT2'], if2_key),
unnumbered_sw_if_index=0
@@ -1145,7 +1145,7 @@ class IPsecUtil(object):
cmd2 = 'sw_interface_set_flags'
args2 = dict(
sw_if_index=0,
- admin_up_down=1)
+ flags=InterfaceStatusFlags.IF_STATUS_API_FLAG_ADMIN_UP.value)
cmd3 = 'ip_route_add_del'
args3 = dict(
is_add=1,
diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py
index 982a345ef2..81dd20dc32 100644
--- a/resources/libraries/python/InterfaceUtil.py
+++ b/resources/libraries/python/InterfaceUtil.py
@@ -30,6 +30,61 @@ from resources.libraries.python.topology import NodeType, Topology
from resources.libraries.python.VPPUtil import VPPUtil
+class InterfaceStatusFlags(IntEnum):
+ """Interface status falgs."""
+ IF_STATUS_API_FLAG_ADMIN_UP = 1
+ IF_STATUS_API_FLAG_LINK_UP = 2
+
+
+class MtuProto(IntEnum):
+ """MTU protocol."""
+ MTU_PROTO_API_L3 = 0
+ MTU_PROTO_API_IP4 = 1
+ MTU_PROTO_API_IP6 = 2
+ MTU_PROTO_API_MPLS = 3
+ MTU_PROTO_API_N = 4
+
+
+class LinkDuplex(IntEnum):
+ """Link duplex"""
+ LINK_DUPLEX_API_UNKNOWN = 0
+ LINK_DUPLEX_API_HALF = 1
+ LINK_DUPLEX_API_FULL = 2
+
+
+class SubInterfaceFlags(IntEnum):
+ """Sub-interface flags."""
+ SUB_IF_API_FLAG_NO_TAGS = 1
+ SUB_IF_API_FLAG_ONE_TAG = 2
+ SUB_IF_API_FLAG_TWO_TAGS = 4
+ SUB_IF_API_FLAG_DOT1AD = 8
+ SUB_IF_API_FLAG_EXACT_MATCH = 16
+ SUB_IF_API_FLAG_DEFAULT = 32
+ SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY = 64
+ SUB_IF_API_FLAG_INNER_VLAN_ID_ANY = 128
+ SUB_IF_API_FLAG_DOT1AH = 256
+
+
+class RxMode(IntEnum):
+ """RX mode"""
+ RX_MODE_API_UNKNOWN = 0
+ RX_MODE_API_POLLING = 1
+ RX_MODE_API_INTERRUPT = 2
+ RX_MODE_API_ADAPTIVE = 3
+ RX_MODE_API_DEFAULT = 4
+
+
+class IfType(IntEnum):
+ """Interface type"""
+ # A hw interface
+ IF_API_TYPE_HARDWARE = 0
+ # A sub-interface
+ IF_API_TYPE_SUB = 1
+ IF_API_TYPE_P2P = 2
+ IF_API_TYPE_PIPE = 3
+
+
+# pylint: disable=invalid-name
class LinkBondLoadBalance(IntEnum):
"""Link bonding load balance."""
L2 = 0 # pylint: disable=invalid-name
@@ -126,17 +181,18 @@ class InterfaceUtil(object):
if node['type'] == NodeType.DUT:
if state == 'up':
- admin_up_down = 1
+ flags = InterfaceStatusFlags.IF_STATUS_API_FLAG_ADMIN_UP.value
elif state == 'down':
- admin_up_down = 0
+ flags = 0
else:
raise ValueError('Unexpected interface state: {state}'.format(
state=state))
cmd = 'sw_interface_set_flags'
err_msg = 'Failed to set interface state on host {host}'.format(
host=node['host'])
- args = dict(sw_if_index=sw_if_index,
- admin_up_down=admin_up_down)
+ args = dict(
+ sw_if_index=sw_if_index,
+ flags=flags)
with PapiSocketExecutor(node) as papi_exec:
papi_exec.add(cmd, **args).get_reply(err_msg)
elif node['type'] == NodeType.TG or node['type'] == NodeType.VM:
@@ -258,13 +314,12 @@ class InterfaceUtil(object):
not_ready = list()
out = InterfaceUtil.vpp_get_interface_data(node)
for interface in out:
- if interface.get('admin_up_down') == 1:
- if interface.get('link_up_down') != 1:
- not_ready.append(interface.get('interface_name'))
+ if interface.get('flags') == 1:
+ not_ready.append(interface.get('interface_name'))
if not not_ready:
break
else:
- logger.debug('Interfaces still in link-down state:\n{ifs} '
+ logger.debug('Interfaces still not in link-up state:\n{ifs} '
'\nWaiting...'.format(ifs=not_ready))
sleep(1)
else:
@@ -312,11 +367,16 @@ class InterfaceUtil(object):
:returns: Processed interface dump.
:rtype: dict
"""
- if_dump['interface_name'] = if_dump['interface_name'].rstrip('\x00')
- if_dump['tag'] = if_dump['tag'].rstrip('\x00')
- if_dump['l2_address'] = L2Util.bin_to_mac(if_dump['l2_address'])
- if_dump['b_dmac'] = L2Util.bin_to_mac(if_dump['b_dmac'])
- if_dump['b_smac'] = L2Util.bin_to_mac(if_dump['b_smac'])
+ if_dump['l2_address'] = str(if_dump['l2_address'])
+ if_dump['b_dmac'] = str(if_dump['b_dmac'])
+ if_dump['b_smac'] = str(if_dump['b_smac'])
+ if_dump['flags'] = if_dump['flags'].value
+ if_dump['type'] = if_dump['type'].value
+ if_dump['link_duplex'] = if_dump['link_duplex'].value
+ if_dump['sub_if_flags'] = if_dump['sub_if_flags'].value \
+ if hasattr(if_dump['sub_if_flags'], 'value') \
+ else int(if_dump['sub_if_flags'])
+
return if_dump
if interface is not None:
@@ -331,12 +391,15 @@ class InterfaceUtil(object):
param = ''
cmd = 'sw_interface_dump'
- args = dict(name_filter_valid=0,
- name_filter='')
+ args = dict(
+ name_filter_valid=False,
+ name_filter=''
+ )
err_msg = 'Failed to get interface dump on host {host}'.format(
host=node['host'])
with PapiSocketExecutor(node) as papi_exec:
details = papi_exec.add(cmd, **args).get_details(err_msg)
+ logger.debug('Received data:\n{d!r}'.format(d=details))
data = list() if interface is None else dict()
for dump in details:
@@ -724,8 +787,10 @@ class InterfaceUtil(object):
sw_if_index = InterfaceUtil.get_interface_index(node, interface)
cmd = 'create_vlan_subif'
- args = dict(sw_if_index=sw_if_index,
- vlan_id=int(vlan))
+ args = dict(
+ sw_if_index=sw_if_index,
+ vlan_id=int(vlan)
+ )
err_msg = 'Failed to create VLAN sub-interface on host {host}'.format(
host=node['host'])
with PapiSocketExecutor(node) as papi_exec:
@@ -930,20 +995,31 @@ class InterfaceUtil(object):
"""
subif_types = type_subif.split()
+ flags = 0
+ if 'no_tags' in subif_types:
+ flags = flags | SubInterfaceFlags.SUB_IF_API_FLAG_NO_TAGS
+ if 'one_tag' in subif_types:
+ flags = flags | SubInterfaceFlags.SUB_IF_API_FLAG_ONE_TAG
+ if 'two_tags' in subif_types:
+ flags = flags | SubInterfaceFlags.SUB_IF_API_FLAG_TWO_TAGS
+ if 'dot1ad' in subif_types:
+ flags = flags | SubInterfaceFlags.SUB_IF_API_FLAG_DOT1AD
+ if 'exact_match' in subif_types:
+ flags = flags | SubInterfaceFlags.SUB_IF_API_FLAG_EXACT_MATCH
+ if 'default_sub' in subif_types:
+ flags = flags | SubInterfaceFlags.SUB_IF_API_FLAG_DEFAULT
+ if type_subif == 'default_sub':
+ flags = flags | SubInterfaceFlags.SUB_IF_API_FLAG_INNER_VLAN_ID_ANY\
+ | SubInterfaceFlags.SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY
+
cmd = 'create_subif'
args = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, interface),
sub_id=int(sub_id),
- no_tags=1 if 'no_tags' in subif_types else 0,
- one_tag=1 if 'one_tag' in subif_types else 0,
- two_tags=1 if 'two_tags' in subif_types else 0,
- dot1ad=1 if 'dot1ad' in subif_types else 0,
- exact_match=1 if 'exact_match' in subif_types else 0,
- default_sub=1 if 'default_sub' in subif_types else 0,
- outer_vlan_id_any=1 if type_subif == 'default_sub' else 0,
- inner_vlan_id_any=1 if type_subif == 'default_sub' else 0,
+ sub_if_flags=flags.value if hasattr(flags, 'value') else int(flags),
outer_vlan_id=int(outer_vlan_id) if outer_vlan_id else 0,
- inner_vlan_id=int(inner_vlan_id) if inner_vlan_id else 0)
+ inner_vlan_id=int(inner_vlan_id) if inner_vlan_id else 0
+ )
err_msg = 'Failed to create sub-interface on host {host}'.format(
host=node['host'])
with PapiSocketExecutor(node) as papi_exec:
@@ -996,7 +1072,7 @@ class InterfaceUtil(object):
"""Create loopback interface on VPP node.
:param node: Node to create loopback interface on.
- :param mac: Optional MAC address for Loopback interface.
+ :param mac: Optional MAC address for loopback interface.
:type node: dict
:type mac: str
:returns: SW interface index.
@@ -1378,7 +1454,7 @@ class InterfaceUtil(object):
cmd = 'sw_interface_set_table'
args = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, interface),
- is_ipv6=1 if ipv6 else 0,
+ is_ipv6=ipv6,
vrf_id=int(table_id))
err_msg = 'Failed to assign interface {ifc} to FIB table'.format(
ifc=interface)
@@ -1567,8 +1643,12 @@ class InterfaceUtil(object):
cmd = 'sw_interface_set_rx_placement'
err_msg = "Failed to set interface RX placement to worker on host " \
"{host}!".format(host=node['host'])
- args = dict(sw_if_index=sw_if_index, queue_id=queue_id,
- worker_id=worker_id)
+ args = dict(
+ sw_if_index=sw_if_index,
+ queue_id=queue_id,
+ worker_id=worker_id,
+ is_main=False
+ )
with PapiSocketExecutor(node) as papi_exec:
papi_exec.add(cmd, **args).get_reply(err_msg)
diff --git a/resources/libraries/python/TestConfig.py b/resources/libraries/python/TestConfig.py
index 5887c11a9f..48f67e5a0f 100644
--- a/resources/libraries/python/TestConfig.py
+++ b/resources/libraries/python/TestConfig.py
@@ -17,7 +17,8 @@ from ipaddress import ip_address, AddressValueError
from robot.api import logger
from resources.libraries.python.Constants import Constants
-from resources.libraries.python.InterfaceUtil import InterfaceUtil
+from resources.libraries.python.InterfaceUtil import InterfaceUtil, \
+ InterfaceStatusFlags
from resources.libraries.python.IPUtil import IPUtil
from resources.libraries.python.PapiExecutor import PapiSocketExecutor
from resources.libraries.python.topology import Topology
@@ -145,11 +146,10 @@ class TestConfig(object):
cmd1 = 'sw_interface_add_del_address'
args1 = dict(
sw_if_index=InterfaceUtil.get_interface_index(node, node_vxlan_if),
- is_add=1,
- is_ipv6=1 if src_ip_addr_start.version == 6 else 0,
- del_all=0,
- address_length=128 if src_ip_addr_start.version == 6 else 32,
- address=None)
+ is_add=True,
+ del_all=False,
+ prefix=None
+ )
cmd2 = 'vxlan_add_del_tunnel'
args2 = dict(
is_add=1,
@@ -160,12 +160,14 @@ class TestConfig(object):
mcast_sw_if_index=Constants.BITWISE_NON_ZERO,
encap_vrf_id=0,
decap_next_index=Constants.BITWISE_NON_ZERO,
- vni=None)
+ vni=None
+ )
cmd3 = 'create_vlan_subif'
args3 = dict(
sw_if_index=InterfaceUtil.get_interface_index(
node, node_vlan_if),
- vlan_id=None)
+ vlan_id=None
+ )
with PapiSocketExecutor(node) as papi_exec:
for i in xrange(0, vxlan_count):
@@ -177,7 +179,8 @@ class TestConfig(object):
"has been reached.")
vxlan_count = i
break
- args1['address'] = getattr(src_ip, 'packed')
+ args1['prefix'] = IPUtil.create_prefix_object(
+ src_ip, 128 if src_ip_addr_start.version == 6 else 32)
args2['src_address'] = getattr(src_ip, 'packed')
args2['dst_address'] = getattr(dst_ip, 'packed')
args2['vni'] = int(vni_start) + i
@@ -250,10 +253,12 @@ class TestConfig(object):
cmd = 'sw_interface_set_flags'
args1 = dict(
sw_if_index=None,
- admin_up_down=1)
+ flags=InterfaceStatusFlags.IF_STATUS_API_FLAG_ADMIN_UP.value
+ )
args2 = dict(
sw_if_index=None,
- admin_up_down=1)
+ flags=InterfaceStatusFlags.IF_STATUS_API_FLAG_ADMIN_UP.value
+ )
with PapiSocketExecutor(node) as papi_exec:
for i in xrange(0, vxlan_count):
diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py
index 8b7b6891ac..8f9b593902 100644
--- a/resources/libraries/python/VPPUtil.py
+++ b/resources/libraries/python/VPPUtil.py
@@ -193,16 +193,25 @@ class VPPUtil(object):
"""
cmd = 'sw_interface_dump'
- args = dict(name_filter_valid=0, name_filter='')
+ args = dict(
+ name_filter_valid=False,
+ name_filter=''
+ )
err_msg = 'Failed to get interface dump on host {host}'.format(
host=node['host'])
with PapiSocketExecutor(node) as papi_exec:
details = papi_exec.add(cmd, **args).get_details(err_msg)
for if_dump in details:
- if_dump['interface_name'] = if_dump['interface_name'].rstrip('\x00')
- if_dump['tag'] = if_dump['tag'].rstrip('\x00')
- if_dump['l2_address'] = L2Util.bin_to_mac(if_dump['l2_address'])
+ if_dump['l2_address'] = str(if_dump['l2_address'])
+ if_dump['b_dmac'] = str(if_dump['b_dmac'])
+ if_dump['b_smac'] = str(if_dump['b_smac'])
+ if_dump['flags'] = if_dump['flags'].value
+ if_dump['type'] = if_dump['type'].value
+ if_dump['link_duplex'] = if_dump['link_duplex'].value
+ if_dump['sub_if_flags'] = if_dump['sub_if_flags'].value \
+ if hasattr(if_dump['sub_if_flags'], 'value') \
+ else int(if_dump['sub_if_flags'])
# TODO: return only base data
logger.trace('Interface data of host {host}:\n{details}'.format(
host=node['host'], details=details))