Fixes around persisting values in entity-manager

This fixes three problems that were causing "Faild to set dbus
property." error traces to show up.

1. In VirtualSensor::createThresholds() the setEntityPath() and
   setEntityInterfaceHigh/Low() calls have to be made on the threshold
   objects before the critical/warning/High/Low() functions are called
   so that the path and interface is known for the property set call.
   Reorder the code so this is the case.

2. Saving the value in entity-manager only works when the virtual sensor
   config was obtained from entity-manager D-Bus objects, and not when
   it was obtained from virtual_sensor_config.json.  In the latter case,
   the 'entityPath' variable won't have a value, so check for that
   before trying to set a property on entity-manager.

3. If either a 'high' or 'low' threshold property isn't set, then the
   'entityInterfaceHigh/Low' variable will be empty.  Also skip the
   property write in that case.

Tested:  No more error traces, and verified that changing a threshold
value on a virtual sensor is still reflected in entity-manager when its
config was from EM in the first place.

Change-Id: I67dc35fb4b8f4c1367231e22ddde91fbd1bb354d
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
2 files changed
tree: 69ecd89ee1904716e7538e543078527b4fe2e227
  1. subprojects/
  2. .clang-format
  3. .editorconfig
  4. .gitignore
  5. .prettierrc.yaml
  6. dbusSensor.hpp
  7. dbusUtils.hpp
  8. exprtkTools.hpp
  9. LICENSE
  10. meson.build
  11. OWNERS
  12. phosphor-virtual-sensor.service.in
  13. README.md
  14. thresholds.hpp
  15. virtual_sensor_config.json
  16. virtualSensor.cpp
  17. virtualSensor.hpp
README.md

phosphor-virtual-sensor

phosphor-virtual-sensor reads in virtual_sensor_config.json There are two types of data in this file:

virtual sensor configuration information

See virtual_sensor_config.json in this repository for an example. Sensors added this way can use any expression that is accepted by exprtk.

information to get a virtual sensor configuraton from D-Bus

For example:

{
  "Desc": {
    "Config": "D-Bus",
    "Type": "ModifiedMedian"
  }
}

Sensors added this way can only use a set of restricted calculations. At this stage 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).