Association not created when sensors from DBus

Save the path when create virtual sensors from DBus.
Main functions after saving:
* Set the threshold on the path corresponding to entity-manager
* Create an association

I found that the sensor created by reading virtual_sensor_config.json will create association.
However,the virtual sensor created from DBus has no association,
so I added this.
In this way, my web/redfish can display this virtual sensor.

```
root@NULL:~# busctl introspect  xyz.openbmc_project.VirtualSensor /xyz/openbmc_project/sensors/temperature/NVMe_MAX_Temp xyz.openbmc_project.Association.Definitions
NAME                                        TYPE      SIGNATURE RESULT/VALUE                                                                    FLAGS
.Associations                               property  a(sss)    1 "chassis" "all_sensors" "/xyz/openbmc_project/inventory/system/nvme/NVMe_MAX" emits-change writable
```

The BMC web will find my all_sensor according to the following steps:

```
root@NULL:~#  busctl call   xyz.openbmc_project.ObjectMapper   /xyz/openbmc_project/object_mapper  xyz.openbmc_project.ObjectMapper  GetSubTreePaths   sias  /xyz/openbmc_project/inventory   0 2 xyz.openbmc_project.Inventory.Item.Board xyz.openbmc_project.Inventory.Item.Chassis --verbose
MESSAGE "as" {
        ARRAY "s" {
                STRING "/xyz/openbmc_project/inventory/system/board/FP5280G2_Motherboard";
                STRING "/xyz/openbmc_project/inventory/system/chassis";
                STRING "/xyz/openbmc_project/inventory/system/nvme/NVMe_MAX";
        };
};

root@NULL:~# busctl call   xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/inventory/system/nvme/NVMe_MAX/all_sensors  org.freedesktop.DBus.Properties Get ss xyz.openbmc_project.Association endpoints --verbose
MESSAGE "v" {
        VARIANT "as" {
                ARRAY "s" {
                        STRING "/xyz/openbmc_project/sensors/temperature/NVMe_MAX_Temp";
                };
        };
};
```

Signed-off-by: Tao Lin <lintao.lc@inspur.com>
Change-Id: I5ab8ce532dde9cff837f85d1e27a0a420942a8ce
2 files changed
tree: 3ac02ba4c1a41eca1c632395f7d3d259549f1042
  1. subprojects/
  2. .clang-format
  3. .editorconfig
  4. .gitignore
  5. .markdownlint.yaml
  6. .prettierrc.yaml
  7. dbusSensor.hpp
  8. dbusUtils.hpp
  9. exprtkTools.hpp
  10. LICENSE
  11. meson.build
  12. OWNERS
  13. phosphor-virtual-sensor.service.in
  14. README.md
  15. thresholds.hpp
  16. virtual_sensor_config.json
  17. virtualSensor.cpp
  18. 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).