1# presence_detection
2
3## Description
4Specifies how to detect whether a device is present.
5
6Some devices are only present in certain system configurations.  For example:
7* A regulator is only present when a related processor or memory module is
8  present.
9* A system supports multiple storage backplane types, and the device only
10  exists on one of the backplanes.
11
12Device presence is detected by executing actions, such as
13[compare_presence](compare_presence.md) and [compare_vpd](compare_vpd.md).
14
15Device operations like [configuration](configuration.md) and [sensor
16monitoring](sensor_monitoring.md) will only be performed if the actions
17indicate the device is present.
18
19The actions can be specified in two ways:
20* Use the "rule_id" property to specify a standard rule to run.
21* Use the "actions" property to specify an array of actions that are unique to
22  this device.
23
24The return value of the rule or the last action in the array indicates whether
25the device is present.  A return value of true means the device is present;
26false means the device is missing.
27
28Device presence will only be detected once per boot of the system.  Presence
29will be determined prior to the first device operation (such as configuration).
30When the system is re-booted, presence will be re-detected.  As a result,
31presence detection is not supported for devices that can be removed or added
32(hot-plugged) while the system is booted and running.
33
34## Properties
35| Name | Required | Type | Description |
36| :--- | :------: | :--- | :---------- |
37| comments | no | array of strings | One or more comment lines describing the presence detection. |
38| rule_id | see [notes](#notes) | string | Unique ID of the [rule](rule.md) to execute. |
39| actions | see [notes](#notes) | array of [actions](action.md) | One or more actions to execute. |
40
41### Notes
42* You must specify either "rule_id" or "actions".
43
44## Examples
45```
46{
47  "comments": [ "Regulator is only present on the FooBar backplane" ],
48  "rule_id": "is_foobar_backplane_installed_rule"
49}
50
51{
52  "comments": [ "Regulator is only present when CPU 3 is present" ],
53  "actions": [
54    {
55      "compare_presence": {
56        "fru": "/system/chassis/motherboard/cpu3",
57        "value": true
58      }
59    }
60  ]
61}
62```
63