Пример #1
0
def show_led(stub, port_start, port_end):
    led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_PORT
    port_idx = platform_ndk_pb2.ReqLedIndexPb(start_idx=port_start,
                                              end_idx=port_end)
    response = stub.ShowLed(
        platform_ndk_pb2.ReqLedInfoPb(led_type=led_type, led_idx=port_idx))
    if len(response.led_show.show_info) == 0:
        print('Port/LED Output not available on this card')
        return

    if format_type == 'json-format':
        json_response = MessageToJson(response)
        print(json_response)
        return

    field = []
    field.append('Interface     ')
    field.append('Status                    ')

    i = 0
    item_list = []
    while i < len(response.led_show.show_info):
        led_device = response.led_show.show_info[i]
        item_list.append(
            [led_device.led_name, (led_device.led_status.rstrip())])
        i += 1

    print('FRONT-PANEL INTERFACE STATUS TABLE')
    print_table(field, item_list)
    return
Пример #2
0
def set_fp_port_led(led_stub, port_id, port_up):
    led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_PORT
    _intf_info = platform_ndk_pb2.UpdateIntfInfoPb(port_name='FPport' +
                                                   str(port_id),
                                                   port_up=port_up)
    response = led_stub.SetLed(
        platform_ndk_pb2.ReqLedInfoPb(led_type=led_type, intf_info=_intf_info))
Пример #3
0
def show_system_led(stub):
    led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_ALL
    response = stub.ShowLed(platform_ndk_pb2.ReqLedInfoPb(led_type=led_type))
    if len(response.led_show.show_info) == 0:
        print('LED Output not available on this card')
        return

    if format_type == 'json-format':
        json_response = MessageToJson(response)
        print(json_response)
        return

    field = []
    field.append('Name                  ')
    field.append('Status                    ')

    i = 0
    item_list = []
    while i < len(response.led_show.show_info):
        led_device = response.led_show.show_info[i]
        item_list.append(
            [led_device.led_name, (led_device.led_status.rstrip())])
        i += 1

    print('SYSTEM LED STATUS TABLE')
    print_table(field, item_list)
    return
Пример #4
0
    def set_status_led(self, color):
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_BOARD_STATUS
        _led_info = nokia_common.led_color_to_info(color)

        channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_LED_SERVICE)
        if not channel or not stub:
            return False
        ret, response = nokia_common.try_grpc(stub.SetLed,
                                              platform_ndk_pb2.ReqLedInfoPb(led_type=led_type, led_info=_led_info))
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return False
        return True
Пример #5
0
    def get_status_led(self):
        color = Chassis.STATUS_LED_COLOR_OFF
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_BOARD_STATUS
        channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_LED_SERVICE)
        if not channel or not stub:
            return color
        ret, response = nokia_common.try_grpc(stub.GetLed,
                                              platform_ndk_pb2.ReqLedInfoPb(led_type=led_type))
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return color

        color = nokia_common.led_info_to_color(response.led_get.led_info[0])
        return color
Пример #6
0
 def __init__(self):
     led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_PORT
     led_info = nokia_common.led_color_to_info(
         DeviceBase.STATUS_LED_COLOR_OFF)
     channel, stub = nokia_common.channel_setup(
         nokia_common.NOKIA_GRPC_LED_SERVICE)
     if not channel or not stub:
         return
     port_idx = platform_ndk_pb2.ReqLedIndexPb(
         start_idx=nokia_common.NOKIA_FP_START_PORTID,
         end_idx=nokia_common.NOKIA_FP_END_PORTID)
     ret, response = nokia_common.try_grpc(
         stub.SetLed,
         platform_ndk_pb2.ReqLedInfoPb(led_type=led_type,
                                       led_idx=port_idx,
                                       led_info=led_info))
     nokia_common.channel_shutdown(channel)
Пример #7
0
    def set_status_master_led(cls, color):
        """
        Set the PSU master led register with the input color
        """
        cls.psu_master_led_color = color
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_MASTER_PSU_STATUS
        _led_info = nokia_common.led_color_to_info(color)

        channel, stub = nokia_common.channel_setup(
            nokia_common.NOKIA_GRPC_LED_SERVICE)
        if not channel or not stub:
            return False
        ret, response = nokia_common.try_grpc(
            stub.SetLed,
            platform_ndk_pb2.ReqLedInfoPb(led_type=led_type,
                                          led_info=_led_info))
        nokia_common.channel_shutdown(channel)

        return True
Пример #8
0
    def get_status_master_led(cls):
        """
        Get the PSU master led register with the input color
        """
        color = Psu.STATUS_LED_COLOR_OFF
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_MASTER_PSU_STATUS
        channel, stub = nokia_common.channel_setup(
            nokia_common.NOKIA_GRPC_LED_SERVICE)
        if not channel or not stub:
            return color
        ret, response = nokia_common.try_grpc(
            stub.GetLed, platform_ndk_pb2.ReqLedInfoPb(led_type=led_type))
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return color

        color = nokia_common.led_info_to_color(response.led_get.led_info[0])
        return color
Пример #9
0
def set_led(stub, type_str, color):
    if type_str == 'port':
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_PORT
    elif type_str == 'fantray':
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_FANTRAY
    elif type_str == 'sfm':
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_SFM
    elif type_str == 'board':
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_BOARD_STATUS
    elif type_str == 'master-fan':
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_MASTER_FAN_STATUS
    elif type_str == 'master-psu':
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_MASTER_PSU_STATUS
    elif type_str == 'master-sfm':
        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_MASTER_SFM_STATUS
    else:
        print('Unsupported led-type')
        return

    _led_info = nokia_common.led_color_to_info(color)
    stub.SetLed(
        platform_ndk_pb2.ReqLedInfoPb(led_type=led_type, led_info=_led_info))
Пример #10
0
    def port_link_state_change(self, port, state):
        intf_prefix = 'Ethernet'
        if port.startswith(intf_prefix) is False:
            return
        else:
            import re
            parse_nums = re.findall(r'\d+', port)
            port_id = int(parse_nums[0])

        if state == 'up':
            port_up = 1
        elif state == 'down':
            port_up = 0
        else:
            return

        led_type = platform_ndk_pb2.ReqLedType.LED_TYPE_PORT
        if port_up:
            led_info = nokia_common.led_color_to_info(
                DeviceBase.STATUS_LED_COLOR_GREEN)
        else:
            led_info = nokia_common.led_color_to_info(
                DeviceBase.STATUS_LED_COLOR_OFF)

        channel, stub = nokia_common.channel_setup(
            nokia_common.NOKIA_GRPC_LED_SERVICE)
        if not channel or not stub:
            return
        port_idx = platform_ndk_pb2.ReqLedIndexPb(start_idx=port_id,
                                                  end_idx=port_id)
        ret, response = nokia_common.try_grpc(
            stub.SetLed,
            platform_ndk_pb2.ReqLedInfoPb(led_type=led_type,
                                          led_idx=port_idx,
                                          led_info=led_info))
        nokia_common.channel_shutdown(channel)