Skip to content

Commit

Permalink
Get fan_sensors route working again. (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewHink committed Jul 2, 2018
1 parent 1e03fb3 commit 1cf90b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
26 changes: 17 additions & 9 deletions synse/commands/fan_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def fan_sensors():
# to read all the devices of a given type or model.

start_time = datetime.datetime.now()
_cache = await cache.get_metainfo_cache()
_cache = await cache.get_device_info_cache()
scan_cache = await cache.get_scan_cache()

readings = []
Expand All @@ -87,10 +87,10 @@ async def fan_sensors():
for _, v in _cache.items():

logger.debug('FAN SENSORS')
logger.debug('fan_sensors cache item: {}'.format(v))

is_temp = v.type.lower() == 'temperature' and v.model.lower() == 'max11610'
is_pressure = v.type.lower() == 'pressure' and v.model.lower() == 'sdp610'
is_temp = v.output[0].name.lower() == 'temperature' \
and v.metadata['model'].lower() == 'max11610'
is_pressure = v.output[0].name.lower() == 'pressure' \
and v.metadata['model'].lower() == 'sdp610'

if is_temp or is_pressure:
rack = v.location.rack # string (vec1-c1-wrigley for example)
Expand Down Expand Up @@ -138,17 +138,19 @@ async def fan_sensors():
# Translate single_reading['scan_cache_device']['info']
# and add it under the rack key which is:
# new_readings['racks'][rack][translation] \
# = single_reading['data'][single_reading['type']]['value']
# = single_reading['data'][0]['value']
logger.debug('single_reading: {}'.format(single_reading))
logger.debug(
'single_reading[scan_cache_device][info]: {}'.format(
single_reading['scan_cache_device']['info']))
logger.debug(
'single_reading[data][single_reading[type]][value]: {}'.format(
single_reading['data'][single_reading['type']]['value']))
'single_reading[data][single_reading[kind][value]: {}'.format(
single_reading['data'][0]['value']))

# Add sensor reading to result set.
fan_sensor_key = _translate_device_info(single_reading['scan_cache_device']['info'])
reading_value = single_reading['data'][single_reading['type']]['value']
# This only works because thermistors and pressure sensors have exactly one reading.
reading_value = single_reading['data'][0]['value']
if fan_sensor_key is not None and reading_value is not None:
# Be sure not to overwrite any existing reading in the current result set.
# That would imply a mapping issue or some other bug.
Expand All @@ -165,6 +167,12 @@ async def fan_sensors():
logger.debug('--- FAN SENSORS end ---')
# Sort the new_readings racks by racks['id']
new_readings['racks'] = OrderedDict(sorted(new_readings['racks'].items()))

# Sort each output for each rack so we can debug this.
for rack in new_readings['racks']:
logger.debug('sorting rack: {}'.format(rack))
new_readings['racks'][rack] = OrderedDict(sorted(new_readings['racks'][rack].items()))

end_time = datetime.datetime.now()
read_time = (end_time - start_time).total_seconds() * 1000

Expand Down
12 changes: 7 additions & 5 deletions synse/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,11 @@ def register_tcp():
Return:
list[str]: The ids of all plugins that were registered.
"""
logger.debug(_('Registering plugins (tcp)'))
registered = []

configured = config.options.get('plugin.tcp', [])
if not configured:
logger.debug(_('No plugin configurations for TCP'))
logger.info(_('No plugin configurations for TCP'))
return registered

logger.debug(_('TCP plugin configuration: {}').format(configured))
Expand All @@ -300,6 +299,7 @@ def register_tcp():
continue
registered.append(plugin_id)

logger.info('Registered tcp plugins: {}'.format(registered))
return registered


Expand All @@ -318,12 +318,11 @@ def register_unix():
Returns:
list[str]: The ids of all plugins that were registered.
"""
logger.debug(_('Registering plugins (unix)'))
registered = []

configured = config.options.get('plugin.unix', [])
if not configured:
logger.debug(_('No plugin configurations for unix'))
logger.info(_('No plugin configurations for unix'))

logger.debug(_('unix plugin configuration: {}').format(configured))
for address in configured:
Expand Down Expand Up @@ -351,7 +350,9 @@ def register_unix():
.format(const.SOCKET_DIR)
)
else:
logger.debug(_('Registering plugins from default socket directory'))
logger.debug(_(
'Registering plugins from default socket directory ({})'.format(
const.SOCKET_DIR)))

for item in os.listdir(const.SOCKET_DIR):
logger.debug(' {}'.format(item))
Expand All @@ -375,4 +376,5 @@ def register_unix():
else:
config.options.get('plugin.unix').append(address)

logger.info('Registered unix plugins: {}'.format(registered))
return registered

0 comments on commit 1cf90b6

Please sign in to comment.