commit | 32dff21bf5ec860a359b70b9d9dcae656b40578e | [log] [tgz] |
---|---|---|
author | Patrick Williams <patrick@stwcx.xyz> | Thu Feb 09 13:54:18 2023 -0600 |
committer | Patrick Williams <patrick@stwcx.xyz> | Thu Feb 09 14:15:03 2023 -0600 |
tree | f5df8fabd26b17b2e1a6870f0bc4a74e7dee68f2 | |
parent | a291ce1acfc8935dc69675c2e29bf1dee4f68ccd [diff] |
config-file: search multiple directories Restricting the config file to `/usr/share` makes testing difficult and prevents the config file from being present on a, typically for the BMC, read-write volume. Change the config loading code to search: 1. pwd 2. /var/lib/phosphor-virtual-sensor 3. /usr/share/phosphor-virtual-sensor Tested: Ran strace on the changes and observed the expected file search. ``` getcwd("pwd/phosphor-virtual-sensor/builddir", 4096) = 75 newfstatat(AT_FDCWD, "pwd/phosphor-virtual-sensor/builddir/virtual_sensor_config.json", 0x7fff60a0af90, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/var/lib/phosphor-virtual-sensor/virtual_sensor_config.json", 0x7fff60a0af90, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/usr/share/phosphor-virtual-sensor/virtual_sensor_config.json", 0x7fff60a0af90, 0) = -1 ENOENT (No such file or directory) ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I70854d565a3b13cd48c27a80da84de54c00a0603
phosphor-virtual-sensor reads the configuration file virtual_sensor_config.json
from one of three locations:
/var/lib/phosphor-virtual-sensor
/usr/share/phosphor-virtual-sensor
By default the repository will install a sample config into (3).
There are two types of data in this file.
See virtual_sensor_config.json
in this repository for an example. Sensors added this way can use any expression that is accepted by exprtk.
For example:
{ "Desc": { "Config": "D-Bus", "Type": "ModifiedMedian" } }
Sensors added this way can only use a set of restricted calculations. Currently the only type supported is modifiedMedian
.
The virtual sensor configuration information needs to be added into the relevant hardware configuration file in entity-manager. This method of adding a virtual sensor allows a recipe that builds for different hardware configurations to have different virtual sensors for each configuration.
The virtual sensor configuration in entity manager follows a different format to the JSON in virtual_sensor_config.json
(specified in entity-manager/schemas/VirtualSensor.json).