Exemple #1
0
        def create_config(self):

            fanout_devices = IxiaFanoutManager(self.fanout_graph_facts)
            fanout_devices.get_fanout_device_details(device_number=0)
            device_conn = self.conn_graph_facts['device_conn']

            # The number of ports should be at least three for this test
            available_phy_port = fanout_devices.get_ports()
            pytest_assert(
                len(available_phy_port) > 3,
                "Number of physical ports must be at least 3")

            # Get interface speed of peer port
            for intf in available_phy_port:
                peer_port = intf['peer_port']
                intf['speed'] = int(device_conn[peer_port]['speed'])

            config = ""

            port1_location = get_location(available_phy_port[0])
            port2_location = get_location(available_phy_port[1])
            port3_location = get_location(available_phy_port[2])

            port1 = Port(name='Port1', location=port1_location)
            port2 = Port(name='Port2', location=port2_location)
            port3 = Port(name='Port3', location=port3_location)

            pfc = Ieee8021qbb(pfc_delay=1,
                              pfc_class_0=0,
                              pfc_class_1=1,
                              pfc_class_2=2,
                              pfc_class_3=3,
                              pfc_class_4=4,
                              pfc_class_5=5,
                              pfc_class_6=6,
                              pfc_class_7=7)

            flow_ctl = FlowControl(choice=pfc)

            l1_oneHundredGbe = OneHundredGbe(link_training=True,
                                             ieee_media_defaults=False,
                                             auto_negotiate=False,
                                             speed='one_hundred_gbps',
                                             flow_control=flow_ctl,
                                             rs_fec=True)

            common_l1_config = Layer1(
                name='common L1 config',
                choice=l1_oneHundredGbe,
                port_names=[port1.name, port2.name, port3.name])

            config = Config(ports=[port1, port2, port3],
                            layer1=[common_l1_config],
                            options=Options(
                                PortOptions(location_preemption=True)))

            return config
Exemple #2
0
def one_hundred_gbe(testbed, conn_graph_facts, fanout_graph_facts, serializer):

    fanout_devices = IxiaFanoutManager(fanout_graph_facts)
    fanout_devices.get_fanout_device_details(device_number=0)
    device_conn = conn_graph_facts['device_conn']

    # The number of ports should be at least two for this test
    available_phy_port = fanout_devices.get_ports()
    pytest_assert(
        len(available_phy_port) > 2,
        "Number of physical ports must be at least 2")

    configs = []
    for i in range(len(available_phy_port)):
        rx_id = i
        tx_id = (i + 1) % len(available_phy_port)

        phy_tx_port = get_location(available_phy_port[tx_id])
        phy_rx_port = get_location(available_phy_port[rx_id])

        #########################################################################
        # common L1 configuration
        #########################################################################

        tx = Port(name='Tx', location=phy_tx_port)
        rx = Port(name='Rx', location=phy_rx_port)

        pfc = Ieee8021qbb(pfc_delay=1,
                          pfc_class_0=0,
                          pfc_class_1=1,
                          pfc_class_2=2,
                          pfc_class_3=3,
                          pfc_class_4=4,
                          pfc_class_5=5,
                          pfc_class_6=6,
                          pfc_class_7=7)

        flow_ctl = FlowControl(choice=pfc)

        l1_oneHundredGbe = OneHundredGbe(link_training=True,
                                         ieee_media_defaults=False,
                                         auto_negotiate=False,
                                         speed='one_hundred_gbps',
                                         flow_control=flow_ctl,
                                         rs_fec=True)

        common_l1_config = Layer1(name='common L1 config',
                                  choice=l1_oneHundredGbe,
                                  port_names=[tx.name, rx.name])

        config = Config(ports=[tx, rx],
                        layer1=[common_l1_config],
                        options=Options(PortOptions(location_preemption=True)))

        configs.append(config)

    return configs
        def create_config(self, phy_ports):
            """
            Creates config for traffic generator with given physical ports

            :param phy_ports: Physical ports config creation on traffic generator
            """
            ports = []
            one_hundred_gbe_ports = []

            for index, phy_port in enumerate(phy_ports, 1):
                port_location = get_location(phy_port)
                port = Port(name='Port' + str(index), location=port_location)
                if (phy_port['speed'] / 1000 == 100):
                    one_hundred_gbe_ports.append(port.name)
                else:
                    pytest_assert(
                        False,
                        "This test supports only 100gbe speed as of now, need to enhance the script based on requirement"
                    )

                ports.append(port)

            pfc = Ieee8021qbb(pfc_delay=1,
                              pfc_class_0=0,
                              pfc_class_1=1,
                              pfc_class_2=2,
                              pfc_class_3=3,
                              pfc_class_4=4,
                              pfc_class_5=5,
                              pfc_class_6=6,
                              pfc_class_7=7)

            flow_ctl = FlowControl(choice=pfc)

            one_hundred_gbe = OneHundredGbe(link_training=True,
                                            ieee_media_defaults=False,
                                            auto_negotiate=False,
                                            speed='one_hundred_gbps',
                                            flow_control=flow_ctl,
                                            rs_fec=True)

            layer1 = Layer1(name='Layer1 settings',
                            choice=one_hundred_gbe,
                            port_names=one_hundred_gbe_ports)

            config = Config(ports=ports,
                            layer1=[layer1],
                            options=Options(
                                PortOptions(location_preemption=True)))

            return config
