def get_serial(self): """ Retrieves the serial number of the PSU Returns: string: Serial number of PSU """ if self.is_cpm == 0: return 'N/A' if self.serial != 'Unknown': return self.serial channel, stub = nokia_common.channel_setup( nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return nokia_common.NOKIA_INVALID_STRING ret, response = nokia_common.try_grpc( stub.GetPsuSerial, platform_ndk_pb2.ReqPsuInfoPb(psu_idx=self.index)) nokia_common.channel_shutdown(channel) if ret is False: return nokia_common.NOKIA_INVALID_STRING self.product = response.fru_info.product_name self.model = response.fru_info.part_number self.serial = response.fru_info.serial_number return self.serial
def get_status(self): """ Retrieves the operational status of the PSU Returns: bool: True if PSU is operating properly, False if not """ status = False if self.is_cpm == 0: return status channel, stub = nokia_common.channel_setup( nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return status ret, response = nokia_common.try_grpc( stub.GetPsuStatus, platform_ndk_pb2.ReqPsuInfoPb(psu_idx=self.index)) nokia_common.channel_shutdown(channel) if ret is False: return status status = response.psu_status return status
def get_presence(self): """ Retrieves the presence of the Power Supply Unit (PSU) Returns: bool: True if PSU is present, False if not """ status = False if self.is_cpm == 0: return status channel, stub = nokia_common.channel_setup( nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return status ret, response = nokia_common.try_grpc( stub.GetPsuPresence, platform_ndk_pb2.ReqPsuInfoPb(psu_idx=self.index)) nokia_common.channel_shutdown(channel) if ret is False: return status status = response.psu_presence return status
def show_psu_detail(stub): response = stub.ShowPsuInfo(platform_ndk_pb2.ReqPsuInfoPb(psu_idx=0)) if len(response.psu_info.psu_device) == 0: print('PSU Output not available on this card') return if format_type == 'json-format': json_response = MessageToJson(response) print(json_response) return field = [] field.append('Index ') field.append('Current ') field.append('Voltage ') field.append('Power ') field.append('Temperature ') i = 0 item_list = [] while i < len(response.psu_info.psu_device): psu_device = response.psu_info.psu_device[i] if psu_device.psu_presence: item = [] item.append(str(i + 1)) p_response = stub.GetPsuOutputCurrent( platform_ndk_pb2.ReqPsuInfoPb(psu_idx=i + 1)) item.append(str(p_response.output_current)) p_response = stub.GetPsuOutputVoltage( platform_ndk_pb2.ReqPsuInfoPb(psu_idx=i + 1)) item.append(str(p_response.output_voltage)) p_response = stub.GetPsuOutputPower( platform_ndk_pb2.ReqPsuInfoPb(psu_idx=i + 1)) item.append(str(p_response.output_power)) p_response = stub.GetPsuTemperature( platform_ndk_pb2.ReqPsuInfoPb(psu_idx=i + 1)) item.append(str(p_response.ambient_temp)) item_list.append(item) i += 1 print('PSU TABLE DETAILS') print_table(field, item_list) return
def get_voltage(self): channel, stub = nokia_common.channel_setup( nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return self.output_voltage ret, response = nokia_common.try_grpc( stub.GetPsuOutputVoltage, platform_ndk_pb2.ReqPsuInfoPb(psu_idx=self.index)) nokia_common.channel_shutdown(channel) if ret is False: return self.output_voltage self.output_voltage = response.output_voltage return self.output_voltage
def get_temperature(self): channel, stub = nokia_common.channel_setup( nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return self.ambient_temperature ret, response = nokia_common.try_grpc( stub.GetPsuTemperature, platform_ndk_pb2.ReqPsuInfoPb(psu_idx=self.index)) nokia_common.channel_shutdown(channel) if ret is False: return self.ambient_temperature self.ambient_temperature = response.ambient_temp return self.ambient_temperature
def _get_psu_list(self): if not self.is_cpm: return [] channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return ret, response = nokia_common.try_grpc(stub.GetPsuNum, platform_ndk_pb2.ReqPsuInfoPb()) nokia_common.channel_shutdown(channel) if ret is False: return self.num_psus = response.num_psus for i in range(self.num_psus): psu = Psu(i, self.psu_stub) self._psu_list.append(psu) return self._psu_list
def get_maximum_supplied_power(self): """ Retrieves the maximum output power in watts of a power supply unit (PSU) """ if self.is_cpm == 0: return 0.0 channel, stub = nokia_common.channel_setup( nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return self.max_supplied_power ret, response = nokia_common.try_grpc( stub.GetPsuMaximumPower, platform_ndk_pb2.ReqPsuInfoPb(psu_idx=self.index)) nokia_common.channel_shutdown(channel) if ret is False: return self.max_supplied_power self.max_supplied_power = response.supplied_power return self.max_supplied_power
def get_voltage_low_threshold(self): if self.min_voltage != 0.0: return self.min_voltage channel, stub = nokia_common.channel_setup( nokia_common.NOKIA_GRPC_PSU_SERVICE) if not channel or not stub: return self.min_voltage ret, response = nokia_common.try_grpc( stub.GetPsuMaxTemperature, platform_ndk_pb2.ReqPsuInfoPb(psu_idx=self.index)) nokia_common.channel_shutdown(channel) if ret is False: return self.min_voltage self.min_voltage = response.fault_info.min_voltage self.max_voltage = response.fault_info.max_voltage self.max_temperature = response.fault_info.max_temperature return self.min_voltage
def show_psu(stub): arg1 = platform_ndk_pb2.ReqPsuInfoPb(psu_idx=0) ret, response = nokia_common.try_grpc(stub.ShowPsuInfo, arg1) if ret is False: print('PSU request unsuccessful on this card') return if len(response.psu_info.psu_device) == 0: print('PSU Output not available on this card') return if format_type == 'json-format': json_response = MessageToJson(response) print(json_response) return field = [] field.append('Index ') field.append('Status ') i = 0 item_list = [] while i < len(response.psu_info.psu_device): psu_device = response.psu_info.psu_device[i] item = [] item.append(str(i + 1)) if psu_device.psu_presence: if psu_device.psu_status: item.append('UP') else: item.append('DOWN') else: item.append('NOT-PRESENT') item_list.append(item) i += 1 print('PSU TABLE') print_table(field, item_list) return