Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fan_sensors route for auto fan. #118

Merged
merged 1 commit into from
Apr 2, 2018
Merged

Conversation

MatthewHink
Copy link
Contributor

This commit updates the fan_sensors route to make the result set look like what we had in synse 1.4 as much as possible. This makes the changes required for auto_fan much smaller.

Also sorts the scan cache racks to emit them in a predictable manner.

Sample result set:
start_time, end_time, read_time are the same for all vecs now. In the past they were not. Duplicating them in the result set makes the auto fan changes smaller.

vapor@vec1-c1-wrigley:~/src/vec-testbed/poc$ curl http://${SYNSE_IP}:5000/synse/2.0/fan_sensors
{
  "racks":{
    "vec1-c1-wrigley":{
      "thermistor_1":17.71,
      "thermistor_2":18.0,
      "thermistor_3":17.27,
      "thermistor_5":18.65,
      "thermistor_6":19.2,
      "thermistor_7":17.56,
      "thermistor_9":17.49,
      "thermistor_10":17.49,
      "thermistor_11":17.34,
      "differential_pressure_0":-6.333,
      "differential_pressure_1":32.194,
      "differential_pressure_2":1.742,
      "start_time":"2018-03-30 16:52:30.481019",
      "end_time":"2018-03-30 16:52:30.735985",
      "read_time":254.966
    },
    "vec2-c1-wrigley":{
      "thermistor_1":17.34,
      "thermistor_2":16.97,
      "thermistor_3":16.9,
      "thermistor_5":17.19,
      "thermistor_6":16.97,
      "thermistor_7":17.04,
      "thermistor_9":17.04,
      "thermistor_10":16.97,
      "thermistor_11":16.9,
      "differential_pressure_0":3.431,
      "differential_pressure_1":16.097,
      "differential_pressure_2":2.428,
      "start_time":"2018-03-30 16:52:30.481019",
      "end_time":"2018-03-30 16:52:30.735985",
      "read_time":254.966
    },
    "vec3-c1-wrigley":{
      "thermistor_1":16.9,
      "thermistor_2":16.6,
      "thermistor_3":16.68,
      "thermistor_5":17.04,
      "thermistor_6":17.19,
      "thermistor_7":16.9,
      "thermistor_9":16.6,
      "thermistor_10":16.68,
      "thermistor_11":16.6,
      "differential_pressure_0":183.033,
      "differential_pressure_1":110.728,
      "differential_pressure_2":63.175,
      "start_time":"2018-03-30 16:52:30.481019",
      "end_time":"2018-03-30 16:52:30.735985",
      "read_time":254.966
    },
    "vec4-c1-wrigley":{
      "thermistor_1":16.97,
      "thermistor_2":16.68,
      "thermistor_3":17.04,
      "thermistor_5":17.71,
      "thermistor_6":19.9,
      "thermistor_7":17.12,
      "thermistor_9":17.04,
      "thermistor_10":16.68,
      "thermistor_11":16.9,
      "differential_pressure_0":-1324.986,
      "differential_pressure_1":1047.428,
      "differential_pressure_2":294.869,
      "start_time":"2018-03-30 16:52:30.481019",
      "end_time":"2018-03-30 16:52:30.735985",
      "read_time":254.966
    },
    "vec5-c1-wrigley":{
      "thermistor_1":17.34,
      "thermistor_2":17.19,
      "thermistor_3":17.04,
      "thermistor_5":17.34,
      "thermistor_6":17.41,
      "thermistor_7":16.82,
      "thermistor_9":17.12,
      "thermistor_10":16.9,
      "thermistor_11":16.97,
      "differential_pressure_0":-8.022,
      "differential_pressure_1":477.006,
      "differential_pressure_2":46.233,
      "start_time":"2018-03-30 16:52:30.481019",
      "end_time":"2018-03-30 16:52:30.735985",
      "read_time":254.966
    },
    "vec6-c1-wrigley":{
      "thermistor_1":17.19,
      "thermistor_2":17.04,
      "thermistor_3":17.19,
      "thermistor_5":17.27,
      "thermistor_6":17.19,
      "thermistor_7":17.12,
      "thermistor_9":17.19,
      "thermistor_10":17.19,
      "thermistor_11":17.27,
      "differential_pressure_0":0.0,
      "differential_pressure_1":0.0,
      "differential_pressure_2":0.0,
      "start_time":"2018-03-30 16:52:30.481019",
      "end_time":"2018-03-30 16:52:30.735985",
      "read_time":254.966
    }
  }
}

