示例#1
0
    def add_bond_eth_interface(node, ifc_name=None, sw_if_idx=None):
        """Add BondEthernet interface to current topology.

        :param node: DUT node from topology.
        :param ifc_name: Name of the BondEthernet interface.
        :param sw_if_idx: SW interface index.
        :type node: dict
        :type ifc_name: str
        :type sw_if_idx: int
        """
        if_key = Topology.add_new_port(node, 'eth_bond')

        vat_executor = VatExecutor()
        vat_executor.execute_script_json_out("dump_interfaces.vat", node)
        interface_dump_json = vat_executor.get_script_stdout()

        if ifc_name and sw_if_idx is None:
            sw_if_idx = VatJsonUtil.get_interface_sw_index_from_json(
                interface_dump_json, ifc_name)
        Topology.update_interface_sw_if_index(node, if_key, sw_if_idx)
        if sw_if_idx and ifc_name is None:
            ifc_name = InterfaceUtil.vpp_get_interface_name(node, sw_if_idx)
        Topology.update_interface_name(node, if_key, ifc_name)
        ifc_mac = VatJsonUtil.get_interface_mac_from_json(
            interface_dump_json, sw_if_idx)
        Topology.update_interface_mac_address(node, if_key, ifc_mac)
示例#2
0
    def vpp_ipsec_add_sad_entries(node,
                                  n_entries,
                                  sad_id,
                                  spi,
                                  crypto_alg,
                                  crypto_key,
                                  integ_alg,
                                  integ_key,
                                  tunnel_src=None,
                                  tunnel_dst=None):
        """Create multiple Security Association Database entries on VPP node.

        :param node: VPP node to add SAD entry on.
        :param n_entries: Number of SAD entries to be created.
        :param sad_id: First SAD entry ID. All subsequent SAD entries will have
            id incremented by 1.
        :param spi: Security Parameter Index of first SAD entry. All subsequent
            SAD entries will have spi incremented by 1.
        :param crypto_alg: The encryption algorithm name.
        :param crypto_key: The encryption key string.
        :param integ_alg: The integrity algorithm name.
        :param integ_key: The integrity key string.
        :param tunnel_src: Tunnel header source IPv4 or IPv6 address. If not
            specified ESP transport mode is used.
        :param tunnel_dst: Tunnel header destination IPv4 or IPv6 address. If
            not specified ESP transport mode is used.
        :type node: dict
        :type n_entries: int
        :type sad_id: int
        :type spi: int
        :type crypto_alg: CryptoAlg
        :type crypto_key: str
        :type integ_alg: IntegAlg
        :type integ_key: str
        :type tunnel_src: str
        :type tunnel_dst: str
        """
        tmp_filename = '/tmp/ipsec_sad_{0}_add_del_entry.script'.format(sad_id)
        ckey = crypto_key.encode('hex')
        ikey = integ_key.encode('hex')
        tunnel = 'tunnel_src {0} tunnel_dst {1}'.format(tunnel_src, tunnel_dst)\
            if tunnel_src is not None and tunnel_dst is not None else ''

        integ = 'integ_alg {0} integ_key {1}'.format(integ_alg.alg_name, ikey)\
            if crypto_alg.alg_name != 'aes-gcm-128' else ''

        with open(tmp_filename, 'w') as tmp_file:
            for i in range(0, n_entries):
                buf_str = 'ipsec_sad_add_del_entry esp sad_id {0} spi {1} ' \
                          'crypto_alg {2} crypto_key {3} {4} {5}\n'.format(
                              sad_id+i, spi+i, crypto_alg.alg_name, ckey, integ,
                              tunnel)
                tmp_file.write(buf_str)
        vat = VatExecutor()
        vat.execute_script(tmp_filename,
                           node,
                           timeout=300,
                           json_out=False,
                           copy_on_execute=True)
        os.remove(tmp_filename)
示例#3
0
    def vpp_del_lisp_local_eid(node,
                               locator_set_name,
                               vni,
                               eid,
                               prefix_len=None):
        """Set lisp eid addres on the VPP node in topology.

        :param node: VPP node.
        :param locator_set_name: Name of the locator_set.
        :param vni: vni value.
        :param eid: Eid value.
        :param prefix_len: prefix len if the eid is IP address.
        :type node: dict
        :type locator_set_name: str
        :type vni: int
        :type eid: str
        :type prefix_len: int
        """

        if prefix_len is not None:
            VatExecutor.cmd_from_template(node,
                                          'lisp/del_lisp_local_eid.vat',
                                          vni=vni,
                                          eid=eid,
                                          eid_prefix=prefix_len,
                                          locator_name=locator_set_name)
        else:
            VatExecutor.cmd_from_template(node,
                                          'lisp/del_lisp_local_eid_mac.vat',
                                          vni=vni,
                                          eid=eid,
                                          locator_name=locator_set_name)
示例#4
0
    def vpp_del_lisp_remote_mapping(node, vni, deid, deid_prefix, seid,
                                    seid_prefix, rloc):
        """Delete lisp remote mapping on the VPP node in topology.

        :param node: VPP node.
        :param vni: Vni.
        :param deid: Destination eid address.
        :param deid_prefix: Destination eid address prefix_len.
        :param seid: Source eid address.
        :param seid_prefix: Source eid address prefix_len.
        :param rloc: Receiver locator.
        :type node: dict
        :type vni: int
        :type deid: str
        :type deid_prefix: int
        :type seid: str
        :type seid_prefix: int
        :type rloc: str
        """

        VatExecutor.cmd_from_template(node,
                                      'lisp/del_lisp_remote_mapping.vat',
                                      vni=vni,
                                      deid=deid,
                                      deid_prefix=deid_prefix,
                                      seid=seid,
                                      seid_prefix=seid_prefix,
                                      rloc=rloc)
示例#5
0
文件: L2Util.py 项目: marekgr/csit
    def create_l2_bd(node, bd_id, flood=1, uu_flood=1, forward=1, learn=1,
                     arp_term=0):
        """Create a l2 bridge domain on the chosen VPP node

        Execute "bridge_domain_add_del bd_id {bd_id} flood {flood} uu-flood 1
        forward {forward} learn {learn} arp-term {arp_term}" VAT command on
        the node.

        :param node: Node where we wish to crate the l2 bridge domain.
        :param bd_id: Bridge domain index number.
        :param flood: Enable flooding.
        :param uu_flood: Enable uu_flood.
        :param forward: Enable forwarding.
        :param learn: Enable mac address learning to fib.
        :param arp_term: Enable arp_termination.
        :type node: dict
        :type bd_id: int
        :type flood: bool
        :type uu_flood: bool
        :type forward: bool
        :type learn: bool
        :type arp_term: bool
        """
        VatExecutor.cmd_from_template(node, "l2_bd_create.vat",
                                      bd_id=bd_id, flood=flood,
                                      uu_flood=uu_flood, forward=forward,
                                      learn=learn, arp_term=arp_term)
示例#6
0
    def vpp_del_lisp_adjacency(node, vni, deid, deid_prefix, seid,
                               seid_prefix):
        """Delete lisp adjacency on the VPP node in topology.

        :param node: VPP node.
        :param vni: Vni.
        :param deid: Destination eid address.
        :param deid_prefix: Destination eid address prefix_len.
        :param seid: Source eid address.
        :param seid_prefix: Source eid address prefix_len.
        :type node: dict
        :type vni: int
        :type deid: str
        :type deid_prefix: int
        :type seid: str
        :type seid_prefix: int
        """

        VatExecutor.cmd_from_template(node,
                                      'lisp/del_lisp_adjacency.vat',
                                      vni=vni,
                                      deid=deid,
                                      deid_prefix=deid_prefix,
                                      seid=seid,
                                      seid_prefix=seid_prefix)
示例#7
0
    def vpp_api_trace_dump(node):
        """Run "api trace custom-dump" CLI command.

        :param node: Node to run command on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("api_trace_dump.vat", node, json_out=False)
示例#8
0
    def vpp_show_hardware_detail(node):
        """Run "show hardware-interfaces detail" debug CLI command.

        :param node: Node to run command on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("show_hardware_detail.vat", node, json_out=False)
示例#9
0
    def vpp_show_version_verbose(node):
        """Run "show version verbose" CLI command.

        :param node: Node to run command on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("show_version_verbose.vat", node, json_out=False)
示例#10
0
    def vpp_show_errors(node):
        """Run "show errors" debug CLI command.

        :param node: Node to run command on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("show_errors.vat", node, json_out=False)
示例#11
0
    def vpp_clear_runtime(node):
        """Run "clear runtime" CLI command.

        :param node: Node to run command on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("clear_runtime.vat", node, json_out=False)
示例#12
0
    def show_event_logger_on_dut(node):
        """Show event logger on the DUT node.

        :param node: DUT node to show traces on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("show_event_logger.vat", node, json_out=False)
示例#13
0
    def dump_memif(node):
        """Dump Memif data for the given node.

        :param node: Given node to show Memif data on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("memif_dump.vat", node, json_out=False)
示例#14
0
    def vpp_show_vhost(node):
        """Get vhost-user data for the given node.

        :param node: VPP node to get interface data from.
        :type node: dict
        :returns: nothing
        """
        vat = VatExecutor()
        vat.execute_script("show_vhost.vat", node, json_out=False)
示例#15
0
    def show_packet_trace_on_all_duts(nodes):
        """Show VPP packet trace.

        :param nodes: Nodes from which the packet trace will be displayed.
        :type nodes: list
        """
        for node in nodes.values():
            if node['type'] == NodeType.DUT:
                vat = VatExecutor()
                vat.execute_script("show_trace.vat", node, json_out=False)
示例#16
0
    def vpp_enable_barrier_traces_on_dut(node):
        """Enable vpp barrier traces on the DUT node.

        :param node: DUT node to set up.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("test_threads_barrier_elog.vat",
                           node,
                           json_out=False)
示例#17
0
    def clear_packet_trace_on_all_duts(nodes):
        """Clear VPP packet trace.

        :param nodes: Nodes where the packet trace will be cleared.
        :type nodes: list
        """
        for node in nodes.values():
            if node['type'] == NodeType.DUT:
                vat = VatExecutor()
                vat.execute_script("clear_trace.vat", node, json_out=False)
示例#18
0
    def vpp_show_crypto_device_mapping(node):
        """Run "show crypto device mapping" CLI command.

        :param node: Node to run command on.
        :type node: dict
        """
        vat = VatExecutor()
        vat.execute_script("show_crypto_device_mapping.vat",
                           node,
                           json_out=False)
示例#19
0
    def exec_vat(self, script, **args):
        """Wrapper for VAT executor.

        :param script: Script to execute.
        :param args: Parameters to the script.
        :type script: str
        :type args: dict
        :returns: nothing
        """
        # TODO: check return value
        VatExecutor.cmd_from_template(self.node_info, script, **args)
示例#20
0
    def vpp_lisp_enable_disable(node, state):
        """Enable/Disable lisp in the VPP node in topology.

        :param node: Node of the test topology.
        :param state: State of the lisp, enable or disable.
        :type node: dict
        :type state: str
        """

        VatExecutor.cmd_from_template(node,
                                      'lisp/lisp_status.vat',
                                      state=state)
示例#21
0
    def vpp_show_lisp_rloc_config(node):
        """Get LISP RLOC configuration from VPP node.

        :param node: VPP node.
        :type node: dict
        :returns: LISP RLOC configuration as python list.
        :rtype: list
        """

        vat = VatExecutor()
        vat.execute_script_json_out('lisp/show_lisp_rloc_config.vat', node)
        return JsonParser().parse_data(vat.get_script_stdout())
示例#22
0
    def vpp_show_lisp_pitr(node):
        """Get Lisp PITR feature config from VPP node.

        :param node: VPP node.
        :type node: dict
        :returns: Lisp PITR config data.
        :rtype: dict
        """

        vat = VatExecutor()
        vat.execute_script_json_out('lisp/show_lisp_pitr.vat', node)
        return JsonParser().parse_data(vat.get_script_stdout())
示例#23
0
    def vpp_log_macip_acl_interface_assignment(node):
        """Get interface list and associated MACIP ACLs and write to robot log.

        :param node: VPP node.
        :type node: dict
        """
        try:
            VatExecutor.cmd_from_template(
                node, "acl_plugin/macip_acl_interface_get.vat", json_out=False)
        except RuntimeError:
            # Fails to parse response, but it is still logged
            pass
示例#24
0
    def vpp_del_map_resolver(node, map_resolver_ip):
        """Unset lisp map resolver on the VPP node in topology.

        :param node: VPP node.
        :param map_resolver_ip: IP address of the map resolver.
        :type node: dict
        :type map_resolver_ip: str
        """

        VatExecutor.cmd_from_template(node,
                                      'lisp/del_lisp_map_resolver.vat',
                                      address=map_resolver_ip)
示例#25
0
    def vpp_show_lisp_state(node):
        """Get lisp state from VPP node.

        :param node: VPP node.
        :type node: dict
        :returns: Lisp gpe state.
        :rtype: list
        """

        vat = VatExecutor()
        vat.execute_script_json_out('lisp/show_lisp_status.vat', node)
        return JsonParser().parse_data(vat.get_script_stdout())
示例#26
0
    def vpp_del_lisp_locator_set(node, name):
        """Del lisp locator_set on VPP.

        :param node: VPP node.
        :param name: VPP locator name.
        :type node: dict
        :type name: str
        """

        VatExecutor.cmd_from_template(node,
                                      'lisp/del_lisp_locator_set.vat',
                                      lisp_name=name)
示例#27
0
    def vpp_log_plugin_acl_settings(node):
        """Retrieve configured settings from the ACL plugin
         and write to robot log.

        :param node: VPP node.
        :type node: dict
        """
        try:
            VatExecutor.cmd_from_template(node, "acl_plugin/acl_dump.vat")
        except (ValueError, RuntimeError):
            # Fails to parse JSON data in response, but it is still logged
            pass
示例#28
0
    def vpp_show_lisp_map_register(node):
        """Get LISP Map Register from VPP node.

        :param node: VPP node.
        :type node: dict
        :returns: LISP Map Register as python list.
        :rtype: list
        """

        vat = VatExecutor()
        vat.execute_script_json_out('lisp/show_lisp_map_register.vat', node)
        return JsonParser().parse_data(vat.get_script_stdout())
示例#29
0
    def vpp_show_lisp_eid_table(node):
        """Get lisp eid table from VPP node.

        :param node: VPP node.
        :type node: dict
        :returns: Lisp eid table as python list.
        :rtype: list
        """

        vat = VatExecutor()
        vat.execute_script_json_out('lisp/show_lisp_eid_table.vat', node)
        return JsonParser().parse_data(vat.get_script_stdout())
示例#30
0
    def vpp_lisp_gpe_iface(node, state):
        """Set lisp gpe interface up or down on the VPP node in topology.

        :param node: VPP node.
        :param state: State of the gpe iface, up or down.
        :type node: dict
        :type state: str
        """

        VatExecutor.cmd_from_template(node,
                                      'lisp/lisp_gpe_iface.vat',
                                      state=state)