Use interface key instead of interface name. 32/1032/34
authorMiroslav Miklus <mmiklus@cisco.com>
Sun, 8 May 2016 12:11:51 +0000 (14:11 +0200)
committerJan Gelety <jgelety@cisco.com>
Tue, 28 Jun 2016 00:15:03 +0000 (00:15 +0000)
JIRA: CSIT-141

Change-Id: I75cef6d570ab45ea9c4af838b6bf68cefc7c1a91
Signed-off-by: Miroslav Miklus <mmiklus@cisco.com>
21 files changed:
resources/libraries/python/IPUtil.py
resources/libraries/python/IPv4NodeAddress.py
resources/libraries/python/IPv4Setup.py
resources/libraries/python/IPv6NodesAddr.py
resources/libraries/python/IPv6Setup.py
resources/libraries/python/IPv6Util.py
resources/libraries/python/InterfaceUtil.py
resources/libraries/python/ssh.py
resources/libraries/python/topology.py
resources/libraries/robot/bridge_domain.robot
resources/libraries/robot/dhcp_client.robot
resources/libraries/robot/double_qemu_setup.robot
resources/libraries/robot/gre.robot
resources/libraries/robot/ipv4.robot
resources/libraries/robot/ipv6.robot
resources/libraries/robot/l2_traffic.robot
resources/libraries/robot/traffic.robot
resources/libraries/robot/vxlan.robot
tests/suites/fds_related_tests/provider_network.robot
tests/suites/vxlan/vxlan_bd_untagged.robot
tests/suites/vxlan/vxlan_xconnect_untagged.robot

index e364e60..323c75b 100644 (file)
@@ -17,30 +17,42 @@ from ipaddress import IPv4Network
 from resources.libraries.python.ssh import SSH
 from resources.libraries.python.constants import Constants
 
+from resources.libraries.python.topology import Topology
 
 class IPUtil(object):
     """Common IP utilities"""
 
     @staticmethod
-    def vpp_ip_probe(node, interface, addr):
+    def vpp_ip_probe(node, interface, addr, if_type="key"):
         """Run ip probe on VPP node.
 
         :param node: VPP node.
-        :param interface: Interface name.
+        :param interface: Interface key or name.
         :param addr: IPv4/IPv6 address.
+        :param if_type: Interface type
         :type node: dict
         :type interface: str
         :type addr: str
+        :type if_type: str
+        :raises ValueError: If the if_type is unknown.
+        :raises Exception: If vpp probe fails.
         """
         ssh = SSH()
         ssh.connect(node)
 
+        if if_type == "key":
+            iface_name = Topology.get_interface_name(node, interface)
+        elif if_type == "name":
+            iface_name = interface
+        else:
+            raise ValueError("if_type unknown: {}".format(if_type))
+
         cmd = "{c}".format(c=Constants.VAT_BIN_NAME)
-        cmd_input = 'exec ip probe {dev} {ip}'.format(dev=interface, ip=addr)
+        cmd_input = 'exec ip probe {dev} {ip}'.format(dev=iface_name, ip=addr)
         (ret_code, _, _) = ssh.exec_command_sudo(cmd, cmd_input)
         if int(ret_code) != 0:
             raise Exception('VPP ip probe {dev} {ip} failed on {h}'.format(
-                dev=interface, ip=addr, h=node['host']))
+                dev=iface_name, ip=addr, h=node['host']))
 
 
 def convert_ipv4_netmask_prefix(network):
index 25179a3..617377d 100644 (file)
@@ -79,7 +79,8 @@ def get_variables(nodes, networks=IPV4_NETWORKS[:]):
         port_idx = 0
         ports = {}
         for node in nodes.values():
-            if_name = topo.get_interface_by_link_name(node, link)
+            if_key = topo.get_interface_by_link_name(node, link)
+            if_name = topo.get_interface_name(node, if_key)
             if if_name is not None:
                 port = {'addr': str(next(net_hosts)),
                         'node': node['host'],
index 577b225..d89eeed 100644 (file)
@@ -173,18 +173,18 @@ class Dut(IPv4Node):
         # TODO: check return value
         VatExecutor.cmd_from_template(self.node_info, script, **args)
 
-    def set_arp(self, interface, ip_address, mac_address):
+    def set_arp(self, iface_key, ip_address, mac_address):
         """Set entry in ARP cache.
 
-        :param interface: Interface name.
+        :param iface_key: Interface key.
         :param ip_address: IP address.
         :param mac_address: MAC address.
-        :type interface: str
+        :type iface_key: str
         :type ip_address: str
         :type mac_address: str
         """
         self.exec_vat('add_ip_neighbor.vat',
-                      sw_if_index=self.get_sw_if_index(interface),
+                      sw_if_index=self.get_sw_if_index(iface_key),
                       ip_address=ip_address, mac_address=mac_address)
 
     def set_ip(self, interface, address, prefix_length):
@@ -255,7 +255,8 @@ class IPv4Setup(object):
                     continue
                 if node['type'] != NodeType.DUT:
                     continue
-                get_node(node).set_ip(port['if'], port['addr'], net['prefix'])
+                iface_key = topo.get_interface_by_name(node, port['if'])
+                get_node(node).set_ip(iface_key, port['addr'], net['prefix'])
                 interfaces.append((node, port['if']))
 
         return interfaces
@@ -263,18 +264,19 @@ class IPv4Setup(object):
     @staticmethod
     @keyword('Get IPv4 address of node "${node}" interface "${port}" '
              'from "${nodes_addr}"')
-    def get_ip_addr(node, interface, nodes_addr):
+    def get_ip_addr(node, iface_key, nodes_addr):
         """Return IPv4 address of the node port.
 
         :param node: Node in the topology.
-        :param interface: Interface name of the node.
+        :param iface_key: Interface key of the node.
         :param nodes_addr: Nodes IPv4 addresses.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :type nodes_addr: dict
         :return: IPv4 address.
         :rtype: str
         """
+        interface = Topology.get_interface_name(node, iface_key)
         for net in nodes_addr.values():
             for port in net['ports'].values():
                 host = port.get('node')
@@ -305,27 +307,25 @@ class IPv4Setup(object):
         for node in nodes_info.values():
             if node['type'] == NodeType.TG:
                 continue
-            for interface, interface_data in node['interfaces'].iteritems():
-                interface_name = interface_data['name']
+            for iface_key in node['interfaces'].keys():
                 adj_node, adj_int = Topology.\
-                    get_adjacent_node_and_interface(nodes_info, node,
-                                                    interface_name)
-                ip_address = IPv4Setup.get_ip_addr(adj_node, adj_int['name'],
+                    get_adjacent_node_and_interface(nodes_info, node, iface_key)
+                ip_address = IPv4Setup.get_ip_addr(adj_node, adj_int,
                                                    nodes_addr)
-                mac_address = adj_int['mac_address']
-                get_node(node).set_arp(interface_name, ip_address, mac_address)
+                mac_address = Topology.get_interface_mac(adj_node, adj_int)
+                get_node(node).set_arp(iface_key, ip_address, mac_address)
 
     @staticmethod
-    def add_arp_on_dut(node, interface, ip_address, mac_address):
+    def add_arp_on_dut(node, iface_key, ip_address, mac_address):
         """Set ARP cache entree on DUT node.
 
         :param node: VPP Node in the topology.
-        :param interface: Interface name of the node.
+        :param iface_key: Interface key.
         :param ip_address: IP address of the interface.
         :param mac_address: MAC address of the interface.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :type ip_address: str
         :type mac_address: str
         """
-        get_node(node).set_arp(interface, ip_address, mac_address)
+        get_node(node).set_arp(iface_key, ip_address, mac_address)
index 133c861..0482cf3 100644 (file)
@@ -52,7 +52,8 @@ def get_variables(nodes, networks=IPV6_NETWORKS):
         port_idx = 0
         ports = {}
         for node in nodes.values():
-            if_name = topo.get_interface_by_link_name(node, link)
+            if_key = topo.get_interface_by_link_name(node, link)
+            if_name = topo.get_interface_name(node, if_key)
             if if_name is not None:
                 port = {'addr': str(next(net_hosts)),
                         'node': node['host'],
index 12f6de7..2c68c33 100644 (file)
@@ -78,7 +78,8 @@ class IPv6Setup(object):
                 if node is None:
                     continue
                 if node['type'] == NodeType.DUT:
-                    self.vpp_set_if_ipv6_addr(node, port['if'], port['addr'],
+                    port_key = topo.get_interface_by_name(node, port['if'])
+                    self.vpp_set_if_ipv6_addr(node, port_key, port['addr'],
                                               net['prefix'])
 
                     interfaces.append((node, port['if']))
@@ -156,19 +157,20 @@ class IPv6Setup(object):
             raise Exception('TG ifconfig failed')
 
     @staticmethod
-    def vpp_set_if_ipv6_addr(node, interface, addr, prefix):
+    def vpp_set_if_ipv6_addr(node, iface_key, addr, prefix):
         """Set IPv6 address on VPP.
 
         :param node: VPP node.
-        :param interface: Node interface.
+        :param iface_key: Node interface key.
         :param addr: IPv6 address.
         :param prefix: IPv6 address prefix.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :type addr: str
         :type prefix: str
         """
-        sw_if_index = Topology.get_interface_sw_index(node, interface)
+        topo = Topology()
+        sw_if_index = Topology.get_interface_sw_index(node, iface_key)
         with VatTerminal(node) as vat:
             vat.vat_terminal_exec_cmd_from_template('add_ip_address.vat',
                                                     sw_if_index=sw_if_index,
@@ -274,11 +276,8 @@ class IPv6Setup(object):
         for node in nodes.values():
             if node['type'] == NodeType.TG:
                 continue
-            for port_k, port_v in node['interfaces'].items():
-                if_name = port_v.get('name')
-                if if_name is None:
-                    continue
-                self.vpp_ra_suppress_link_layer(node, if_name)
+            for port_k in node['interfaces'].keys():
+                self.vpp_ra_suppress_link_layer(node, port_k)
 
     @staticmethod
     def get_link_address(link, nodes_addr):
index 35ec8d5..437a7c0 100644 (file)
@@ -81,18 +81,19 @@ class IPv6Util(object):
         return IPv6Util.ipv6_ping(src_node, dst_ip, cnt, size, timeout)
 
     @staticmethod
-    def get_node_port_ipv6_address(node, interface, nodes_addr):
+    def get_node_port_ipv6_address(node, iface_key, nodes_addr):
         """Return IPv6 address of the node port.
 
         :param node: Node in the topology.
-        :param interface: Interface name of the node.
+        :param iface_key: Interface key of the node.
         :param nodes_addr: Nodes IPv6 addresses.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :type nodes_addr: dict
         :return: IPv6 address string.
         :rtype: str
         """
+        interface = Topology.get_interface_name(node, iface_key)
         for net in nodes_addr.values():
             for port in net['ports'].values():
                 host = port.get('node')
index a84d595..7bf0584 100644 (file)
@@ -32,19 +32,36 @@ class InterfaceUtil(object):
     __UDEV_IF_RULES_FILE = '/etc/udev/rules.d/10-network.rules'
 
     @staticmethod
-    def set_interface_state(node, interface, state):
+    def set_interface_state(node, interface, state, if_type="key"):
         """Set interface state on a node.
 
         Function can be used for DUTs as well as for TGs.
 
         :param node: Node where the interface is.
-        :param interface: Interface name or sw_if_index.
+        :param interface: Interface key or sw_if_index or name.
         :param state: One of 'up' or 'down'.
+        :param if_type: Interface type
         :type node: dict
         :type interface: str or int
         :type state: str
+        :type if_type: str
         :return: nothing
         """
+
+        if if_type == "key":
+            if isinstance(interface, basestring):
+                sw_if_index = Topology.get_interface_sw_index(node, interface)
+                iface_name = Topology.get_interface_name(node, interface)
+            else:
+                sw_if_index = interface
+        elif if_type == "name":
+            iface_key = Topology.get_interface_by_name(node, interface)
+            if iface_key is not None:
+                sw_if_index = Topology.get_interface_sw_index(node, iface_key)
+            iface_name = interface
+        else:
+            raise ValueError("if_type unknown: {}".format(if_type))
+
         if node['type'] == NodeType.DUT:
             if state == 'up':
                 state = 'admin-up'
@@ -52,33 +69,26 @@ class InterfaceUtil(object):
                 state = 'admin-down'
             else:
                 raise ValueError('Unexpected interface state: {}'.format(state))
-
-            if isinstance(interface, basestring):
-                sw_if_index = Topology.get_interface_sw_index(node, interface)
-            else:
-                sw_if_index = interface
-
             VatExecutor.cmd_from_template(node, 'set_if_state.vat',
                                           sw_if_index=sw_if_index, state=state)
-
         elif node['type'] == NodeType.TG or node['type'] == NodeType.VM:
-            cmd = 'ip link set {} {}'.format(interface, state)
+            cmd = 'ip link set {} {}'.format(iface_name, state)
             exec_cmd_no_error(node, cmd, sudo=True)
         else:
             raise Exception('Node {} has unknown NodeType: "{}"'.
                             format(node['host'], node['type']))
 
     @staticmethod
-    def set_interface_ethernet_mtu(node, interface, mtu):
+    def set_interface_ethernet_mtu(node, iface_key, mtu):
         """Set Ethernet MTU for specified interface.
 
         Function can be used only for TGs.
 
         :param node: Node where the interface is.
-        :param interface: Interface name.
+        :param interface: Interface key from topology file.
         :param mtu: MTU to set.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :type mtu: int
         :return: nothing
         """
@@ -86,7 +96,8 @@ class InterfaceUtil(object):
             ValueError('Node {}: Setting Ethernet MTU for interface '
                        'on DUT nodes not supported', node['host'])
         elif node['type'] == NodeType.TG:
-            cmd = 'ip link set {} mtu {}'.format(interface, mtu)
+            iface_name = Topology.get_interface_name(node, iface_key)
+            cmd = 'ip link set {} mtu {}'.format(iface_name, mtu)
             exec_cmd_no_error(node, cmd, sudo=True)
         else:
             raise ValueError('Node {} has unknown NodeType: "{}"'.
@@ -102,8 +113,8 @@ class InterfaceUtil(object):
         :type node: dict
         :return: nothing
         """
-        for ifc in node['interfaces'].values():
-            InterfaceUtil.set_interface_ethernet_mtu(node, ifc['name'], 1500)
+        for ifc in node['interfaces']:
+            InterfaceUtil.set_interface_ethernet_mtu(node, ifc, 1500)
 
     @staticmethod
     def vpp_node_interfaces_ready_wait(node, timeout=10):
@@ -444,7 +455,8 @@ class InterfaceUtil(object):
         :return: Name and index of created subinterface.
         :rtype: tuple
         """
-        sw_if_index = Topology.get_interface_sw_index(node, interface)
+        iface_key = Topology.get_interface_by_name(node, interface)
+        sw_if_index = Topology.get_interface_sw_index(node, iface_key)
 
         output = VatExecutor.cmd_from_template(node, "create_vlan_subif.vat",
                                                sw_if_index=sw_if_index,
index 67193c1..a96a55f 100644 (file)
@@ -250,7 +250,7 @@ def exec_cmd(node, cmd, timeout=None, sudo=False):
     try:
         ssh.connect(node)
     except Exception, e:
-        logger.error("Failed to connect to node" + e)
+        logger.error("Failed to connect to node" + str(e))
         return None
 
     try:
index 7e94007..80cbb1f 100644 (file)
@@ -58,9 +58,92 @@ class Topology(object):
     """Topology data manipulation and extraction methods.
 
     Defines methods used for manipulation and extraction of data from
-    the used topology.
+    the active topology.
+
+    "Active topology" contains initially data from the topology file and can be
+    extended with additional data from the DUTs like internal interface indexes
+    or names. Additional data which can be filled to the active topology are
+        - additional internal representation (index, name, ...)
+        - operational data (dynamic ports)
+
+    To access the port data it is recommended to use a port key because the key
+    does not rely on the data retrieved from nodes, this allows to call most of
+    the methods without having filled active topology with internal nodes data.
     """
 
+    @staticmethod
+    def add_new_port(node, ptype):
+        """Add new port to the node to active topology.
+
+        :param node: Node to add new port on.
+        :param ptype: Port type, used as key prefix.
+        :type node: dict
+        :type ptype: str
+        :return: Port key or None
+        :rtype: string or None
+        """
+        max_ports = 1000000
+        iface = None
+        for i in range(1, max_ports):
+            if node['interfaces'].get(str(ptype) + str(i)) is None:
+                iface = str(ptype) + str(i)
+                node['interfaces'][iface] = dict()
+                break
+        return iface
+
+    @staticmethod
+    def remove_all_ports(node, ptype):
+        """Remove all ports with ptype as prefix.
+
+        :param node: Node to remove ports on.
+        :param: ptype: Port type, used as key prefix.
+        :type node: dict
+        :type ptype: str
+        :return: Nothing
+        """
+        for if_key in list(node['interfaces']):
+            if if_key.startswith(str(ptype)):
+                node['interfaces'].pop(if_key)
+
+    @staticmethod
+    def update_interface_sw_if_index(node, iface_key, sw_if_index):
+        """Update sw_if_index on the interface from the node.
+
+        :param node: Node to update sw_if_index on.
+        :param iface_key: Topology key of the interface.
+        :param sw_if_index: Internal index to store.
+        :type node: dict
+        :type iface_key: str
+        :type sw_if_index: int
+        """
+        node['interfaces'][iface_key]['vpp_sw_index'] = int(sw_if_index)
+
+    @staticmethod
+    def update_interface_mac_address(node, iface_key, mac_address):
+        """Update mac_address on the interface from the node.
+
+        :param node: Node to update MAC on.
+        :param iface_key: Topology key of the interface.
+        :param mac_address: MAC address.
+        :type node: dict
+        :type iface_key: str
+        :type mac_address: str
+        """
+        node['interfaces'][iface_key]['mac_address'] = str(mac_address)
+
+    @staticmethod
+    def update_interface_vhost_socket(node, iface_key, vhost_socket):
+        """Update vhost socket name on the interface from the node.
+
+        :param node: Node to update socket name on.
+        :param iface_key: Topology key of the interface.
+        :param vhost_socket: Path to named socket on node.
+        :type node: dict
+        :type iface_key: str
+        :type vhost_socket: str
+        """
+        node['interfaces'][iface_key]['vhost_socket'] = str(vhost_socket)
+
     @staticmethod
     def get_node_by_hostname(nodes, hostname):
         """Get node from nodes of the topology by hostname.
@@ -99,35 +182,59 @@ class Topology(object):
 
     @staticmethod
     def _get_interface_by_key_value(node, key, value):
-        """Return node interface name according to key and value.
+        """Return node interface key from topology file
+        according to key and value.
 
         :param node: The node dictionary.
         :param key: Key by which to select the interface.
         :param value: Value that should be found using the key.
-        :return:
+        :type node: dict
+        :type key: string
+        :type value: string
+        :return: Interface key from topology file
+        :rtype: string
         """
         interfaces = node['interfaces']
         retval = None
-        for interface in interfaces.values():
-            k_val = interface.get(key)
+        for if_key, if_val in interfaces.iteritems():
+            k_val = if_val.get(key)
             if k_val is not None:
                 if k_val == value:
-                    retval = interface['name']
+                    retval = if_key
                     break
         return retval
 
-    def get_interface_by_link_name(self, node, link_name):
-        """Return interface name of link on node.
+    @staticmethod
+    def get_interface_by_name(node, iface_name):
+        """Return interface key based on name from DUT/TG.
+
+        This method returns interface key based on interface name
+        retrieved from the DUT, or TG.
+
+        :param node: The node topology dictionary.
+        :param iface_name: Interface name (string form).
+        :type node: dict
+        :type iface_name: string
+        :return: Interface key.
+        :rtype: str
+        """
+        return Topology._get_interface_by_key_value(node, "name", iface_name)
+
+    @staticmethod
+    def get_interface_by_link_name(node, link_name):
+        """Return interface key of link on node.
 
         This method returns the interface name associated with a given link
         for a given node.
 
-        :param link_name: Name of the link that a interface is connected to.
         :param node: The node topology dictionary.
-        :return: Interface name of the interface connected to the given link.
+        :param link_name: Name of the link that a interface is connected to.
+        :type node: dict
+        :type link_name: string
+        :return: Interface key of the interface connected to the given link.
         :rtype: str
         """
-        return self._get_interface_by_key_value(node, "link", link_name)
+        return Topology._get_interface_by_key_value(node, "link", link_name)
 
     def get_interfaces_by_link_names(self, node, link_names):
         """Return dictionary of dictionaries {"interfaceN", interface name}.
@@ -135,9 +242,11 @@ class Topology(object):
         This method returns the interface names associated with given links
         for a given node.
 
+        :param node: The node topology directory.
         :param link_names: List of names of the link that a interface is
         connected to.
-        :param node: The node topology directory.
+        :type node: dict
+        :type link_names: list
         :return: Dictionary of interface names that are connected to the given
         links.
         :rtype: dict
@@ -146,155 +255,119 @@ class Topology(object):
         interface_key_tpl = "interface{}"
         interface_number = 1
         for link_name in link_names:
-            interface_name = self.get_interface_by_link_name(node, link_name)
+            interface = self.get_interface_by_link_name(node, link_name)
+            interface_name = self.get_interface_name(node, interface)
             interface_key = interface_key_tpl.format(str(interface_number))
             retval[interface_key] = interface_name
             interface_number += 1
         return retval
 
-    def get_interface_by_sw_index(self, node, sw_index):
+    @staticmethod
+    def get_interface_by_sw_index(node, sw_index):
         """Return interface name of link on node.
 
         This method returns the interface name associated with a software
         interface index assigned to the interface by vpp for a given node.
 
-        :param sw_index: Sw_index of the link that a interface is connected to.
         :param node: The node topology dictionary.
+        :param sw_index: Sw_index of the link that a interface is connected to.
+        :type node: dict
+        :type sw_index: int
         :return: Interface name of the interface connected to the given link.
         :rtype: str
         """
-        return self._get_interface_by_key_value(node, "vpp_sw_index", sw_index)
+        return Topology._get_interface_by_key_value(node, "vpp_sw_index", sw_index)
 
     @staticmethod
-    def get_interface_sw_index(node, interface):
+    def get_interface_sw_index(node, iface_key):
         """Get VPP sw_if_index for the interface.
 
         :param node: Node to get interface sw_if_index on.
-        :param interface: Interface identifier.
+        :param iface_key: Interface key from topology file, or sw_index.
         :type node: dict
-        :type interface: str or int
+        :type iface_key: str/int
         :return: Return sw_if_index or None if not found.
         """
         try:
-            return int(interface)
-        except ValueError:
-            for port in node['interfaces'].values():
-                port_name = port.get('name')
-                if port_name == interface:
-                    return port.get('vpp_sw_index')
+            if isinstance(iface_key, basestring):
+                return node['interfaces'][iface_key].get('vpp_sw_index')
+            #FIXME: use only iface_key, do not use integer
+            else:
+                return int(iface_key)
+        except (KeyError, ValueError):
             return None
 
     @staticmethod
-    def get_interface_mtu(node, interface):
+    def get_interface_mtu(node, iface_key):
         """Get interface MTU.
 
         Returns physical layer MTU (max. size of Ethernet frame).
         :param node: Node to get interface MTU on.
-        :param interface: Interface name.
+        :param iface_key: Interface key from topology file.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :return: MTU or None if not found.
         :rtype: int
         """
-        for port in node['interfaces'].values():
-            port_name = port.get('name')
-            if port_name == interface:
-                return port.get('mtu')
-
-        return None
+        try:
+            return node['interfaces'][iface_key].get('mtu')
+        except KeyError:
+            return None
 
     @staticmethod
-    def get_interface_mac_by_port_key(node, port_key):
-        """Get MAC address for the interface based on port key.
+    def get_interface_name(node, iface_key):
+        """Get interface name (retrieved from DUT/TG).
 
-        :param node: Node to get interface mac on.
-        :param port_key: Dictionary key name of interface.
+        Returns name in string format, retrieved from the node.
+        :param node: Node to get interface name on.
+        :param iface_key: Interface key from topology file.
         :type node: dict
-        :type port_key: str
-        :return: Return MAC or None if not found.
+        :type iface_key: str
+        :return: Interface name or None if not found.
+        :rtype: int
         """
-        for port_name, port_data in node['interfaces'].iteritems():
-            if port_name == port_key:
-                return port_data['mac_address']
-
-        return None
+        try:
+            return node['interfaces'][iface_key].get('name')
+        except KeyError:
+            return None
 
     @staticmethod
-    def get_interface_mac(node, interface):
+    def get_interface_mac(node, iface_key):
         """Get MAC address for the interface.
 
-        :param node: Node to get interface sw_index on.
-        :param interface: Interface name.
+        :param node: Node to get interface mac on.
+        :param iface_key: Interface key from topology file.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :return: Return MAC or None if not found.
         """
-        for port in node['interfaces'].values():
-            port_name = port.get('name')
-            if port_name == interface:
-                return port.get('mac_address')
-
-        return None
-
-    @staticmethod
-    def get_adjacent_node_and_interface_by_key(nodes_info, node, port_key):
-        """Get node and interface adjacent to specified interface
-        on local network.
-
-        :param nodes_info: Dictionary containing information on all nodes
-        in topology.
-        :param node: Node that contains specified interface.
-        :param port_key: Interface port key.
-        :type nodes_info: dict
-        :type node: dict
-        :type port_key: str
-        :return: Return (node, interface info) tuple or None if not found.
-        :rtype: (dict, dict)
-        """
-        link_name = None
-        # get link name where the interface belongs to
-        for port_name, port_data in node['interfaces'].iteritems():
-            if port_name == 'mgmt':
-                continue
-            if port_name == port_key:
-                link_name = port_data['link']
-                break
-
-        if link_name is None:
+        try:
+            return node['interfaces'][iface_key].get('mac_address')
+        except KeyError:
             return None
 
-        # find link
-        for node_data in nodes_info.values():
-            # skip self
-            if node_data['host'] == node['host']:
-                continue
-            for interface, interface_data \
-                    in node_data['interfaces'].iteritems():
-                if 'link' not in interface_data:
-                    continue
-                if interface_data['link'] == link_name:
-                    return node_data, node_data['interfaces'][interface]
-
     @staticmethod
-    def get_adjacent_node_and_interface(nodes_info, node, interface_name):
+    def get_adjacent_node_and_interface(nodes_info, node, iface_key):
         """Get node and interface adjacent to specified interface
         on local network.
 
         :param nodes_info: Dictionary containing information on all nodes
         in topology.
         :param node: Node that contains specified interface.
-        :param interface_name: Interface name.
+        :param iface_key: Interface key from topology file.
         :type nodes_info: dict
         :type node: dict
-        :type interface_name: str
-        :return: Return (node, interface info) tuple or None if not found.
-        :rtype: (dict, dict)
+        :type iface_key: str
+        :return: Return (node, interface_key) tuple or None if not found.
+        :rtype: (dict, str)
         """
         link_name = None
         # get link name where the interface belongs to
-        for port_name, port_data in node['interfaces'].iteritems():
-            if port_data['name'] == interface_name:
-                link_name = port_data['link']
+        for if_key, if_val in node['interfaces'].iteritems():
+            if if_key == 'mgmt':
+                continue
+            if if_key == iface_key:
+                link_name = if_val['link']
                 break
 
         if link_name is None:
@@ -305,42 +378,42 @@ class Topology(object):
             # skip self
             if node_data['host'] == node['host']:
                 continue
-            for interface, interface_data \
+            for if_key, if_val \
                     in node_data['interfaces'].iteritems():
-                if 'link' not in interface_data:
+                if 'link' not in if_val:
                     continue
-                if interface_data['link'] == link_name:
-                    return node_data, node_data['interfaces'][interface]
+                if if_val['link'] == link_name:
+                    return node_data, if_key
 
     @staticmethod
-    def get_interface_pci_addr(node, interface):
+    def get_interface_pci_addr(node, iface_key):
         """Get interface PCI address.
 
         :param node: Node to get interface PCI address on.
-        :param interface: Interface name.
+        :param iface_key: Interface key from topology file.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :return: Return PCI address or None if not found.
         """
-        for port in node['interfaces'].values():
-            if interface == port.get('name'):
-                return port.get('pci_address')
-        return None
+        try:
+            return node['interfaces'][iface_key].get('pci_address')
+        except KeyError:
+            return None
 
     @staticmethod
-    def get_interface_driver(node, interface):
+    def get_interface_driver(node, iface_key):
         """Get interface driver.
 
         :param node: Node to get interface driver on.
-        :param interface: Interface name.
+        :param iface_key: Interface key from topology file.
         :type node: dict
-        :type interface: str
+        :type iface_key: str
         :return: Return interface driver or None if not found.
         """
-        for port in node['interfaces'].values():
-            if interface == port.get('name'):
-                return port.get('driver')
-        return None
+        try:
+            return node['interfaces'][iface_key].get('driver')
+        except KeyError:
+            return None
 
     @staticmethod
     def get_node_link_mac(node, link_name):
@@ -442,8 +515,8 @@ class Topology(object):
         else:
             return connecting_links[0]
 
-    @keyword('Get egress interfaces on "${node1}" for link with "${node2}"')
-    def get_egress_interfaces_for_nodes(self, node1, node2):
+    @keyword('Get egress interfaces name on "${node1}" for link with "${node2}"')
+    def get_egress_interfaces_name_for_nodes(self, node1, node2):
         """Get egress interfaces on node1 for link with node2.
 
         :param node1: First node, node to get egress interface on.
@@ -469,19 +542,19 @@ class Topology(object):
             interfaces.append(name)
         return interfaces
 
-    @keyword('Get first egress interface on "${node1}" for link with '
+    @keyword('Get first egress interface name on "${node1}" for link with '
              '"${node2}"')
     def get_first_egress_interface_for_nodes(self, node1, node2):
         """Get first egress interface on node1 for link with node2.
 
-        :param node1: First node, node to get egress interface on.
+        :param node1: First node, node to get egress interface name on.
         :param node2: Second node.
         :type node1: dict
         :type node2: dict
-        :return: Egress interface.
+        :return: Egress interface name.
         :rtype: str
         """
-        interfaces = self.get_egress_interfaces_for_nodes(node1, node2)
+        interfaces = self.get_egress_interfaces_name_for_nodes(node1, node2)
         if not interfaces:
             raise RuntimeError('No egress interface for nodes')
         return interfaces[0]
index 96af11d..ac0fea8 100644 (file)
 | | ${vhost1}= | Get Vhost User If Name By Sock | ${vm} | ${sock1}
 | | ${vhost2}= | Get Vhost User If Name By Sock | ${vm} | ${sock2}
 | | Linux Add Bridge | ${vm} | ${br} | ${vhost1} | ${vhost2}
-| | Set Interface State | ${vm} | ${vhost1} | up
-| | Set Interface State | ${vm} | ${vhost2} | up
-| | Set Interface State | ${vm} | ${br} | up
+| | Set Interface State | ${vm} | ${vhost1} | up | if_type=name
+| | Set Interface State | ${vm} | ${vhost2} | up | if_type=name
+| | Set Interface State | ${vm} | ${br} | up | if_type=name
 | | Set Test Variable | ${vm_node} | ${vm}
 
 | VPP Vhost interfaces for L2BD forwarding are setup
index 0dd5e7b..c3c4645 100644 (file)
@@ -42,7 +42,8 @@
 | | ... | \| eth2 \| 08:00:27:66:b8:57 \| client-hostname \|
 | | ...
 | | [Arguments] | ${tg_node} | ${interface} | ${src_mac} | ${hostname}=${EMPTY}
-| | ${args}= | Catenate | --rx_if | ${interface} | --rx_src_mac | ${src_mac}
+| | ${interface_name}= | Get interface name | ${tg_node} | ${interface}
+| | ${args}= | Catenate | --rx_if | ${interface_name} | --rx_src_mac | ${src_mac}
 | | ${args}= | Run Keyword If | "${hostname}" == "" | Set Variable | ${args}
 | | ...      | ELSE | Catenate | ${args} | --hostname | ${hostname}
 | | Run Traffic Script On Node | dhcp/check_dhcp_discover.py
@@ -92,7 +93,8 @@
 | | [Arguments] | ${tg_node} | ${tg_interface} | ${server_mac} | ${server_ip}
 | | ... | ${client_mac} | ${client_ip} | ${client_mask}
 | | ... | ${hostname}=${EMPTY} | ${offer_xid}=${EMPTY}
-| | ${args}= | Catenate | --rx_if | ${tg_interface} | --server_mac
+| | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
+| | ${args}= | Catenate | --rx_if | ${tg_interface_name} | --server_mac
 | | ... | ${server_mac} | --server_ip | ${server_ip} | --client_mac
 | | ... | ${client_mac} | --client_ip | ${client_ip} | --client_mask
 | | ... | ${client_mask}
 | | [Arguments] | ${tg_node} | ${tg_interface}
 | | ... | ${server_mac} | ${server_ip} | ${client_ip} | ${client_mask}
 | | ... | ${lease_time}
-| | ${args}= | Catenate | --rx_if | ${tg_interface}
+| | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
+| | ${args}= | Catenate | --rx_if | ${tg_interface_name}
 | | ... | --server_mac | ${server_mac} | --server_ip | ${server_ip}
 | | ... | --client_ip | ${client_ip} | --client_mask | ${client_mask}
 | | ... | --lease_time | ${lease_time}
index 167605e..d2d7e9e 100644 (file)
 | | ${vhost2}= | Get Vhost User If Name By Sock | ${vm} | ${sock2}
 | | ${vhost3}= | Get Vhost User If Name By Sock | ${vm} | ${sock3}
 | | ${vhost4}= | Get Vhost User If Name By Sock | ${vm} | ${sock4}
-| | Set Interface State | ${vm} | ${vhost1} | up
-| | Set Interface State | ${vm} | ${vhost2} | up
-| | Set Interface State | ${vm} | ${vhost3} | up
-| | Set Interface State | ${vm} | ${vhost4} | up
+| | Set Interface State | ${vm} | ${vhost1} | up | if_type=name
+| | Set Interface State | ${vm} | ${vhost2} | up | if_type=name
+| | Set Interface State | ${vm} | ${vhost3} | up | if_type=name
+| | Set Interface State | ${vm} | ${vhost4} | up | if_type=name
 | | Setup Network Namespace
 | | ... | ${vm} | nmspace1 | ${vhost1} | ${ip1} | ${prefix_length}
 | | Setup Network Namespace
index b2036b8..23d6ff9 100644 (file)
@@ -75,7 +75,9 @@
 | | ...         | ${tx_dst_mac} | ${rx_dst_mac}
 | | ...         | ${inner_src_ip} | ${inner_dst_ip}
 | | ...         | ${outer_src_ip} | ${outer_dst_ip}
-| | ${args}= | Catenate | --tx_if | ${tx_if} | --rx_if | ${rx_if}
+| | ${tx_if_name}= | Get interface name | ${tg_node} | ${tx_if}
+| | ${rx_if_name}= | Get interface name | ${tg_node} | ${rx_if}
+| | ${args}= | Catenate | --tx_if | ${tx_if_name} | --rx_if | ${rx_if_name}
 | | | ... | --tx_dst_mac | ${tx_dst_mac} | --rx_dst_mac | ${rx_dst_mac}
 | | | ... | --inner_src_ip | ${inner_src_ip} | --inner_dst_ip | ${inner_dst_ip}
 | | | ... | --outer_src_ip | ${outer_src_ip} | --outer_dst_ip | ${outer_dst_ip}
 | | ...         | ${tx_dst_mac} | ${rx_dst_mac}
 | | ...         | ${inner_src_ip} | ${inner_dst_ip}
 | | ...         | ${outer_src_ip} | ${outer_dst_ip}
-| | ${args}= | Catenate | --tx_if | ${tx_if} | --rx_if | ${rx_if}
+| | ${tx_if_name}= | Get interface name | ${tg_node} | ${tx_if}
+| | ${rx_if_name}= | Get interface name | ${tg_node} | ${rx_if}
+| | ${args}= | Catenate | --tx_if | ${tx_if_name} | --rx_if | ${rx_if_name}
 | | | ... | --tx_dst_mac | ${tx_dst_mac} | --rx_dst_mac | ${rx_dst_mac}
 | | | ... | --inner_src_ip | ${inner_src_ip} | --inner_dst_ip | ${inner_dst_ip}
 | | | ... | --outer_src_ip | ${outer_src_ip} | --outer_dst_ip | ${outer_dst_ip}
index 4464cbc..7db329d 100644 (file)
@@ -28,7 +28,7 @@
 | | [Arguments] | ${nodes} | ${nodes_addr}
 | | ${interfaces}= | VPP nodes set ipv4 addresses | ${nodes} | ${nodes_addr}
 | | :FOR | ${interface} | IN | @{interfaces}
-| | | Set Interface State | @{interface} | up
+| | | Set Interface State | @{interface} | up | if_type=name
 
 | Routes are set up for IPv4 testing
 | | [Documentation] | Setup routing on all VPP nodes required for IPv4 tests
 | | ${dst_mac}= | Get interface mac | ${to_node} | ${to_port}
 | | ${is_dst_tg}= | Is TG node | ${to_node}
 | | ${adj_node} | ${adj_int}= | Get adjacent node and interface | ${nodes} | ${from_node} | ${from_port}
-| | ${args}= | Traffic Script Gen Arg | ${to_port} | ${from_port} | ${src_mac}
+| | ${from_port_name}= | Get interface name | ${from_node} | ${from_port}
+| | ${to_port_name}= | Get interface name | ${to_node} | ${to_port}
+| | ${adj_int_mac}= | Get interface MAC | ${adj_node} | ${adj_int}
+| | ${args}= | Traffic Script Gen Arg | ${to_port_name} | ${from_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
-| | ${args}= | Catenate | ${args} | --hops ${hops} | --first_hop_mac ${adj_int['mac_address']}
+| | ${args}= | Catenate | ${args} | --hops ${hops} | --first_hop_mac ${adj_int_mac}
 | |          | ...      | --is_dst_tg ${is_dst_tg}
 | | Run Traffic Script On Node | ipv4_ping_ttl_check.py | ${from_node} | ${args}
 
@@ -84,7 +87,8 @@
 | | ${dst_ip}= | Get IPv4 address of node "${dst_node}" interface "${dst_port}" from "${nodes_ipv4_addr}"
 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | ${args}= | Set Variable
 | | ... | ${args} --start_size ${start_size} --end_size ${end_size} --step ${step}
 | | ${dst_ip}= | Get IPv4 address of node "${vpp_node}" interface "${dst_if}" from "${nodes_ipv4_addr}"
 | | ${src_mac}= | Get node link mac | ${tg_node} | ${link_name}
 | | ${dst_mac}= | Get node link mac | ${vpp_node} | ${link_name}
-| | ${args}= | Traffic Script Gen Arg | ${src_if} | ${src_if} | ${src_mac}
+| | ${src_if_name}= | Get interface name | ${tg_node} | ${src_if}
+| | ${args}= | Traffic Script Gen Arg | ${src_if_name} | ${src_if_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
 
 | | ...
 | | [Arguments] | ${tg_node} | ${tg_interface}
 | | ... | ${dst_mac} | ${src_mac} | ${dst_ip} | ${src_ip} | ${timeout}=${10}
-| | ${args}= | Catenate | --rx_if | ${tg_interface} | --tx_if | ${tg_interface}
+| | ${tg_interface_name}= | Get interface name | ${tg_node} | ${tg_interface}
+| | ${args}= | Catenate | --rx_if | ${tg_interface_name} | --tx_if | ${tg_interface_name}
 | | ... | --dst_mac | ${dst_mac} | --src_mac | ${src_mac}
 | | ... | --dst_ip | ${dst_ip} | --src_ip | ${src_ip} | --timeout | ${timeout}
 | | Run Traffic Script On Node | send_icmp_wait_for_reply.py
index ef0b79f..19c222e 100644 (file)
@@ -37,7 +37,8 @@
 | | ${dst_ip}= | Get Node Port Ipv6 Address | ${dst_node} | ${dst_port} | ${nodes_addr}
 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Traffic Script On Node | icmpv6_echo.py | ${tg_node} | ${args}
 | | Vpp dump stats | ${dst_node}
@@ -56,7 +57,8 @@
 | | ${dst_ip}= | Get Node Port Ipv6 Address | ${dst_node} | ${dst_port} | ${nodes_addr}
 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | ${args}= | Set Variable
 | | ...      | ${args} --start_size ${start_size} --end_size ${end_size} --step ${step}
@@ -74,7 +76,8 @@
 | | ${dst_ip}= | Get Node Port Ipv6 Address | ${dst_node} | ${dst_port} | ${nodes_addr}
 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
 | | ${dst_mac}= | Get Interface Mac | ${hop_node} | ${hop_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Traffic Script On Node | icmpv6_echo.py | ${tg_node} | ${args}
 
@@ -91,7 +94,8 @@
 | | ${dst_ip}= | Get Node Port Ipv6 Address | ${dst_node} | ${dst_port} | ${nodes_addr}
 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
 | | ${dst_mac}= | Get Interface Mac | ${hop_node} | ${hop_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Traffic Script On Node | icmpv6_echo.py | ${tg_node} | ${args}
 
 | | ${dst_ip}= | Get Node Port Ipv6 Address | ${dst_node} | ${dst_port} | ${nodes_addr}
 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
 | | ${dst_mac}= | Get Interface Mac | ${hop_node} | ${hop_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Traffic Script On Node | icmpv6_echo.py | ${tg_node} | ${args}
 
 | | ${dst_mac}= | Get Interface Mac | ${src_node} | ${dst_port}
 | | ${src_nh_mac}= | Get Interface Mac | ${src_nh_node} | ${src_nh_port}
 | | ${dst_nh_mac}= | Get Interface Mac | ${dst_nh_node} | ${dst_nh_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${dst_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${dst_port_name}= | Get interface name | ${dst_node} | ${dst_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${dst_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | ${args}= | Catenate | ${args} | --src_nh_mac ${src_nh_mac}
 | |          | ...      | --dst_nh_mac ${dst_nh_mac} | --h_num 2
 | | ${dst_ip}= | Get Node Port Ipv6 Address | ${dst_node} | ${dst_port} | ${nodes_addr}
 | | ${src_mac}= | Get Interface Mac | ${src_node} | ${src_port}
 | | ${dst_mac}= | Get Interface Mac | ${dst_node} | ${dst_port}
-| | ${args}= | Traffic Script Gen Arg | ${src_port} | ${src_port} | ${src_mac}
+| | ${src_port_name}= | Get interface name | ${src_node} | ${src_port}
+| | ${args}= | Traffic Script Gen Arg | ${src_port_name} | ${src_port_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Traffic Script On Node | ipv6_ns.py | ${src_node} | ${args}
 
 | | Setup all DUTs before test
 | | ${interfaces}= | Nodes Set Ipv6 Addresses | ${nodes} | ${nodes_addr}
 | | :FOR | ${interface} | IN | @{interfaces}
-| | | Set Interface State | @{interface} | up
+| | | Set Interface State | @{interface} | up | if_type=name
 | | All Vpp Interfaces Ready Wait | ${nodes}
 
 | Clear ipv6 on all dut in topology
index 1ddb602..d8e24b8 100644 (file)
@@ -44,7 +44,9 @@
 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2
 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
-| | ${args}= | Traffic Script Gen Arg | ${dst_int} | ${src_int} | ${src_mac}
+| | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
+| | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
+| | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
 
@@ -76,7 +78,9 @@
 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2
 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
-| | ${args}= | Traffic Script Gen Arg | ${dst_int} | ${src_int} | ${src_mac}
+| | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
+| | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
+| | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name} | ${src_mac}
 | |          | ...                    | ${dst_mac} | ${src_ip} | ${dst_ip}
 | | Run Keyword And Expect Error | ICMP echo Rx timeout |
 | | ... | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
index 29635c0..90f7ab2 100644 (file)
 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_src_port} |
 | | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac}
 | | ... | ${rx_dst_mac}
+| | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_src_port}
+| | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
 | | ${args}= | Catenate | --tg_src_mac | ${tx_src_mac} | --tg_dst_mac |
 | | ... | ${rx_dst_mac} | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac |
 | | ... | ${rx_src_mac} | --src_ip | ${src_ip} | --dst_ip | ${dst_ip} |
-| | ... | --tx_if | ${tx_src_port} | --rx_if | ${rx_port}
+| | ... | --tx_if | ${tx_port_name} | --rx_if | ${rx_port_name}
 | | Run Traffic Script On Node | send_icmp_check_headers.py | ${tg_node} |
 | | ... | ${args}
 
 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_src_port} |
 | | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac} |
 | | ... | ${rx_dst_mac}
+| | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_src_port}
+| | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
 | | ${args}= | Catenate | --tg_src_mac | ${tx_src_mac} | --tg_dst_mac |
 | | ... | ${rx_dst_mac} | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac |
 | | ... | ${rx_src_mac} | --src_ip | ${src_ip} | --dst_ip | ${dst_ip} |
-| | ... | --tx_if | ${tx_src_port} | --rx_if | ${rx_port}
+| | ... | --tx_if | ${tx_port_name} | --rx_if | ${rx_port_name}
 | | Run Keyword And Expect Error | ICMP echo Rx timeout |
 | | ... | Run Traffic Script On Node | send_icmp_check_headers.py
 | | ... | ${tg_node} | ${args}
 | | [Arguments] | ${tg_node} | ${tx_src_ip} | ${tx_dst_ip} | ${tx_port}
 | | ... | ${tx_dst_mac} | ${rx_port} | ${rx_src_mac} | ${rx_arp_src_ip}
 | | ... | ${rx_arp_dst_ip}
+| | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_port}
+| | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
 | | ${args}= | Catenate
 | | ... | --tx_dst_mac | ${tx_dst_mac} | --rx_src_mac | ${rx_src_mac}
 | | ... | --tx_src_ip | ${tx_src_ip} | --tx_dst_ip | ${tx_dst_ip}
-| | ... | --tx_if | ${tx_port} | --rx_if | ${rx_port}
+| | ... | --tx_if | ${tx_port_name} | --rx_if | ${rx_port_name}
 | | ... | --rx_arp_src_ip ${rx_arp_src_ip} | --rx_arp_dst_ip ${rx_arp_dst_ip}
 | | Run Traffic Script On Node | send_icmp_check_arp.py | ${tg_node} | ${args}
 
 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_port} |
 | | ... | ${tx_mac} | ${rx_port} | ${rx_mac} | ${protocol} | ${source_port}
 | | ... | ${destination_port}
+| | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_port}
+| | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
 | | ${args}= | Catenate | --tx_mac | ${tx_mac}
 | | ...                 | --rx_mac | ${rx_mac}
 | | ...                 | --src_ip | ${src_ip}
 | | ...                 | --dst_ip | ${dst_ip}
-| | ...                 | --tx_if | ${tx_port}
-| | ...                 | --rx_if | ${rx_port}
+| | ...                 | --tx_if | ${tx_port_name}
+| | ...                 | --rx_if | ${rx_port_name}
 | | ...                 | --protocol | ${protocol}
 | | ...                 | --source_port | ${source_port}
 | | ...                 | --destination_port | ${destination_port}
 | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_port} |
 | | ... | ${tx_mac} | ${rx_port} | ${rx_mac} | ${protocol} | ${source_port}
 | | ... | ${destination_port}
+| | ${tx_port_name}= | Get interface name | ${tg_node} | ${tx_port}
+| | ${rx_port_name}= | Get interface name | ${tg_node} | ${rx_port}
 | | ${args}= | Catenate | --tx_mac | ${tx_mac}
 | | ...                 | --rx_mac | ${rx_mac}
 | | ...                 | --src_ip | ${src_ip}
 | | ...                 | --dst_ip | ${dst_ip}
-| | ...                 | --tx_if | ${tx_port}
-| | ...                 | --rx_if | ${rx_port}
+| | ...                 | --tx_if | ${tx_port_name}
+| | ...                 | --rx_if | ${rx_port_name}
 | | ...                 | --protocol | ${protocol}
 | | ...                 | --source_port | ${source_port}
 | | ...                 | --destination_port | ${destination_port}
 | | ... | \| ${nodes['DUT1']} \| eth2 \| 08:00:27:cc:4f:54 \|
 | | ...
 | | [Arguments] | ${node} | ${rx_port} | ${src_mac}
-| | ${args}= | Catenate | --rx_if | ${rx_port} | --src_mac | ${src_mac}
+| | ${rx_port_name}= | Get interface name | ${node} | ${rx_port}
+| | ${args}= | Catenate | --rx_if | ${rx_port_name} | --src_mac | ${src_mac}
 | | Run Traffic Script On Node | check_ra_packet.py | ${node} | ${args}
index 7b97769..f6506bb 100644 (file)
@@ -27,6 +27,7 @@
 | IP addresses are set on interfaces
 | | [Documentation] | *Set IPv4 addresses on interfaces on DUTs.*
 | | ... | If interface index is None then is determines with Get Interface Sw Index
+| | ... | in this case it is required the interface to be present in topology dict.
 | | ... | It also executes VPP IP Probe to determine MACs to IPs on DUTs
 | | ...
 | | ... | _Set testcase variables with IP addresses and prefix length:_
 | | Set Test Variable | ${dut1s_ip_address} | 172.16.0.1
 | | Set Test Variable | ${dut2s_ip_address} | 172.16.0.2
 | | Set Test Variable | ${duts_ip_address_prefix} | 24
+| | ${DUT1_INT_KEY}= | Run Keyword If | ${DUT1_INT_INDEX} is None
+| |                  | ... | Get Interface by name | ${DUT1} | ${DUT1_INT_NAME}
+| | ${DUT2_INT_KEY}= | Run Keyword If | ${DUT2_INT_INDEX} is None
+| |                  | ... | Get Interface by name | ${DUT2} | ${DUT2_INT_NAME}
 | | ${DUT1_INT_INDEX}= | Run Keyword If | ${DUT1_INT_INDEX} is None
-| |                    | ... | Get Interface Sw Index | ${DUT1} | ${DUT1_INT_NAME}
+| |                    | ... | Get Interface Sw Index | ${DUT1} | ${DUT1_INT_KEY}
 | |                    | ... | ELSE | Set Variable | ${DUT1_INT_INDEX}
 | | ${DUT2_INT_INDEX}= | Run Keyword If | ${DUT2_INT_INDEX} is None
-| |                    | ... | Get Interface Sw Index | ${DUT2} | ${DUT2_INT_NAME}
+| |                    | ... | Get Interface Sw Index | ${DUT2} | ${DUT2_INT_KEY}
 | |                    | ... | ELSE | Set Variable | ${DUT2_INT_INDEX}
 | | Set Interface Address | ${DUT1} | ${DUT1_INT_INDEX}
 | | ... | ${dut1s_ip_address} | ${duts_ip_address_prefix}
 | | Set Interface Address | ${DUT2} | ${DUT2_INT_INDEX}
 | | ... | ${dut2s_ip_address} | ${duts_ip_address_prefix}
-| | VPP IP Probe | ${DUT1} | ${DUT1_INT_NAME} | ${dut2s_ip_address}
-| | VPP IP Probe | ${DUT2} | ${DUT2_INT_NAME} | ${dut1s_ip_address}
+| | VPP IP Probe | ${DUT1} | ${DUT1_INT_NAME} | ${dut2s_ip_address} | if_type=name
+| | VPP IP Probe | ${DUT2} | ${DUT2_INT_NAME} | ${dut1s_ip_address} | if_type=name
 
 | VXLAN interface is created
 | | [Arguments] | ${DUT} | ${VNI} | ${SRC_IP} | ${DST_IP}
 | | ... | - ${dut2s_vlan_index}
 | | ...
 | | [Arguments] | ${VLAN} | ${DUT1} | ${INT1} | ${DUT2} | ${INT2}
+| | ${INT1_NAME}= | Get interface name | ${DUT1} | ${INT1}
+| | ${INT2_NAME}= | Get interface name | ${DUT2} | ${INT2}
 | | ${dut1s_vlan_name} | ${dut1s_vlan_index}= | Create Vlan Subinterface
-| |                    | ...                  | ${DUT1} | ${INT1} | ${VLAN}
+| |                    | ...                  | ${DUT1} | ${INT1_NAME} | ${VLAN}
 | | ${dut2s_vlan_name} | ${dut2s_vlan_index}= | Create Vlan Subinterface
-| |                    | ...                  | ${DUT2} | ${INT2} | ${VLAN}
+| |                    | ...                  | ${DUT2} | ${INT2_NAME} | ${VLAN}
 | | Set Interface State | ${DUT1} | ${dut1s_vlan_index} | up
 | | Set Interface State | ${DUT2} | ${dut2s_vlan_index} | up
 | | Set Test Variable | ${dut1s_vlan_name}
index eb7ed2c..db0f9a1 100644 (file)
 | | [Arguments] | ${dut_node} | ${interface} | @{vhosts}
 | | Bridge domain on DUT node is created | ${dut_node} | ${bid_b} | learn=${TRUE}
 | | Bridge domain on DUT node is created | ${dut_node} | ${bid_r} | learn=${TRUE}
+| | ${interface_name}= | Get interface name | ${dut_node} | ${interface}
 | | ${vlan1_name} | ${vlan1_index}= | Create Vlan Subinterface
-| | ... | ${dut_node} | ${interface} | ${vlan_blue}
+| | ... | ${dut_node} | ${interface_name} | ${vlan_blue}
 | | ${vlan2_name} | ${vlan2_index}= | Create Vlan Subinterface
-| | ... | ${dut_node} | ${interface} | ${vlan_red}
+| | ... | ${dut_node} | ${interface_name} | ${vlan_red}
 | | L2 Tag Rewrite | ${dut_node} | @{vhosts}[0] | push-1 | ${vlan_blue}
 | | L2 Tag Rewrite | ${dut_node} | @{vhosts}[1] | push-1 | ${vlan_blue}
 | | L2 Tag Rewrite | ${dut_node} | @{vhosts}[2] | push-1 | ${vlan_red}
 | | ... | ${namespace4}
 | | Run keyword and expect error | Ping Not Successful
 | | ... | Send Ping From Node To Dst | ${qemu_node2} | ${dut1_blue2}
-| | ... | ${namespace4}
\ No newline at end of file
+| | ... | ${namespace4}
index ec857ad..7fd6cae 100644 (file)
 | | Given Path for 3-node testing is set
 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['DUT2']} | ${nodes['TG']}
 | | And Interfaces in 3-node path are up
-| | And IP addresses are set on interfaces | ${dut1_node} | ${dut1_to_dut2} | ${NONE}
-| | ...                                    | ${dut2_node} | ${dut2_to_dut1} | ${NONE}
+| | ${dut1_to_dut2_name}= | Get interface name | ${dut1_node} | ${dut1_to_dut2}
+| | ${dut2_to_dut1_name}= | Get interface name | ${dut2_node} | ${dut2_to_dut1}
+| | And IP addresses are set on interfaces | ${dut1_node} | ${dut1_to_dut2_name} | ${NONE}
+| | ...                                    | ${dut2_node} | ${dut2_to_dut1_name} | ${NONE}
 | | ${dut1s_vxlan}= | When Create VXLAN interface     | ${dut1_node} | ${vni_1}
 | |                 | ... | ${dut1s_ip_address} | ${dut2s_ip_address}
 | | And  Interfaces are added to BD | ${dut1_node} | ${bd_id1}
index a4aa061..05a11db 100644 (file)
 | | Given Path for 3-node testing is set
 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['DUT2']} | ${nodes['TG']}
 | | And   Interfaces in 3-node path are up
-| | And   IP addresses are set on interfaces | ${dut1_node} | ${dut1_to_dut2} | ${NONE}
-| |       ...                                | ${dut2_node} | ${dut2_to_dut1} | ${NONE}
+| | ${dut1_to_dut2_name}= | Get interface name | ${dut1_node} | ${dut1_to_dut2}
+| | ${dut2_to_dut1_name}= | Get interface name | ${dut2_node} | ${dut2_to_dut1}
+| | And   IP addresses are set on interfaces | ${dut1_node} | ${dut1_to_dut2_name} | ${NONE}
+| |       ...                                | ${dut2_node} | ${dut2_to_dut1_name} | ${NONE}
 | | ${dut1s_vxlan}= | When Create VXLAN interface     | ${dut1_node} | ${VNI}
 | |                 | ...  | ${dut1s_ip_address} | ${dut2s_ip_address}
 | |                   And  Interfaces are added to xconnect | ${dut1_node}