xref: /openbmc/entity-manager/docs/associations.md (revision 3ed6525083b3583a5c639b39cc8c2c134937b8d2)
13f3fa4cdSMatt Spinler# Associations
23f3fa4cdSMatt Spinler
33f3fa4cdSMatt SpinlerEntity Manager will create [associations][1] between entities in certain cases.
43f3fa4cdSMatt Spinler
53f3fa4cdSMatt Spinler## `contained_by`, `containing`
63f3fa4cdSMatt Spinler
73f3fa4cdSMatt SpinlerEntity Manager can model the [physical topology][2] of how entities plug into
83f3fa4cdSMatt Spinlereach other when upstream and downstream ports are added as `Exposes` elements.
93f3fa4cdSMatt SpinlerIt will then create the 'upstream containing downstream' and 'downstream
103f3fa4cdSMatt Spinlercontained_by upstream' associations for the connected entities.
113f3fa4cdSMatt Spinler
123f3fa4cdSMatt SpinlerFor example, taken from the referenced physical topology design:
133f3fa4cdSMatt Spinler
143f3fa4cdSMatt Spinlersuperchassis.json:
153f3fa4cdSMatt Spinler
163f3fa4cdSMatt Spinler```json
173f3fa4cdSMatt Spinler{
183f3fa4cdSMatt Spinler  "Exposes": [
193f3fa4cdSMatt Spinler    {
203f3fa4cdSMatt Spinler      "Name": "MyPort",
213f3fa4cdSMatt Spinler      "Type": "BackplanePort"
223f3fa4cdSMatt Spinler    }
233f3fa4cdSMatt Spinler  ],
243f3fa4cdSMatt Spinler  "Name": "Superchassis"
253f3fa4cdSMatt Spinler}
263f3fa4cdSMatt Spinler```
273f3fa4cdSMatt Spinler
283f3fa4cdSMatt Spinlersubchassis.json:
293f3fa4cdSMatt Spinler
303f3fa4cdSMatt Spinler```json
313f3fa4cdSMatt Spinler{
323f3fa4cdSMatt Spinler  "Exposes": [
333f3fa4cdSMatt Spinler    {
343f3fa4cdSMatt Spinler      "ConnectsToType": "BackplanePort",
353f3fa4cdSMatt Spinler      "Name": "MyDownstreamPort",
363f3fa4cdSMatt Spinler      "Type": "DownstreamPort"
373f3fa4cdSMatt Spinler    }
383f3fa4cdSMatt Spinler  ],
393f3fa4cdSMatt Spinler  "Name": "Subchassis"
403f3fa4cdSMatt Spinler}
413f3fa4cdSMatt Spinler```
423f3fa4cdSMatt Spinler
433f3fa4cdSMatt SpinlerEntity Manager will create the 'Superchassis containing Subchassis' and
443f3fa4cdSMatt Spinler'Subchassis contained_by Superchassis` associations, putting the associations
453f3fa4cdSMatt Spinlerdefinition interface on the downstream entity.
463f3fa4cdSMatt Spinler
473f3fa4cdSMatt Spinler## `powered_by`, `powering`
483f3fa4cdSMatt Spinler
493f3fa4cdSMatt SpinlerIn addition to the `containing` associations, entity-manager will add
503f3fa4cdSMatt Spinler`powering`/`powered_by` associations between a power supply and its parent when
51*3ed65250SMatt Spinlerits downstream port is marked as a `PowerPort`.
52*3ed65250SMatt Spinler
53*3ed65250SMatt SpinlerThe below example shows two PSU ports on the motherboard, where the `Type`
54*3ed65250SMatt Spinlerfields for those ports match up with the `ConnectsToType` field from the PSUs.
55*3ed65250SMatt Spinler
56*3ed65250SMatt Spinlermotherboard.json:
573f3fa4cdSMatt Spinler
583f3fa4cdSMatt Spinler```json
593f3fa4cdSMatt Spinler{
60*3ed65250SMatt Spinler  "Exposes": [
61*3ed65250SMatt Spinler    {
62*3ed65250SMatt Spinler      "Name": "PSU 1 Port",
63*3ed65250SMatt Spinler      "Type": "PSU 1 Port"
64*3ed65250SMatt Spinler    },
65*3ed65250SMatt Spinler    {
66*3ed65250SMatt Spinler      "Name": "PSU 2 Port",
67*3ed65250SMatt Spinler      "Type": "PSU 2 Port"
68*3ed65250SMatt Spinler    }
69*3ed65250SMatt Spinler  ]
70*3ed65250SMatt Spinler}
71*3ed65250SMatt Spinler```
72*3ed65250SMatt Spinler
73*3ed65250SMatt Spinlerpsu.json:
74*3ed65250SMatt Spinler
75*3ed65250SMatt Spinler```json
76*3ed65250SMatt Spinler{
77*3ed65250SMatt Spinler  "Exposes": [
78*3ed65250SMatt Spinler    {
79*3ed65250SMatt Spinler      "ConnectsToType": "PSU$ADDRESS % 4 + 1 Port",
80*3ed65250SMatt Spinler      "Name": "PSU Port",
813f3fa4cdSMatt Spinler      "Type": "DownstreamPort",
823f3fa4cdSMatt Spinler      "PowerPort": true
833f3fa4cdSMatt Spinler    }
84*3ed65250SMatt Spinler  ]
85*3ed65250SMatt Spinler}
863f3fa4cdSMatt Spinler```
873f3fa4cdSMatt Spinler
883f3fa4cdSMatt Spinler[1]:
893f3fa4cdSMatt Spinler  https://github.com/openbmc/docs/blob/master/architecture/object-mapper.md#associations
903f3fa4cdSMatt Spinler[2]: https://github.com/openbmc/docs/blob/master/designs/physical-topology.md
91