Make sure tlbmc sensors are dynamic

Certain sensors can be deleted, e.g., PSU sensors, then recreated when the power gets resumed. tlbmc used to keep the sensor unchanged, which results in stale input file descriptor.

This commit adds a temporary solution to recreate input device when old device returns "not found". An ideal solution is using IPC to track host power or integrate host power (GPIO monitoring) into tlbmc, which is a goal in the next iteration.

Also add sensor device path into the Redfish error message for debuggability.

On real machine,

```
# device rejoin
root@dddhh9-nfd01:~# echo adm1272 > /sys/bus/i2c/devices/i2c-30/new_device 0x1f
root@dddhh9-nfd01:~# ls /sys/bus/i2c/devices/i2c-30/30-001f/
driver     hwmon      modalias   name       power      subsystem  uevent
root@dddhh9-nfd01:~# ls /sys/bus/i2c/devices/i2c-30/30-001f/hwmon/
hwmon9
root@dddhh9-nfd01:~# ls /sys/bus/i2c/devices/i2c-30/30-001f/hwmon/hwmon9/
curr1_highest         in1_highest           in2_highest           in_samples            power1_max            temp1_max
curr1_input           in1_input             in2_input             name                  power1_reset_history  temp1_max_alarm
curr1_label           in1_label             in2_label             of_node               power_samples         temp1_reset_history
curr1_max             in1_max               in2_max               power                 subsystem             uevent
curr1_max_alarm       in1_max_alarm         in2_max_alarm         power1_alarm          temp1_crit
curr1_reset_history   in1_min               in2_min               power1_input          temp1_crit_alarm
curr_samples          in1_min_alarm         in2_min_alarm         power1_input_highest  temp1_highest
device                in1_reset_history     in2_reset_history     power1_label          temp1_input

```

Before this change,
```
root@dddhh9-nfd01:~# curl localhost:18080/redfish/v1/Chassis/BigGulp_1/Sensors/power_hotswap_in_Input_Power
{
  "error": {
    "message": "Failed to read from input device: No such device; input device path: /sys/bus/i2c/devices/i2c-30/30-001f/hwmon/hwmon9/power1_input"
  }
```

After this change:
```
root@dddhh9-nfd01:~# curl localhost:18080/redfish/v1/Chassis/BigGulp_1/Sensors/power_hotswap_in_Input_Power
{
  "@odata.id": "/redfish/v1/Chassis/BigGulp_1/Sensors/power_hotswap_in_Input_Power",
  "@odata.type": "#Sensor.v1_2_0.Sensor",
  "Description": "Sensor",
  "Id": "power_hotswap_in_Input_Power",
  "Name": "hotswap in Input Power",
  "Reading": 22.306597,
  "ReadingRangeMax": 4700.0,
  "ReadingRangeMin": -11.0,
  "ReadingType": "Power",
  "ReadingUnits": "W",
  "RelatedItem": [
    {
      "@odata.id": "/redfish/v1/Chassis/BigGulp_1"
    }
  ],
  "Status": {
    "Health": "OK",
    "State": "Enabled"
  },
  "Thresholds": {
    "LowerCritical": {
      "Reading": -10.0
    },
    "UpperCritical": {
      "Reading": 4600.0
    }
  }
}
```

PiperOrigin-RevId: 744088791
Change-Id: I92b52d410ba24b9a264963b2e62e5597f21ea96a
9 files changed
tree: 4c2a02ffefc31bdcce6fc927746f38a2bac2eb9a
  1. .github/
  2. config/
  3. g3/
  4. http/
  5. include/
  6. plugins/
  7. redfish-core/
  8. redfish_authorization/
  9. scripts/
  10. src/
  11. static/
  12. subprojects/
  13. test/
  14. tlbmc/
  15. .clang-format
  16. .clang-tidy
  17. .clang-tidy-ignore
  18. .dockerignore
  19. .gitignore
  20. .markdownlint.yaml
  21. .openbmc-enforce-gitlint
  22. .openbmc-no-clang
  23. .prettierignore
  24. .shellcheck
  25. AGGREGATION.md
  26. CLIENTS.md
  27. COMMON_ERRORS.md
  28. DBUS_USAGE.md
  29. DEVELOPING.md
  30. gcovr.cfg
  31. HEADERS.md
  32. LICENSE
  33. meson.build
  34. meson_options.txt
  35. OEM_SCHEMAS.md
  36. OWNERS
  37. PLUGINS.md
  38. README.md
  39. README_GOOGLE.md
  40. Redfish.md
  41. run-ci
  42. setup.cfg
  43. TESTING.md
  44. UNIT_TESTING.md
README.md

OpenBMC webserver

This project is Google's version of BMCWeb.

See Readme Google for Google added features. The following is the original README of OpenBMC/BMCWeb.

==============================================================================

This component attempts to be a “do everything” embedded webserver for OpenBMC.

Features

The webserver implements a few distinct interfaces:

  • DBus event websocket. Allows registering on changes to specific dbus paths, properties, and will send an event from the websocket if those filters match.
  • OpenBMC DBus REST api. Allows direct, low interference, high fidelity access to dbus and the objects it represents.
  • Serial: A serial websocket for interacting with the host serial console through websockets.
  • Redfish: A protocol compliant, DBus to Redfish translator.
  • KVM: A websocket based implementation of the RFB (VNC) frame buffer protocol intended to mate to webui-vue to provide a complete KVM implementation.

Protocols

bmcweb at a protocol level supports http and https. TLS is supported through OpenSSL.

AuthX

Authentication

Bmcweb supports multiple authentication protocols:

  • Basic authentication per RFC7617
  • Cookie based authentication for authenticating against webui-vue
  • Mutual TLS authentication based on OpenSSL
  • Session authentication through webui-vue
  • XToken based authentication conformant to Redfish DSP0266

Each of these types of authentication is able to be enabled or disabled both via runtime policy changes (through the relevant Redfish APIs) or via configure time options. All authentication mechanisms supporting username/password are routed to libpam, to allow for customization in authentication implementations.

Authorization

All authorization in bmcweb is determined at routing time, and per route, and conform to the Redfish PrivilegeRegistry.

*Note: Non-Redfish functions are mapped to the closest equivalent Redfish privilege level.

Configuration

bmcweb is configured per the meson build files. Available options are documented in meson_options.txt

Compile bmcweb with default options

meson builddir
ninja -C builddir

If any of the dependencies are not found on the host system during configuration, meson will automatically download them via its wrap dependencies mentioned in bmcweb/subprojects.

Use of persistent data

bmcweb relies on some on-system data for storage of persistent data that is internal to the process. Details on the exact data stored and when it is read/written can seen from the persistent_data namespace.

TLS certificate generation

When SSL support is enabled and a usable certificate is not found, bmcweb will generate a self-signed a certificate before launching the server. Please see the bmcweb source code for details on the parameters this certificate is built with.

Redfish Aggregation

bmcweb is capable of aggregating resources from satellite BMCs. Refer to AGGREGATION.md for more information on how to enable and use this feature.