コード例 #1
0
ファイル: chassis.py プロジェクト: nokia/sonic-platform
    def _get_fantray_list(self):
        if not self.is_cpm:
            return []

        channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_FAN_SERVICE)
        if not channel or not stub:
            return
        ret, response = nokia_common.try_grpc(stub.GetFanNum,
                                              platform_ndk_pb2.ReqFanTrayOpsPb())
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return

        self.num_fantrays = response.fan_nums.num_fantrays

        fan_index = 0
        for drawer_index in range(self.num_fantrays):
            fan_drawer = FanDrawer(drawer_index)
            fan_drawer.set_maximum_consumed_power(self.fantray_power)
            fan = Fan(fan_index, drawer_index, False, self.fan_stub)
            fan_drawer._fan_list.append(fan)
            fan_index = fan_index + 1
            self._fan_drawer_list.append(fan_drawer)

        return self._fan_drawer_list
コード例 #2
0
ファイル: nokia_cmd.py プロジェクト: nokia/sonic-platform
def show_fan(stub):
    req_idx = platform_ndk_pb2.ReqFanTrayIndexPb(fantray_idx=0)
    response = stub.ShowFanInfo(platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
    if len(response.fan_show.fan_device) == 0:
        print('Fan output not available on this card')
        return

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

    field = []
    field.append('        Type         ')
    field.append('        Value                    ')

    i = 0
    item_list = []
    while i < len(response.fan_show.fan_device):
        fan_device = response.fan_show.fan_device[i]
        item = []
        item.append('Fan Tray - ' + str(i))
        item.append(fan_device.fan_state)
        item_list.append(item)
        i += 1

    item_list.append([
        'Fan Algorithm Disable',
        'True' if response.fan_show.fan_algorithm_disable else 'False'
    ])
    item_list.append(
        ['Current Fan Speed',
         str(response.fan_show.current_fan_speed)])
    item_list.append(['Max Fan Speed', str(response.fan_show.max_fan_speed)])
    item_list.append([
        'Force Max Fan Speed',
        'True' if response.fan_show.is_force_max_speed else 'False'
    ])

    print('FAN TABLE')
    print_table(field, item_list)
    return
コード例 #3
0
ファイル: nokia_cmd.py プロジェクト: nokia/sonic-platform
def set_fantray_led(stub, index, color):
    req_idx = platform_ndk_pb2.ReqFanTrayIndexPb(fantray_idx=index)
    _led_info = nokia_common.led_color_to_info(color)
    stub.SetFanLedStatus(
        platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx, led_info=_led_info))
コード例 #4
0
ファイル: nokia_cmd.py プロジェクト: nokia/sonic-platform
def set_fan_speed(stub, speed):
    req_idx = platform_ndk_pb2.ReqFanTrayIndexPb(fantray_idx=1)
    stub.SetFanTargetSpeed(
        platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx, fantray_speed=speed))
コード例 #5
0
ファイル: nokia_cmd.py プロジェクト: nokia/sonic-platform
def set_fan_algo_disable(stub, disable):
    req_idx = platform_ndk_pb2.ReqFanTrayIndexPb(fantray_idx=1)
    req_fan_algo = platform_ndk_pb2.SetFanTrayAlgorithmPb(
        fantray_algo_disable=disable)
    stub.DisableFanAlgorithm(
        platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx, fan_algo=req_fan_algo))
コード例 #6
0
ファイル: nokia_cmd.py プロジェクト: nokia/sonic-platform
def show_fan_detail(stub):
    # Get Num-fans
    req_idx = platform_ndk_pb2.ReqFanTrayIndexPb(fantray_idx=0)
    response = stub.GetFanNum(platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))

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

    fan_msg = response.fan_nums
    num_fans = fan_msg.num_fantrays

    if num_fans == 0:
        print('Fan detail output not available on this card')
        return

    field = []
    field.append('Index   ')
    field.append('Presence')
    field.append('Status  ')
    field.append('Target Speed')
    field.append('Speed   ')
    field.append('SerialNo      ')
    field.append('PartNo        ')
    field.append('Led-Color     ')

    item_list = []
    # For each fan check presence
    for index in range(0, num_fans):
        req_idx = platform_ndk_pb2.ReqFanTrayIndexPb(fantray_idx=index)

        # Presence
        response = stub.GetFanPresence(
            platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
        presence_msg = response.fan_presence
        presence = presence_msg.fantray_presence

        # Status
        status = False
        response = stub.GetFanStatus(
            platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
        status_msg = response.fan_status
        # Empty, Init, SpinUp, Online are possible states
        if status_msg.fantray_status == 'Online':
            status = True

        # Target Speed
        response = stub.GetFanTargetSpeed(
            platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
        speed_msg = response.fan_speed_target
        target_speed = speed_msg.fantray_speed

        # Speed
        response = stub.GetFanActualSpeed(
            platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
        speed_msg = response.fan_speed_actual
        speed = speed_msg.fantray_speed

        # PartNo
        response = stub.GetFanTrayPartNo(
            platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
        fantray_partno = response.fan_eeprom.fantray_edata

        # SerialNo
        response = stub.GetFanTraySerialNo(
            platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
        fantray_serialno = response.fan_eeprom.fantray_edata

        # LED
        response = stub.GetFanLedStatus(
            platform_ndk_pb2.ReqFanTrayOpsPb(idx=req_idx))
        color = nokia_common.led_info_to_color(response.led_info)

        item = []
        item.append(str(index))
        item.append(str(presence))
        item.append(str(status))
        item.append(str(target_speed))
        item.append(str(speed))
        item.append(fantray_serialno)
        item.append(fantray_partno)
        item.append(color)
        item_list.append(item)

    print('FAN DETAIL TABLE')
    print_table(field, item_list)
    return