Skip to content

Add UnavailableOffline state mapping and add getResourceStatus helper - #1501

Draft
jnin-dev wants to merge 9 commits into
ibm-openbmc:1210from
jnin-dev:dev/1210/available_state
Draft

Add UnavailableOffline state mapping and add getResourceStatus helper#1501
jnin-dev wants to merge 9 commits into
ibm-openbmc:1210from
jnin-dev:dev/1210/available_state

Conversation

@jnin-dev

Copy link
Copy Markdown
Contributor
  1. Added a utility function to reduce code duplication for retrieving
    resource's Status.State and Status.Health
  2. Mapped D-Bus Available to Redfish UnavailableOffline

Tested:

  • Build successfully
  • Unit tests passed
  • Sent requests and received Status.State and Status.Health as expected
    with the new mapping
curl -k -v https://${bmc}/redfish/v1/Systems/system/Processors/mcm/SubProcessors/core0

Results with

{
  "@odata.id": "/redfish/v1/Systems/system/Processors/mcm/SubProcessors/core0",
  "@odata.type": "#Processor.v1_18_0.Processor",
  "Enabled": true,
  "Id": "core0",
  "Name": "Node 0 processor module Core 0",
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
 }

@jnin-dev jnin-dev changed the title Add UnavailableOffline state mapping and add getResourceStatus helper WIP: Add UnavailableOffline state mapping and add getResourceStatus helper Jul 10, 2026
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch from ac44a87 to fd33698 Compare July 10, 2026 22:02
@jnin-dev jnin-dev changed the title WIP: Add UnavailableOffline state mapping and add getResourceStatus helper Add UnavailableOffline state mapping and add getResourceStatus helper Jul 13, 2026
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch 2 times, most recently from aee002e to 3e4fbe1 Compare July 14, 2026 00:25

@jeaaustx jeaaustx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the change looks reasonable to me. I have a few comments in the code and a couple of comments on the commit messages:

  • The utils function commit message talks about UnavailableOffline but the output example in the commit message only shows Absent. For clarity it would be good to show the different cases in the output in the commit message.
  • I'm wondering about carrying these patches and the ease of handling rebasing in the future. I suggest considering breaking these up to a single commit that adds the utility function and then separate commits for each of the places changing to use the utility function. (This would help with chicken/egg problem on rebase of needing support in place that pulls in the utility function for any other commits dependant on the function.) But...
  • Is this going upstream? If so then above concern about rebase is less important. However for upstream it is still easiest to get the utility function commit in by itself.
  • Probably should add some unit tests for the utiilty function.

Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/lib/cable.hpp Outdated
Comment thread redfish-core/lib/assembly.hpp Outdated
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch 3 times, most recently from 354e5cc to 4d27cb6 Compare July 20, 2026 23:12
@jnin-dev

Copy link
Copy Markdown
Contributor Author

The utils function commit message talks about UnavailableOffline but the output example in the commit message only shows Absent. For clarity it would be good to show the different cases in the output in the commit message.

I added to the commit message about the difference cases for Status.State

I'm wondering about carrying these patches and the ease of handling rebasing in the future. I suggest considering breaking these up to a single commit that adds the utility function and then separate commits for each of the places changing to use the utility function.

I believe the utility function will go upstream. I've separated them into different commits for each resource since it'll be cleaner

Probably should add some unit tests for the utiilty function.

Done.

@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch from 4d27cb6 to e49178a Compare July 20, 2026 23:38
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch 3 times, most recently from 0d8668c to 65d140a Compare July 21, 2026 21:37
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread test/redfish-core/include/utils/resource_utils_test.cpp
Comment thread test/redfish-core/include/utils/resource_utils_test.cpp
Comment thread redfish-core/lib/processor.hpp
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch from 65d140a to 040f27d Compare July 22, 2026 16:18
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/include/utils/resource_utils.hpp Outdated
Comment thread redfish-core/lib/assembly.hpp Outdated
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch 4 times, most recently from 2f26805 to 293b40c Compare July 23, 2026 16:55

@jeaaustx jeaaustx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. I have just the one comment about the refactoring.

Comment thread redfish-core/lib/processor.hpp
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch 3 times, most recently from 8052c8c to d08e3c0 Compare July 28, 2026 15:25
- State `Available` will be mapped to `UnavailableOffline` for
  Status.State for resources that are present but unavailable
- Added a utility function to reduce code duplication for retrieving
  resource's Status.State (`getResourceState`) and Status.Health
  (`getResourceHealth`)

Tested:
- Compiles and builds
- Unit tests pass

Change-Id: I1164a9412cbd4e1ab8938366ffc7ea9c7fe58786
Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch from d08e3c0 to 33ab4e5 Compare August 4, 2026 16:37
- Utilized resource util's getResourceState() and getResourceHealth()
  to get the Status.State and Status.Health of the cable resource

- Cable will now have the Status.Health where it previously did not have
  it