Copy link
Contributor

@edaniszewski edaniszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have some questions/notes, primary one being about how rack/board/device info is being gotten from the scan cache

@@ -480,6 +480,9 @@ def _build_scan_cache(metainfo):
ref['rack']['boards'] = list(ref['boards'].values())
scan_cache['racks'].append(ref['rack'])

# Sort the scan cache by racks['id']
scan_cache['racks'] = sorted(scan_cache['racks'], key=lambda rck: rck['id'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is okay, but I made this note in another PR - I'm not sure I like ordering things here. we did that in 1.4 for some stuff, and then other pieces were built off the assumption of that order. in some cases that ended up being not great.

I think most consumers of the API will be programmatic usage, so the order shouldn't matter (can be sorted as seen fit by the client).

I think this is okay here for now, but I'd really like to avoid explicitly ordering things moving forward.

from synse import cache
from synse.commands.read import read
from synse.log import logger


# TODO: Need a note in the configuration files about auto_fan relying on
# device information names in order to find these sensors.
def _translate_device_info(device_info):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made note of this in a different PR as well, just saying here again since its pertinent.

I'm not a fan of using the device 'info' field to identify a device. if we just want to ensure its a unique device, it has a unique id that can be used. an issue for a different day, but I think there are some better/cleaner solutions we could have for identifying/labeling devices that we want to use.

since this is work to get autofan working again, it'll be fine for now, but we'll eventually need to think through a better design for things like this.

logger.debug('--- FAN SENSORS end ---')
return readings
# Sort the new_readings racks by racks['id']
new_readings['racks'] = OrderedDict(sorted(new_readings['racks'].items()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably just brainfarting here, but what in auto-fan requires stuff to be sorted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My sanity when debugging it is a good place to start. The initial result set came back like this below. Trying to assure that the sensors are aggregated properly without a sort is madness.

It's not spelled out in the result set above, but each thermistor (0-11) corresponds to the channel that it's on. That channel corresponds to the wiring diagram which corresponds to a rack location.

Pressure are similar, but index 0 is channel 1 bottom, index 1 is channel 2 middle, and index 2 is channel 4 top.

curl http://${SYNSE_IP}:5000/synse/2.0/fan_sensors
[
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.49,
        "timestamp":"2018-03-27 00:27:35.275386728 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"1e93da83dd383757474f539314446c3d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:35.377430472 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"18185208cbc0e5a4700badd6e39bb12d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:35.490718481 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"e955c02a134ff2ac6e9e3a9dedc67dc1"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:34.381839366 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"2079f261767869c929e01ba10132eceb"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:34.493652092 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"b4bf920c24ad7c2e23360ffcda9f4b5d"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":-665.95,
        "timestamp":"2018-03-27 00:27:35.102268176 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"285e7b428eb467678097ecab5f765d7c"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27T00:27:36.794492+00:00",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"3f336eb0bb188de8c72650d406225ffa"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":18.65,
        "timestamp":"2018-03-27 00:27:35.586119185 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"b0efdac41dfc7e8261dfd4bd2369b161"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:35.686236839 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"5beec8c6db5445fd164566478997ff30"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:35.818183615 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"fa941bad2325cb097deb97743007ff36"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:35.923367447 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"c5d8272bc1106aa12225850d33483f33"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":9.764,
        "timestamp":"2018-03-27 00:27:36.184960331 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"880d01fd6edd947ceb75f131324eecb7"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.85,
        "timestamp":"2018-03-27 00:27:36.311018694 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"80de4a2b73c41cf71ef7d30e1f2b9494"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.93,
        "timestamp":"2018-03-27 00:27:36.446805484 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"645a790d97fc93ee12ec5fbb514230d7"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":-194.803,
        "timestamp":"2018-03-27 00:27:32.023314028 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec1-c1-wrigley",
      "board":"vec",
      "device":"b050676303b65806ef664e6a07acf2dc"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:34.450837657 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"c5d8272bc1106aa12225850d33483f33"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":18.57,
        "timestamp":"2018-03-27 00:27:34.553990408 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"18185208cbc0e5a4700badd6e39bb12d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":18.0,
        "timestamp":"2018-03-27 00:27:34.674081431 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"80de4a2b73c41cf71ef7d30e1f2b9494"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:34.796130888 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"fa941bad2325cb097deb97743007ff36"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":-0.95,
        "timestamp":"2018-03-27 00:27:35.401668589 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"285e7b428eb467678097ecab5f765d7c"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:34.270756556 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"5beec8c6db5445fd164566478997ff30"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.41,
        "timestamp":"2018-03-27 00:27:34.363744778 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"1e93da83dd383757474f539314446c3d"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":9.606,
        "timestamp":"2018-03-27 00:27:35.819361251 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"880d01fd6edd947ceb75f131324eecb7"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":2.85,
        "timestamp":"2018-03-27 00:27:36.244524536 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"b050676303b65806ef664e6a07acf2dc"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":18.88,
        "timestamp":"2018-03-27 00:27:35.574651911 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"b0efdac41dfc7e8261dfd4bd2369b161"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:36.479001057 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"b4bf920c24ad7c2e23360ffcda9f4b5d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27T00:27:36.825599+00:00",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"3f336eb0bb188de8c72650d406225ffa"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:36.36390881 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"2079f261767869c929e01ba10132eceb"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.85,
        "timestamp":"2018-03-27 00:27:36.595785182 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"e955c02a134ff2ac6e9e3a9dedc67dc1"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.34,
        "timestamp":"2018-03-27 00:27:36.709157841 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec2-c1-wrigley",
      "board":"vec",
      "device":"645a790d97fc93ee12ec5fbb514230d7"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":18.0,
        "timestamp":"2018-03-27 00:27:32.957080791 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"b0efdac41dfc7e8261dfd4bd2369b161"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.85,
        "timestamp":"2018-03-27 00:27:33.059350972 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"18185208cbc0e5a4700badd6e39bb12d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.63,
        "timestamp":"2018-03-27 00:27:33.170661964 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"fa941bad2325cb097deb97743007ff36"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":79.853,
        "timestamp":"2018-03-27 00:27:33.779212524 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"285e7b428eb467678097ecab5f765d7c"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":48.608,
        "timestamp":"2018-03-27 00:27:35.143883189 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"880d01fd6edd947ceb75f131324eecb7"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27T00:27:36.843812+00:00",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"3f336eb0bb188de8c72650d406225ffa"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:35.243033733 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"5beec8c6db5445fd164566478997ff30"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.49,
        "timestamp":"2018-03-27 00:27:35.32608591 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"1e93da83dd383757474f539314446c3d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:34.883335497 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"b4bf920c24ad7c2e23360ffcda9f4b5d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:35.520428113 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"80de4a2b73c41cf71ef7d30e1f2b9494"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:35.636458257 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"645a790d97fc93ee12ec5fbb514230d7"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:36.167096476 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"c5d8272bc1106aa12225850d33483f33"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.85,
        "timestamp":"2018-03-27 00:27:36.271218018 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"e955c02a134ff2ac6e9e3a9dedc67dc1"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:36.381432508 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"2079f261767869c929e01ba10132eceb"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":6.65,
        "timestamp":"2018-03-27 00:27:36.057917375 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec5-c1-wrigley",
      "board":"vec",
      "device":"b050676303b65806ef664e6a07acf2dc"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:34.485358253 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"e955c02a134ff2ac6e9e3a9dedc67dc1"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":0.0,
        "timestamp":"2018-03-27 00:27:35.093804234 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"285e7b428eb467678097ecab5f765d7c"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:34.181074241 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"b0efdac41dfc7e8261dfd4bd2369b161"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.49,
        "timestamp":"2018-03-27 00:27:34.283197766 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"1e93da83dd383757474f539314446c3d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:34.381244117 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"c5d8272bc1106aa12225850d33483f33"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:36.409486619 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"80de4a2b73c41cf71ef7d30e1f2b9494"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27T00:27:36.879962+00:00",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"3f336eb0bb188de8c72650d406225ffa"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.49,
        "timestamp":"2018-03-27 00:27:36.183073194 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"5beec8c6db5445fd164566478997ff30"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:36.293341489 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"2079f261767869c929e01ba10132eceb"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":0.0,
        "timestamp":"2018-03-27 00:27:33.816854809 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"b050676303b65806ef664e6a07acf2dc"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:36.522880402 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"fa941bad2325cb097deb97743007ff36"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:36.658689779 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"645a790d97fc93ee12ec5fbb514230d7"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":0.0,
        "timestamp":"2018-03-27 00:27:36.895690617 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"880d01fd6edd947ceb75f131324eecb7"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.63,
        "timestamp":"2018-03-27 00:27:33.983691282 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"18185208cbc0e5a4700badd6e39bb12d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:34.097590495 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec6-c1-wrigley",
      "board":"vec",
      "device":"b4bf920c24ad7c2e23360ffcda9f4b5d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:33.475447487 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"c5d8272bc1106aa12225850d33483f33"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:33.843729447 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"80de4a2b73c41cf71ef7d30e1f2b9494"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.49,
        "timestamp":"2018-03-27 00:27:33.598833658 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"fa941bad2325cb097deb97743007ff36"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.41,
        "timestamp":"2018-03-27 00:27:33.714140935 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"645a790d97fc93ee12ec5fbb514230d7"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27T00:27:36.919100+00:00",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"3f336eb0bb188de8c72650d406225ffa"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.85,
        "timestamp":"2018-03-27 00:27:33.930279806 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"b0efdac41dfc7e8261dfd4bd2369b161"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.49,
        "timestamp":"2018-03-27 00:27:34.039614426 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"2079f261767869c929e01ba10132eceb"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:34.150667279 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"b4bf920c24ad7c2e23360ffcda9f4b5d"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":5.858,
        "timestamp":"2018-03-27 00:27:34.388039226 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"880d01fd6edd947ceb75f131324eecb7"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:35.927244334 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"5beec8c6db5445fd164566478997ff30"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.56,
        "timestamp":"2018-03-27 00:27:34.567299471 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"1e93da83dd383757474f539314446c3d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":18.8,
        "timestamp":"2018-03-27 00:27:34.681450265 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"18185208cbc0e5a4700badd6e39bb12d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.93,
        "timestamp":"2018-03-27 00:27:34.794535662 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"e955c02a134ff2ac6e9e3a9dedc67dc1"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":7.336,
        "timestamp":"2018-03-27 00:27:35.221170999 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"b050676303b65806ef664e6a07acf2dc"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":12.983,
        "timestamp":"2018-03-27 00:27:35.836262824 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec3-c1-wrigley",
      "board":"vec",
      "device":"285e7b428eb467678097ecab5f765d7c"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.85,
        "timestamp":"2018-03-27 00:27:36.371482079 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"b0efdac41dfc7e8261dfd4bd2369b161"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:36.475687036 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"1e93da83dd383757474f539314446c3d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":20.06,
        "timestamp":"2018-03-27 00:27:36.579821269 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"e955c02a134ff2ac6e9e3a9dedc67dc1"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:36.708051003 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"80de4a2b73c41cf71ef7d30e1f2b9494"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.78,
        "timestamp":"2018-03-27 00:27:36.831144507 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"fa941bad2325cb097deb97743007ff36"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":21.85,
        "timestamp":"2018-03-27 00:27:35.666520621 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"b050676303b65806ef664e6a07acf2dc"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":104.658,
        "timestamp":"2018-03-27 00:27:36.276649856 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"285e7b428eb467678097ecab5f765d7c"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:36.918600792 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"5beec8c6db5445fd164566478997ff30"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":18.57,
        "timestamp":"2018-03-27 00:27:33.710106794 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"2079f261767869c929e01ba10132eceb"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":20.84,
        "timestamp":"2018-03-27 00:27:31.329975591 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"18185208cbc0e5a4700badd6e39bb12d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:31.442163201 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"b4bf920c24ad7c2e23360ffcda9f4b5d"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27T00:27:36.969472+00:00",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"3f336eb0bb188de8c72650d406225ffa"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":null,
        "timestamp":"2018-03-27 00:27:34.862950819 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"c5d8272bc1106aa12225850d33483f33"
    }
  },
  {
    "type":"temperature",
    "data":{
      "temperature":{
        "value":17.71,
        "timestamp":"2018-03-27 00:27:35.000592161 +0000 UTC",
        "unit":{
          "symbol":"C",
          "name":"degrees celsius"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"645a790d97fc93ee12ec5fbb514230d7"
    }
  },
  {
    "type":"pressure",
    "data":{
      "pressure":{
        "value":-71.356,
        "timestamp":"2018-03-27 00:27:35.247448539 +0000 UTC",
        "unit":{
          "symbol":"Pa",
          "name":"pascals"
        }
      }
    },
    "location":{
      "rack":"vec4-c1-wrigley",
      "board":"vec",
      "device":"880d01fd6edd947ceb75f131324eecb7"
    }
  }
]vapor@vec1-c1-wrigley:~/src```

logger.debug('scan_cache_rack_id, board_id, device_info: {}, {}, {}'.format(
scan_cache_rack.get('id', None),
scan_cache_board.get('id', None),
scan_cache_device.get('info', None)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused about what exactly is going on here.

we're iterating through the _cache which is the metainfo cache. these bits are then traversing through the scan cache, but the scan cache is built off of the metainfo cache, so when we are searching for a rack, board, device, info, etc in the scan cache, we should already be able to access it via the loop variable v (bad name for it now that things have gotten more complex.. v is really the device, specifically the MetainfoResponse for the device - as defined in the gRPC proto: https://github.com/vapor-ware/synse-server-grpc/blob/master/synse.proto#L166)

so really, scan_cache_board should always be the same as board, scan_cache_device should be the same as device, and scan_cache_rack should be the same as rack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the initial result set I just pasted in above, there is no device_info. Auto fan needs the mapping to the device_info for sanity's sake.

Without it, guess where the rack location is for this thermistor? I don't know either: c5d8272bc1106aa12225850d33483f33

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - I'm essentially joining tables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each data point is a join of these data (reading, location, and scan)
There are currently 54 thermistor and 18 pressure sensor reads in the result set. 18 more thermistors are coming in hardware.
``
{
"type":"temperature",
"data":{
"temperature":{
"value":19.67,
"timestamp":"2018-03-27 21:48:07.742104699 +0000 UTC m=+96.137714757",
"unit":{
"symbol":"C",
"name":"degrees celsius"
}
}
},
"location":{
"rack":"vec4-c1-wrigley",
"board":"vec",
"device":"1e93da83dd383757474f539314446c3d"
},
"scan_cache_device":{
"id":"1e93da83dd383757474f539314446c3d",
"info":"Rack Temperature 3 Spare",
"type":"temperature"
}
},

@MatthewHink MatthewHink merged commit ca37833 into v2.0-dev Apr 2, 2018
@MatthewHink MatthewHink deleted the mhink-v2.0-dev-fan branch April 2, 2018 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants