@@ -305,7 +305,7 @@ class PsuStatus(object):
305305 return True
306306
307307 def set_voltage (self , voltage , high_threshold , low_threshold ):
308- if not voltage or not high_threshold or not low_threshold :
308+ if voltage == NOT_AVAILABLE or high_threshold == NOT_AVAILABLE or low_threshold == NOT_AVAILABLE :
309309 if self .voltage_good is not True :
310310 self .logger .log_warning ('PSU voltage or high_threshold or low_threshold become unavailable, '
311311 'voltage={}, high_threshold={}, low_threshold={}' .format (voltage , high_threshold , low_threshold ))
@@ -320,7 +320,7 @@ class PsuStatus(object):
320320 return True
321321
322322 def set_temperature (self , temperature , high_threshold ):
323- if not temperature or not high_threshold :
323+ if temperature == NOT_AVAILABLE or high_threshold == NOT_AVAILABLE :
324324 if self .temperature_good is not True :
325325 self .logger .log_warning ('PSU temperature or high_threshold become unavailable, '
326326 'temperature={}, high_threshold={}' .format (temperature , high_threshold ))
@@ -445,23 +445,23 @@ class DaemonPsud(daemon_base.DaemonBase):
445445 name = get_psu_key (index )
446446 presence = _wrapper_get_psu_presence (index )
447447 power_good = False
448- voltage = None
449- voltage_high_threshold = None
450- voltage_low_threshold = None
451- temperature = None
452- temperature_threshold = None
453- current = None
454- power = None
448+ voltage = NOT_AVAILABLE
449+ voltage_high_threshold = NOT_AVAILABLE
450+ voltage_low_threshold = NOT_AVAILABLE
451+ temperature = NOT_AVAILABLE
452+ temperature_threshold = NOT_AVAILABLE
453+ current = NOT_AVAILABLE
454+ power = NOT_AVAILABLE
455455 is_replaceable = try_get (psu .is_replaceable , False )
456456 if presence :
457457 power_good = _wrapper_get_psu_status (index )
458- voltage = try_get (psu .get_voltage )
459- voltage_high_threshold = try_get (psu .get_voltage_high_threshold )
460- voltage_low_threshold = try_get (psu .get_voltage_low_threshold )
461- temperature = try_get (psu .get_temperature )
462- temperature_threshold = try_get (psu .get_temperature_high_threshold )
463- current = try_get (psu .get_current )
464- power = try_get (psu .get_power )
458+ voltage = try_get (psu .get_voltage , NOT_AVAILABLE )
459+ voltage_high_threshold = try_get (psu .get_voltage_high_threshold , NOT_AVAILABLE )
460+ voltage_low_threshold = try_get (psu .get_voltage_low_threshold , NOT_AVAILABLE )
461+ temperature = try_get (psu .get_temperature , NOT_AVAILABLE )
462+ temperature_threshold = try_get (psu .get_temperature_high_threshold , NOT_AVAILABLE )
463+ current = try_get (psu .get_current , NOT_AVAILABLE )
464+ power = try_get (psu .get_power , NOT_AVAILABLE )
465465
466466 if index not in self .psu_status_dict :
467467 self .psu_status_dict [index ] = PsuStatus (self , psu )
@@ -508,8 +508,8 @@ class DaemonPsud(daemon_base.DaemonBase):
508508 self ._set_psu_led (psu , psu_status )
509509
510510 fvs = swsscommon .FieldValuePairs (
511- [(PSU_INFO_MODEL_FIELD , str (try_get (psu .get_model ))),
512- (PSU_INFO_SERIAL_FIELD , str (try_get (psu .get_serial ))),
511+ [(PSU_INFO_MODEL_FIELD , str (try_get (psu .get_model , NOT_AVAILABLE ))),
512+ (PSU_INFO_SERIAL_FIELD , str (try_get (psu .get_serial , NOT_AVAILABLE ))),
513513 (PSU_INFO_TEMP_FIELD , str (temperature )),
514514 (PSU_INFO_TEMP_TH_FIELD , str (temperature_threshold )),
515515 (PSU_INFO_VOLTAGE_FIELD , str (voltage )),
0 commit comments