Ejemplo n.º 1
0
def ports(request, drone):
    port_id_list = drone.getPortIdList()
    port_config_list = drone.getPortConfig(port_id_list)
    assert len(port_config_list.port) != 0

    # print port list and find default X/Y ports
    ports.x_num = -1
    ports.y_num = -1
    print port_config_list
    print('Port List')
    print('---------')
    for port in port_config_list.port:
        print('%d.%s (%s)' % (port.port_id.id, port.name, port.description))
        # use a vhost port as default X/Y port
        if ('vhost' in port.name or 'oracle' in port.description.lower()):
            if ports.x_num < 0:
                ports.x_num = port.port_id.id
            elif ports.y_num < 0:
                ports.y_num = port.port_id.id
        if ('eth1' in port.name):
            ports.x_num = port.port_id.id
        if ('eth2' in port.name):
            ports.y_num = port.port_id.id

    assert ports.x_num >= 0
    assert ports.y_num >= 0

    print('Using port %d as port X' % ports.x_num)
    print('Using port %d as port Y' % ports.y_num)

    ports.x = ost_pb.PortIdList()
    ports.x.port_id.add().id = ports.x_num

    ports.y = ost_pb.PortIdList()
    ports.y.port_id.add().id = ports.y_num

    # Enable stream stats on ports
    portConfig = ost_pb.PortConfigList()
    portConfig.port.add().port_id.id = ports.x_num
    portConfig.port[0].is_tracking_stream_stats = True
    portConfig.port.add().port_id.id = ports.y_num
    portConfig.port[1].is_tracking_stream_stats = True
    print('Enabling Stream Stats tracking on ports X and Y')
    drone.modifyPort(portConfig)

    return ports
Ejemplo n.º 2
0
def ports(request, drone):
    # retreive port id list
    log.info('retreiving port list')
    port_id_list = drone.getPortIdList()

    # retreive port config list
    log.info('retreiving port config for all ports')
    port_config_list = drone.getPortConfig(port_id_list)

    if len(port_config_list.port) == 0:
        log.warning('drone has no ports!')
        sys.exit(1)

    # iterate port list to find a loopback port to use as the tx/rx port id
    print('Port List')
    print('---------')
    for port in port_config_list.port:
        print('%d.%s (%s)' % (port.port_id.id, port.name, port.description))
        # use a loopback port as default tx/rx port
        if ('lo' in port.name or 'loopback' in port.description.lower()):
            tx_number = port.port_id.id
            rx_number = port.port_id.id

    if tx_number < 0 or rx_number < 0:
        log.warning('loopback port not found')
        sys.exit(1)

    print('Using port %d as tx/rx port(s)' % tx_number)

    ports.tx = ost_pb.PortIdList()
    ports.tx.port_id.add().id = tx_number

    ports.rx = ost_pb.PortIdList()
    ports.rx.port_id.add().id = rx_number

    # stop transmit/capture on ports, if any
    drone.stopTransmit(ports.tx)
    drone.stopCapture(ports.rx)

    # delete existing streams, if any, on tx port
    sid_list = drone.getStreamIdList(ports.tx.port_id[0])
    drone.deleteStream(sid_list)

    return ports
Ejemplo n.º 3
0
def ports(request, drone):
    port_id_list = drone.getPortIdList()
    port_config_list = drone.getPortConfig(port_id_list)
    assert len(port_config_list.port) != 0

    # print port list and find default tx/rx ports
    tx_number = -1
    rx_number = -1
    print port_config_list
    print('Port List')
    print('---------')
    for port in port_config_list.port:
        print('%d.%s (%s)' % (port.port_id.id, port.name, port.description))
        # use a vhost port as default tx/rx port
        if ('vhost' in port.name or 'sun' in port.description.lower()):
            if tx_number < 0:
                tx_number = port.port_id.id
            elif rx_number < 0:
                rx_number = port.port_id.id
        if ('eth1' in port.name):
            tx_number = port.port_id.id
        if ('eth2' in port.name):
            rx_number = port.port_id.id

    assert tx_number >= 0
    assert rx_number >= 0

    print('Using port %d as tx port(s)' % tx_number)
    print('Using port %d as rx port(s)' % rx_number)

    ports.tx = ost_pb.PortIdList()
    ports.tx.port_id.add().id = tx_number

    ports.rx = ost_pb.PortIdList()
    ports.rx.port_id.add().id = rx_number
    return ports
Ejemplo n.º 4
0
    print('Port List')
    print('---------')
    for port in port_config_list.port:
        print('%d.%s (%s)' % (port.port_id.id, port.name, port.description))
        # use a loopback port as default tx/rx port
        if ('lo' in port.name or 'loopback' in port.description.lower()):
            tx_port_number = port.port_id.id
            rx_port_number = port.port_id.id

    if tx_port_number < 0 or rx_port_number < 0:
        log.warning('loopback port not found')
        sys.exit(1)

    print('Using port %d as tx/rx port(s)' % tx_port_number)

    tx_port = ost_pb.PortIdList()
    tx_port.port_id.add().id = tx_port_number

    rx_port = ost_pb.PortIdList()
    rx_port.port_id.add().id = rx_port_number

    # add a stream
    stream_id = ost_pb.StreamIdList()
    stream_id.port_id.CopyFrom(tx_port.port_id[0])
    stream_id.stream_id.add().id = 1
    log.info('adding tx_stream %d' % stream_id.stream_id[0].id)
    drone.addStream(stream_id)

    # configure the stream
    stream_cfg = ost_pb.StreamConfigList()
    stream_cfg.port_id.CopyFrom(tx_port.port_id[0])
Ejemplo n.º 5
0
def emul_ports(request, drone, ports):
    emul_ports = ost_pb.PortIdList()
    emul_ports.port_id.add().id = ports.tx.port_id[0].id
    emul_ports.port_id.add().id = ports.rx.port_id[0].id
    return emul_ports