Tested:
- Unit tests passed
- Redfish Service Validator passed
- Response as expected:
```
curl -k -v http://${bmc}/redfish/v1/Cables/dp1_cable0
```
Results in
```
curl -k -v https://${bmc}/redfish/v1/Cables/dp1_cable0
```
Results in
```
{
  "@odata.id": "/redfish/v1/Cables/dp1_cable0",
  "@odata.type": "#Cable.v1_0_0.Cable",
  "CableType": "",
  "Id": "dp1_cable0",
  "Name": "Cable",
  ...
  "Status": {
    "State": "Enabled",
    "Health": "OK"
  }
  ...
}
```

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
- Utilized resource util's getResourceState() and getResourceHealth()
  to get Status.State and Status.Health of the fan resource

Tested:
- Unit tests passed
- Redfish Service Validator passed
- Response as expected:
```
curl -k -v https://${bmc}/redfish/v1/Chassis/chassis/ThermalSubsystem/Fans/fan0
```
Results in
```
{
  "@odata.id": "/redfish/v1/Chassis/chassis/ThermalSubsystem/Fans/fan0",
  "@odata.type": "#Fan.v1_3_0.Fan",
  "Id": "fan0",
  "Location": {
    "PartLocation": {
      "ServiceLabel": "U78DA.N00.WZS003H-A0"
    }
  },
  "Manufacturer": "Delta",
  "Model": "7B5F",
  "Name": "fan0",
  "PartNumber": "02YK323",
  "SerialNumber": "YL12JP1C1234",
  "SparePartNumber": "02YK323",
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
  }
```
Where the state can be `Enabled`, `UnavailableOffline`, or `Absent`

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
- Utilized resource util's getResourceState and getResourceHealth to
  get the Status.State and Status.Health of the power supply resource

- This commit will decouple Status.Health from Status.State

Tested:
- Unit tests passed
- Redfish Service Validator passed
- Response as expected:
```
curl -k -v https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply0
```
Results in
```
{
  "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply0",
  ...
  "SerialNumber": "Y YL106 63F0",
  "SparePartNumber": "0      ",
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
  }
  ...
}
```

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
- Utilized resource util's getResourceState and getResourceHealth to
  get the Status.State and Status.Health of the fabric adapters resource

Tested:
- Unit tests passed
- Redfish Service Validator passed
```
curl -k -v https://${bmc}/redfish/v1/Systems/system/FabricAdapters/pcie_card0
```
Results in
```
{
  "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/pcie_card0",
  "@odata.type": "#FabricAdapter.v1_4_0.FabricAdapter",
  ...
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
  }
  ...
}
```
If the resource is functional and present but not available

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
- Utilize getResourceState and getResourceHealth utility function for
  resource's Status.State and Status.Health

Tested:
- Unit tests passed
- Redfish Service Validator passed
- Request expected:
```
curl -k -v https://${bmc}/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports/dp0_connector1
```
Results in
```
{
  "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0/Ports/dp0_connector1",
  "@odata.type": "#Port.v1_11_0.Port",
  "Id": "dp0_connector1",
  ...
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
  }
}
```
if the resource is present but not available

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
- Utilize getResourceStatus and getResourceHealth where applicable and
  extended Status.State to handle `Available` mapping to
  `UnavailableOffline`

Tested:
- Unit tests passed
- Redfish Service Validator passed
- Request to Processor results in
```
  ...
  "Status": {
    "Health": "OK",
    "State": "Enabled"
  }
  ...
```
or `UnavailableOffline` if not available
- Request to Subprocessors results in
```
{
  "@odata.id": "/redfish/v1/Systems/system/Processors/dcm1-cpu1/SubProcessors/core15",
  "@odata.type": "#Processor.v1_18_0.Processor",
  "Enabled": true,
  "Id": "core15",
  "Name": "core15",
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
  }
```
if not available

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
- Added `Available` mapping to `UnavailableOffline` for memory

Tested:
- Unit tests passed
- Redfish Service Validator passed
- Request:
```
curl -k -v https://${bmc}/redfish/v1/Systems/system/Memory/dimm3
```
Results in
```
{
  "@odata.id": "/redfish/v1/Systems/system/Memory/dimm3",
  "@odata.type": "#Memory.v1_12_0.Memory",
  ...
  "Status": {
    "Health": "OK",
    "State": "Enabled"
  }
  ...
```
`UnavailableOffline` if not available
```
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
  }
```

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
- Utilized getResourceState and getResourceHealth utility function for
  Assembly's Status.State and Status.Health

Tested:
- Unit tests and Redfish Service Validator passed
- Request:
```
curl -k -v https://${bmc}/redfish/v1/Chassis/chassis/Assembly
```
Response:
```
  "Status": {
    "Health": "OK",
    "State": "Enabled"
  }
```
Otherwise if Available is false
```
  "Status": {
    "Health": "OK",
    "State": "UnavailableOffline"
  }
```

Signed-off-by: Justin Nguyen <justinnanguyen@gmail.com>
@jnin-dev
jnin-dev force-pushed the dev/1210/available_state branch from 33ab4e5 to 369524b Compare August 4, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants