Example #1
0
def set_media_transceiver(interface_obj):
    # get front panel port from ifindex
    if_obj = cps_object.CPSObject(obj=interface_obj)
    npu = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/npu-id')
    port = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/port-id')
    enable = if_obj.get_attr_data('if/interfaces/interface/enabled')
    nas_if.log_info("set_media_transceiver as " + str(enable) + " for " +
                    str(npu) + " , " + str(port))
    port_list = nas_if.nas_os_phy_list(d={'npu-id': npu, 'port-id': port})
    phy_obj = cps_object.CPSObject(obj=port_list[0])
    try:
        hwport_list = phy_obj.get_attr_data('hardware-port-list')
    except:
        nas_if.log_err(" Error in setting media Transceiver for %s" %
                       if_obj.get_attr_data('name'))
        return
    # set media transceiver using media Id and channel ID
    #
    for hwport in hwport_list:
        fp_details = fp.find_port_by_hwport(npu, hwport)
        if fp_details.port_group_id is None:
            _lane = fp_details.lane
        else:
            pg_list = fp.get_port_group_list()
            pg_obj = pg_list[fp_details.port_group_id]
            if ((pg_obj.get_profile_type()) == "ethernet_ddqsfp28"):
                _lane = pg_obj.get_lane(hwport)
            else:
                _lane = fp_details.lane
        media.media_transceiver_set(1, fp_details.media_id, _lane, enable)
def change_phy(args):
    npu = None
    port = None

    if 'npu' in args:
        npu = int(args['npu'])
    if 'port' in args:
        port = int(args['port'])
    l = nas_if.nas_os_phy_list(npu, port)
    if l is None or len(l) == 0 or len(l) > 1:
        print "Cound not find interface"
        sys.exit(1)

    obj = l[0]

    fill_obj(obj, args)

    print "Changing.. port"
    print obj

    ch = {'operation': 'set', 'change': obj}
    if 'operation' in args:
        ch['operation'] = args['operation']

    cps.transaction([ch])
    print_object(ch['change'])
Example #3
0
def set_media_transceiver(interface_obj):
    # get front panel port from ifindex
    if_obj = cps_object.CPSObject(obj=interface_obj)
    npu = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/npu-id')
    port = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/port-id')
    print "set_media_transceiver for %d %d " % (npu, port)
    enable = if_obj.get_attr_data('if/interfaces/interface/enabled')
    port_list = nas_if.nas_os_phy_list(d={'npu-id': npu, 'port-id': port})
    phy_obj = cps_object.CPSObject(obj=port_list[0])
    fanout = phy_obj.get_attr_data('fanout-mode')
    try:
        hwport = phy_obj.get_attr_data('hardware-port-id')
        fp_details = fp.find_port_by_hwport(npu, hwport)
    except:
        print " Error in setting media Transceiver for ", if_obj.get_attr_data(
            'name')
        return
    # set media transceiver using media Id and channel ID
    # in case of 40G mode all channels should be enabled/disabled
    #  else only one channel.
    #
    print "fanout " + str(fanout)
    if fanout == 2:  # then it is in 4x10G fanout mode BASE_PORT_BREAKOUT_MODE_BREAKOUT_4X1
        _lane = fp_details.lane
    else:  # non-fanout mode 1x40g mode
        _lane = None  # enable/disable all channels. Do not pass Lane #
    media.media_transceiver_set(1, fp_details.media_id, _lane, enable)
def set_media_transceiver(interface_obj):
    # get front panel port from ifindex
    if_obj = cps_object.CPSObject(obj=interface_obj)
    npu = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/npu-id')
    port = if_obj.get_attr_data('base-if-phy/if/interfaces/interface/port-id')
    print "set_media_transceiver for %d %d " %(npu, port)
    enable = if_obj.get_attr_data('if/interfaces/interface/enabled')
    port_list = nas_if.nas_os_phy_list(
        d={'npu-id': npu, 'port-id': port})
    phy_obj = cps_object.CPSObject(obj=port_list[0])
    fanout = phy_obj.get_attr_data('fanout-mode')
    try:
        hwport = phy_obj.get_attr_data('hardware-port-id')
        fp_details = fp.find_port_by_hwport(npu, hwport)
    except:
        print " Error in setting media Transceiver for ", if_obj.get_attr_data('name')
        return
    # set media transceiver using media Id and channel ID
    # in case of 40G mode all channels should be enabled/disabled
    #  else only one channel.
    #
    print "fanout " + str(fanout)
    if fanout == 2:  # then it is in 4x10G fanout mode BASE_PORT_BREAKOUT_MODE_BREAKOUT_4X1
        _lane = fp_details.lane
    else:    # non-fanout mode 1x40g mode
        _lane = None # enable/disable all channels. Do not pass Lane #
    media.media_transceiver_set(1, fp_details.media_id, _lane, enable)
def change_phy(args):
    npu = None
    port = None

    if 'npu' in args:
        npu = int(args['npu'])
    if 'port' in args:
        port = int(args['port'])
    l = nas_if.nas_os_phy_list(npu, port)
    if l is None or len(l) == 0 or len(l) > 1:
        print "Cound not find interface"
        sys.exit(1)

    obj = l[0]

    fill_obj(obj, args)

    print "Changing.. port"
    print obj

    ch = {'operation': 'set', 'change': obj}
    if 'operation' in args:
        ch['operation'] = args['operation']

    cps.transaction([ch])
    print_object(ch['change'])
Example #6
0
def phy_port_service_wait():
    while True:
        l = nas_if.nas_os_phy_list()
        if l is not None:
            return l
        time.sleep(1)