Exemple #4
0
def testbed_config(conn_graph_facts, fanout_graph_facts, duthost):
    ixia_fanout = get_peer_ixia_chassis(conn_data=conn_graph_facts,
                                        dut_hostname=duthost.hostname)

    pytest_require(ixia_fanout is not None,
                   skip_message="Cannot find the peer IXIA chassis")

    ixia_fanout_id = list(fanout_graph_facts.keys()).index(ixia_fanout)
    ixia_fanout_list = IxiaFanoutManager(fanout_graph_facts)
    ixia_fanout_list.get_fanout_device_details(device_number=ixia_fanout_id)

    ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname)
    pytest_require(len(ixia_ports) >= 2,
                   skip_message="The test requires at least two ports")

    rx_id = 0
    tx_id = 1

    rx_port_location = get_tgen_location(ixia_ports[rx_id])
    tx_port_location = get_tgen_location(ixia_ports[tx_id])

    rx_port_speed = int(ixia_ports[rx_id]['speed'])
    tx_port_speed = int(ixia_ports[tx_id]['speed'])
    pytest_require(rx_port_speed == tx_port_speed,
                   skip_message="Two ports should have the same speed")
    """ L1 configuration """
    rx_port = Port(name='Rx Port', location=rx_port_location)
    tx_port = Port(name='Tx Port', location=tx_port_location)

    pfc = Ieee8021qbb(pfc_delay=1,
                      pfc_class_0=0,
                      pfc_class_1=1,
                      pfc_class_2=2,
                      pfc_class_3=3,
                      pfc_class_4=4,
                      pfc_class_5=5,
                      pfc_class_6=6,
                      pfc_class_7=7)

    flow_ctl = FlowControl(choice=pfc)

    auto_negotiation = AutoNegotiation(link_training=True, rs_fec=True)

    l1_config = Layer1(name='L1 config',
                       speed='speed_%d_gbps' % (rx_port_speed / 1000),
                       auto_negotiate=False,
                       auto_negotiation=auto_negotiation,
                       flow_control=flow_ctl,
                       port_names=[tx_port.name, rx_port.name])

    config = Config(ports=[tx_port, rx_port],
                    layer1=[l1_config],
                    options=Options(PortOptions(location_preemption=True)))

    vlan_subnet = get_vlan_subnet(duthost)
    pytest_assert(vlan_subnet is not None,
                  "Fail to get Vlan subnet information")

    vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, 2)
    gw_addr = vlan_subnet.split('/')[0]
    prefix = vlan_subnet.split('/')[1]
    tx_port_ip = vlan_ip_addrs[0]
    rx_port_ip = vlan_ip_addrs[1]
    tx_gateway_ip = gw_addr
    rx_gateway_ip = gw_addr
    """ L2/L3 configuration """
    tx_ipv4 = Ipv4(name='Tx Ipv4',
                   address=Pattern(tx_port_ip),
                   prefix=Pattern(prefix),
                   gateway=Pattern(tx_gateway_ip),
                   ethernet=Ethernet(name='Tx Ethernet'))

    config.devices.append(
        Device(name='Tx Device',
               device_count=1,
               container_name=tx_port.name,
               choice=tx_ipv4))

    rx_ipv4 = Ipv4(name='Rx Ipv4',
                   address=Pattern(rx_port_ip),
                   prefix=Pattern(prefix),
                   gateway=Pattern(rx_gateway_ip),
                   ethernet=Ethernet(name='Rx Ethernet'))

    config.devices.append(
        Device(name='Rx Device',
               device_count=1,
               container_name=rx_port.name,
               choice=rx_ipv4))

    return config
Exemple #5
0
def ixia_testbed_config(conn_graph_facts, fanout_graph_facts, duthosts,
                        rand_one_dut_hostname):
    """
    Geenrate Tgen API config and port config information for the testbed

    Args:
        conn_graph_facts (pytest fixture)
        fanout_graph_facts (pytest fixture)
        duthosts (pytest fixture): list of DUTs
        rand_one_dut_hostname (pytest fixture): DUT hostname

    Returns:
        - config (obj): Tgen API config of the testbed
        - port_config_list (list): list of port configuration information
    """
    duthost = duthosts[rand_one_dut_hostname]
    """ Generate L1 config """
    ixia_fanout = get_peer_ixia_chassis(conn_data=conn_graph_facts,
                                        dut_hostname=duthost.hostname)

    pytest_assert(ixia_fanout is not None, 'Fail to get ixia_fanout')

    ixia_fanout_id = list(fanout_graph_facts.keys()).index(ixia_fanout)
    ixia_fanout_list = IxiaFanoutManager(fanout_graph_facts)
    ixia_fanout_list.get_fanout_device_details(device_number=ixia_fanout_id)

    ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname)

    ports = []
    port_names = []
    port_speed = None

    for i in range(len(ixia_ports)):
        port = Port(name='Port {}'.format(i),
                    location=get_tgen_location(ixia_ports[i]))

        ports.append(port)
        port_names.append(port.name)

        if port_speed is None:
            port_speed = int(ixia_ports[i]['speed'])

        pytest_assert(port_speed == int(ixia_ports[i]['speed']),
                      'Ports have different link speeds')

    pfc = Ieee8021qbb(pfc_delay=0,
                      pfc_class_0=0,
                      pfc_class_1=1,
                      pfc_class_2=2,
                      pfc_class_3=3,
                      pfc_class_4=4,
                      pfc_class_5=5,
                      pfc_class_6=6,
                      pfc_class_7=7)

    flow_ctl = FlowControl(choice=pfc)

    auto_negotiation = AutoNegotiation(link_training=True, rs_fec=True)

    speed_gbps = int(port_speed / 1000)

    l1_config = Layer1(name='L1 config',
                       speed='speed_{}_gbps'.format(speed_gbps),
                       auto_negotiate=False,
                       auto_negotiation=auto_negotiation,
                       ieee_media_defaults=False,
                       flow_control=flow_ctl,
                       port_names=port_names)

    config = Config(ports=ports,
                    layer1=[l1_config],
                    options=Options(PortOptions(location_preemption=True)))

    port_config_list = []

    config_result = __vlan_intf_config(config=config,
                                       port_config_list=port_config_list,
                                       duthost=duthost,
                                       ixia_ports=ixia_ports)
    pytest_assert(config_result is True, 'Fail to configure Vlan interfaces')

    config_result = __portchannel_intf_config(
        config=config,
        port_config_list=port_config_list,
        duthost=duthost,
        ixia_ports=ixia_ports)
    pytest_assert(config_result is True,
                  'Fail to configure portchannel interfaces')

    return config, port_config_list
Exemple #6
0
def ixia_testbed(conn_graph_facts, fanout_graph_facts, duthosts,
                 rand_one_dut_hostname):
    """
    L2/L3 Tgen API config for the T0 testbed

    Args:
        conn_graph_facts (pytest fixture)
        fanout_graph_facts (pytest fixture)
        duthosts (pytest fixture): list of DUTs
        rand_one_dut_hostname (pytest fixture): DUT hostname

    Returns:
        L2/L3 config for the T0 testbed
    """
    duthost = duthosts[rand_one_dut_hostname]
    ixia_fanout = get_peer_ixia_chassis(conn_data=conn_graph_facts,
                                        dut_hostname=duthost.hostname)

    if ixia_fanout is None:
        return None

    ixia_fanout_id = list(fanout_graph_facts.keys()).index(ixia_fanout)
    ixia_fanout_list = IxiaFanoutManager(fanout_graph_facts)
    ixia_fanout_list.get_fanout_device_details(device_number=ixia_fanout_id)

    ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname)

    ports = list()
    port_names = list()
    port_speed = None
    """ L1 config """
    for i in range(len(ixia_ports)):
        port = Port(name='Port {}'.format(i),
                    location=get_tgen_location(ixia_ports[i]))

        ports.append(port)
        port_names.append(port.name)

        if port_speed is None:
            port_speed = int(ixia_ports[i]['speed'])

        elif port_speed != int(ixia_ports[i]['speed']):
            """ All the ports should have the same bandwidth """
            return None

    pfc = Ieee8021qbb(pfc_delay=0,
                      pfc_class_0=0,
                      pfc_class_1=1,
                      pfc_class_2=2,
                      pfc_class_3=3,
                      pfc_class_4=4,
                      pfc_class_5=5,
                      pfc_class_6=6,
                      pfc_class_7=7)

    flow_ctl = FlowControl(choice=pfc)

    auto_negotiation = AutoNegotiation(link_training=True, rs_fec=True)

    l1_config = Layer1(name='L1 config',
                       speed='speed_%d_gbps' % int(port_speed / 1000),
                       auto_negotiate=False,
                       auto_negotiation=auto_negotiation,
                       ieee_media_defaults=False,
                       flow_control=flow_ctl,
                       port_names=port_names)

    config = Config(ports=ports,
                    layer1=[l1_config],
                    options=Options(PortOptions(location_preemption=True)))
    """ L2/L3 config """
    vlan_subnet = get_vlan_subnet(duthost)
    if vlan_subnet is None:
        return None

    vlan_ip_addrs = get_addrs_in_subnet(vlan_subnet, len(ixia_ports))
    gw_addr = vlan_subnet.split('/')[0]
    prefix = vlan_subnet.split('/')[1]

    for i in range(len(ixia_ports)):
        ip_stack = Ipv4(name='Ipv4 {}'.format(i),
                        address=Pattern(vlan_ip_addrs[i]),
                        prefix=Pattern(prefix),
                        gateway=Pattern(gw_addr),
                        ethernet=Ethernet(name='Ethernet {}'.format(i)))

        device = Device(name='Device {}'.format(i),
                        device_count=1,
                        container_name=port_names[i],
                        choice=ip_stack)

        config.devices.append(device)

    return config
Exemple #7
0
def options():
    """Returns global options
    """
    from abstract_open_traffic_generator.config import Options
    from abstract_open_traffic_generator.port import Options as PortOptions
    return Options(PortOptions(location_preemption=True))
Exemple #8
0
def test_config_options(serializer):
    options = Options(PortOptions(location_preemption=True))
    config = Config(options=options)
    print(serializer.json(config))