summaryrefslogtreecommitdiff
path: root/redfish-core
AgeCommit message (Collapse)AuthorFilesLines
2023-07-11Enable bugprone clang tidy checksEd Tanous1-3/+4
We pass basically all of these with flying colors now. Previously there were clang-tidy bugs around bugprone-exception-escape, but those seem to be resolved in clang-tidy-16, so we can turn that check back on. The only thing we had was an instance of bugprone-assignment-in-if-condition, that was trivially fixed. Tested: Clang-tidy passes. Change-Id: Ib2e63e951ee8e4e46f0d1b40bf41f8dca59c9a08 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-07-10Tidy enable modernize-redundant-void-argEd Tanous1-33/+33
We have places where we explicitly set something to the pattern of method(void) This is no longer necessary to declare, so fix the places where we do it to make the codebase consistent, and enable the check. Tested: Clang-tidy passes. Change-Id: I3ef03fc07d65b656fecbcfea638dd12ba95f22e0 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-07-10Incorrect value displayed for total system memoryPriyanga Ramasamy1-4/+5
GUI displays 0 as total system memory when the total size is not exactly divisible by 1024 as the code truncates the floating point value. This commit has the fix for it. Change-Id: I95dc6f5ee9e36bb624315909a264c5d21c054a1d Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
2023-07-06Simplify duration string parsingEd Tanous1-116/+121
The code that was here was quite complex, and relied on a number of c++ features that were hard to track. It also implemented a parser that would parse a given number multiple times. This commit replaces fromDurationString with a single pass, simpler parser, that doesn't rely on templates. It does this with a basic state machine, like one would see in any number of places. This allows the details section to be completely removed, as it can now be simply inlined. This results in a decrease of 1.1KB of the binary size of bmcweb. Note, C++20 now has an implementation of std::chrono::days, which obsoletes the need for redfish::time_utils::details::Days, so that conversion is done opportunistically. Tested: Unit tests pass. Pretty good coverage here. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8eb9bee9807cc102f3680105b39f4eed3bd2e73c
2023-07-06Remove IBM console events from RedfishEd Tanous2-22/+0
The /ibm/v1 console is a different tree than Redfish, and as such, should not be sending non-redfish resource events out. This is very likely to break redfish clients on the other end. If the management console wants an event-like entity, it needs to come up with its own EventService-like resource, considering it is a separate tree. Significant related discussion occurred here: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/36368 Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ic2a9e572099490f8810e03ab08336518f5672690
2023-07-06Aggregation: Add satellite only linksCarson Labrado1-17/+74
Allows the aggregator to insert links to top level collections which are only supported by the satellite bmc. Tested: Links were added to responses for collections which are not currently supported by BMCWeb. Also verified that top level collections and satellite resources were still aggregated correctly. curl localhost/redfish/v1 { ... "Fabrics": { "@odata.id": "/redfish/v1/Fabrics" }, ... } curl localhost/redfish/v1/UpdateService { ... "SoftwareInventory": { "@odata.id": "/redfish/v1/UpdateService/SoftwareInventory" } } The following $expand queries also returned as expected curl -s 'localhost/redfish/v1?$expand=.($levels=1)' curl -s 'localhost/redfish/v1/UpdateService?$expand=.($levels=1)' Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: Ie755f67bd28f81f6677670c09c9a210935ae0af9
2023-07-01Add topology links for ChassisJie Yang1-0/+100
Implement the physical topology design[0] for Chassis resources to report which Chassis contain or are contained by other Chassis. Query this information from the object mapper using associations defined in phosphor-dbus-interfaces[1] and make it available in the Links section of the Redfish result. [0] https://gerrit.openbmc.org/c/openbmc/docs/+/54205 [1] https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/58441 Tested: Built for evb-ast2600 with example JSON configs and ran in QEMU Ran Redfish Service Validator with no new warnings Sample output: ''' curl -k -u root:0penBmc -X GET https://127.0.0.1:60443/redfish/v1/Chassis/Subchassis { "@odata.id": "/redfish/v1/Chassis/Subchassis", "@odata.type": "#Chassis.v1_16_0.Chassis", ... "Id": "Subchassis", "Links": { "ComputerSystems": [ { "@odata.id": "/redfish/v1/Systems/system" } ], "ContainedBy": { "@odata.id": "/redfish/v1/Chassis/Superchassis" }, "ManagedBy": [ { "@odata.id": "/redfish/v1/Managers/bmc" } ] }, ... } curl -k -u root:0penBmc -X GET https://127.0.0.1:60443/redfish/v1/Chassis/Superchassis { "@odata.id": "/redfish/v1/Chassis/Superchassis", "@odata.type": "#Chassis.v1_16_0.Chassis", ... "Id": "Superchassis", "Links": { "ComputerSystems": [ { "@odata.id": "/redfish/v1/Systems/system" } ], "Contains": [ { "@odata.id": "/redfish/v1/Chassis/Subchassis" } ], "Contains@odata.count": 1, "ManagedBy": [ { "@odata.id": "/redfish/v1/Managers/bmc" } ] }, ... } ''' Signed-off-by: Jie Yang <jjy@google.com> Signed-off-by: Zhenwei Chen <zhenweichen0207@gmail.com> Signed-off-by: Benjamin Fair <benjaminfair@google.com> Change-Id: Idc4c3e99b8269bcc5f94112e977a89970abd0bf3
2023-07-01Static IPv6 config: Send relevant error on patch.Nitin Kumar Kotania1-2/+11
This commit will send back relevant redfish error back if the client tries to configure the IPv6 static ip with invalid IPv6 address. Tested By: PATCH -D patch.txt -d '{"IPv6StaticAddresses": [{"Address": "1A:1B:1C:1D:10.5.5.6","PrefixLength": 64}]}' https://${bmc}/redfish/v1/Systems/hypervisor/EthernetInterfaces/eth1 Current behaviour: response: 500 Internal Server Error The request failed due to an internal service error Modified behaviour: response: 400 Bad Request The value '1A:1B:1C:1D:10.5.5.6' for the property Address is of a different format than the property can accept. Change-Id: Ibbd6b82acea51fb16785ffbfaca9ae43956c7cb6 Signed-off-by: Nitin Kumar Kotania <gitnkotania@gmail.com>
2023-06-30Add PCIe Slot information to PCIeDevice schemaLakshmi Yadlapati1-24/+174
To align with Redfish's transition from using the PCIeSlot schema to including the Slot within the PCIeDevice schema, this commit adds PCIe Slot information to the PCIeDevice schema. The corresponding PCIe Slot is retrieved using the 'contained_by' association, which establishes a link from the PCIeDevice object to the PCIeSlot object. If there is no PCIeSlot associated with the PCIeDevice, the Slot properties will not be returned. Directed associations, ‘containing’ and ‘contained_by’, are used to establish a link between PCIeDevice and PCIeSlot. The 'containing' association establishes a link from a PCIeSlot to the PCIeDevice it contains, while the 'contained_by' association establishes a link from a PCIeDevice to the PCIeSlot that contains it. Additionally, this commit refactors the PCIeDevice schema to improve its structure, readability, and adherence to best practices. Redfish commit: https://redfish.dmtf.org/schemas/v1/PCIeDevice.v1_11_0.json Tested: Validator Passed ''' curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card7 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card7", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", "Id": "pcie_card7", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card7/PCIeFunctions" }, "PCIeInterface": { "LanesInUse": -1 }, "Slot": { "Lanes": 0, "SlotType": "FullLength" }, "Status": { "Health": "OK", "State": "Absent" } } PCIeDevice with no association: curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card0 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card0", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", "Id": "pcie_card0", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card0/PCIeFunctions" }, "PCIeInterface": { "LanesInUse": -1 }, "Status": { "Health": "OK", "State": "Absent" } } ''' Change-Id: I15ac33be0035721f44c60fded795092896bce9bd Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com> Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-30Refactor redfishPcieGenerationFromDbus and redfishSlotTypeLakshmi Yadlapati3-15/+30
This commit refactors the redfishPcieGenerationFromDbus and redfishSlotType functions by changing their return types. The return value std::nullopt indicates that there is no output, while the return value pcie_device::PCIeTypes::Invalid indicates that the input was invalid and returns an internal error. Additionally, the code that calls these functions has been updated to accommodate the changes. Tested: Validator passed Change-Id: I3f7c1a3c8c6b53fd9a39928e3ad9a5fed9be97ff Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-30Fix a bug for zero arg EventLog entriesEd Tanous1-0/+2
When the EventLog is pushed to the files, there is a case where we can't know the difference between a message with zero args, and a message with one arg, where the first arg is empty string. They both show up in the log similar to <DATE> OpenBMC.MessageId, This causes Redfish to return a LogEntry with one empty argument. This commit uses the registry information to resize the args array appropriately, dependent on what message is being sent, effectively ignoring what the developer put into their logs. If there's too many args, they're removed, if there's not enough args, empty args are added. Tested: GET /redfish/v1/Systems/system/LogServices/EventLog/Entries Returned an entry with the properties: "Message": "Power restore policy applied.", "MessageArgs": [], "MessageId": "OpenBMC.0.1.PowerRestorePolicyApplied", Which appear to be correct. Change-Id: I7d6f150bddad88d1c3da9d0424268d1eac902145 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-28Add support for redfish StopBootOnFaultAlbert Zhang1-0/+110
This commit is added get and set for StopBootOnFault Policy. The StopBootOnFault is defined in ComputerSystem(boot). It contains two values "Never" and "AnyFault". ref:https://redfish.dmtf.org/schemas/v1/ComputerSystem.v1_15_0.json Tested: 1.Validator passes 2.doGet method to get StopBootOnFault. curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system { "@odata.id": "/redfish/v1/Systems/system", "@odata.type": "#ComputerSystem.v1_16_0.ComputerSystem", ... "Boot": { ... "StopBootOnFault": "Never" }, ... } 3.doPatch method set the "StopBootOnFault" property to AnyFault or Never and report error when set to other values curl -k -H "X-Auth-Token: $token" -X PATCH -d '{ "Boot" :{"StopBootOnFault":"AnyFault"}}' https://${bmc}/redfish/v1/Systems/system A few seconds later, curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Systems/system { "@odata.id": "/redfish/v1/Systems/system", "@odata.type": "#ComputerSystem.v1_16_0.ComputerSystem", ... "Boot": { ... "StopBootOnFault": "AnyFault" }, ... } Signed-off-by: Albert Zhang <zhanghaodi@inspur.com> Change-Id: Ib2307deb413081edcbdecba9f234fe18571821a7 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2023-06-28Add efficiency percent for PowerSupplyGeorge Liu1-0/+85
This commit is to add EfficiencyRatings/EfficiencyPercent information according to the Redfish PowerSupply schema. In the PDI model, it is assumed that all power supplies have the same Efficiency Rating. This implementation uses the xyz.openbmc_project.Control.PowerSupplyAttributes interface for all power supplies, similar to power.hpp. ref: http://redfish.dmtf.org/schemas/v1/PowerSupply.v1_5_0.json Tested: Validator passes curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0 { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0", "@odata.type": "#PowerSupply.v1_5_0.PowerSupply", "EfficiencyRatings": [ { "EfficiencyPercent": 90 } ], "FirmwareVersion": "383239323732", "Id": "powersupply0", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS00F6-E0" } }, "Manufacturer": "", "Model": "51E9", "Name": "powersupply0", "PartNumber": "03KP466", "SerialNumber": "YL10KY26E073", "SparePartNumber": "03FP378", "Status": { "Health": "OK", "State": "Enabled" } } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ic782676f9efb8434f1076e726ff0656d1c27d310 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-28Refactor powerSupplyPath association retrievalLakshmi Yadlapati1-62/+68
Improved functionality for retrieving powered_by association endpoints with the "xyz.openbmc_project.Inventory.Item.PowerSupply" interface. This commit introduces an enhanced approach for obtaining the powered_by association endpoints that specifically have the "xyz.openbmc_project.Inventory.Item.PowerSupply" interface. The code now utilizes the getAssociatedSubTreePaths() function, ensuring that only endpoints representing power supplies are retrieved. This updated functionality provides a more accurate and efficient method for retrieving the relevant associations, filtering out any endpoints that do not correspond to power supplies. This approach is particularly beneficial in cases where the powered_by association may be used by entities other than power supplies. Refactor powerSupply list handling in powerSupply subsystem. Tested: Validator Passed ''' curl -k https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies", "@odata.type": "#PowerSupplyCollection.PowerSupplyCollection", "Description": "The collection of PowerSupply resource instances.", "Members": [ { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply2" }, { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/PowerSupplies/powersupply3" } ], "Members@odata.count": 2, "Name": "Power Supply Collection" } ''' Change-Id: Icb56621b578460e65380a633028269a7023c4674 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-28Rename all error_code instances to ecEd Tanous9-49/+48
We're not consistent here, which leads to people copying and pasting code all over, which has lead to a bunch of different names for error codes. This commit changes to coerce them all to "ec", because that's what boost uses for a naming convention. Tested: Rename only, code compiles. Change-Id: I7053cc738faa9f7a82f55fc46fc78618bdf702a5 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-28Make error codes take by referenceEd Tanous2-3/+3
Similar to may other refactors we've done, capture boost::system::error_code instances by const reference. Tested: Trivial change. Code compiles. Change-Id: I63b6c1e3e793621cf55aca03259c2e9ffddab853 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-28Refactor setProperty methodGeorge Liu13-561/+456
SetProperty is a method we should use more, and use consistently in the codebase, this commit makes it consistently used from the utility namespace. Tested: Refactor. Code compiles. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I5939317d23483e16bd98a8298f53e75604ef374d
2023-06-27Remove ServerSentEvents classEd Tanous2-293/+0
Now that SSE is in the core, this code is no longer used or required. Most of it now exists (in function) in http/server_sent_event.hpp. Remove the dead code. Tested: Code compiles Change-Id: I346d1cea566a46157a6667ca472e59b17dfa9b19 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-27Use getPCIeDeviceList in PCIeDeviceCollectionLakshmi Yadlapati1-3/+1
The current implementation of PCIeDeviceCollection uses getCollectionMembers to obtain the list of PCIe devices, but this method does not include empty PCIe slots. To address this limitation and to prepare for future changes that will include PCIe slot information, this commit updates PCIeDeviceCollection to use getPCIeDeviceList instead. While getPCIeDeviceList currently does the same as getCollectionMembers, moving forward it will be expanded to include PCIe slot information. Tested: Validator passed Change-Id: I3ef9fbfa45acd782e99d31136469993a64616710 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-27FindNavigationReferences rename p->jsonPtrEd Tanous1-12/+13
It was pointed out in a prior review that single character variable names were not very descriptive. Rename p to jsonPtr to be more descriptive. Tested: Pretty good unit test coverage here. Change-Id: I9583d52dd6cc7f5e6a8eabe42bbe8da9efa44ee0 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-27Make findNavigationReference* use referencesEd Tanous1-14/+14
Using pointers here would require to check for null in every handler, which is a bit wasteful. Use a reference instead. Tested: Unit tests pass. Pretty good coverage for this section of code. Change-Id: If47e893affb96eb848262cbbcd718f676191664a Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-27Split up findNavigationReferenceEd Tanous1-10/+38
findNavigationReference handles a couple different types. Split it up into the relevant types. Tested: Unit tests pass. Pretty good coverage for this section of code. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0c601a0779c23050b7803e4691334243485c8d29
2023-06-24sdbusplus: use shorter type aliasesPatrick Williams1-6/+5
The sdbusplus headers provide shortened aliases for many types. Switch to using them to provide better code clarity and shorter lines. Possible replacements are for: * bus_t * exception_t * manager_t * match_t * message_t * object_t * slot_t Change-Id: I7f26c74901de1de9268782fb3c0ebb3fc26ffcdd Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-06-23Remove usage of flat_map for enum lookupEd Tanous1-30/+50
This was a common pattern a few years ago that popped up quite a bit. It's not very efficient because it constructs the map every loop, and requires larger binaries than a simpler if/else lookup table. Transform into the existing pattern used elsewhere. Tested: WIP Change-Id: Iafaae412b34a6dcf3b47307b196cb2b26c4cb1a0 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-23error_messages: remove source_location indirectPatrick Williams2-5/+5
clang-16 now supports std::source_location so remove the indirection that uses experimental::source_location in some cases. Tested: Compiled with `CXX=clang++`. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Id55bdf01855206c6892684e1e56cc5ff56e2b5a2
2023-06-21Change the byte of the MemoryAttributes attribute to the size typeGeorge Liu1-3/+2
There is a patch [1] about changing the byte type of the MemoryAttributes attribute to size_t, so we need to update the relevant code in bmcweb synchronously. [1] https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/63799 Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I6fca731956750cdf8f749f963bbc12137fec7796
2023-06-21Redfish: Implement SNMP TrapChicago Duan2-3/+355
Implement SNMPTrap in EventDestination of Redfish. We can use this Redfish interface to add/get/delete the SNMPTrap port and destination address. When the error log is generated, phosphor-snmp will send SNMPTrap messages to our configured SNMPTrap destination. The MIB is here: [1] https://github.com/openbmc/phosphor-snmp/blob/master/mibs/NotificationMIB.txt Refer: [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0268_2019.3.pdf SNMPTrap test: Tested ok on the Witherspoon machine. Steps are as follows: 1. Use this Redfish interface to configure the port and destination address: curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://192.168.31.89:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c"}' 2. Run the SNMPTrap receiver tool in the destination computer(192.168.31.89),I used iReasoning MIB Browser as the SNMPTrap receiving tool. 3. Trigger error logs such as power supply AC Lost. We will see the error log under /xyz/openbmc_project/logging. 4. The SNMPTrap receiver tool in the destination computer received the SNMPTrap sent by OpenBMC. Tested: Validator passes 1. Add snmp client: curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://192.168.31.89:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c", "Context": "testContext"}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_0_0.Message", "Message": "The resource has been created successfully", "MessageArgs": [], "MessageId": "Base.1.8.1.Created", "MessageSeverity": "OK", "Resolution": "None" } ] } 2. Get snmp trap client configurations: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/snmp1 { "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp1", "@odata.type": "#EventDestination.v1_7_0.EventDestination", "Context": "testContext", "Destination": "snmp://192.168.31.89:162", "EventFormatType": "Event", "Id": "snmp1", "Name": "Event Destination snmp1", "Protocol": "SNMPv2c", "SubscriptionType": "SNMPTrap" } Reboot the BMC, and get the snmp trap client again: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/snmp1 { "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp1", "@odata.type": "#EventDestination.v1_7_0.EventDestination", "Context": "testContext", "Destination": "snmp://192.168.31.89:162", "EventFormatType": "Event", "Id": "snmp1", "Name": "Event Destination snmp1", "Protocol": "SNMPv2c", "SubscriptionType": "SNMPTrap" } 3. Delete snmp client: curl -k -H "X-Auth-Token: $token" -X DELETE https://${bmc}/redfish/v1/EventService/Subscriptions/snmp1 { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "Successfully Completed Request", "MessageArgs": [], "MessageId": "Base.1.8.1.Success", "MessageSeverity": "OK", "Resolution": "None" } ] } 4. After we have added some SNMP clients using Redfish, we can see them in Dbus: busctl tree xyz.openbmc_project.Network.SNMP `-/xyz `-/xyz/openbmc_project `-/xyz/openbmc_project/network `-/xyz/openbmc_project/network/snmp `-/xyz/openbmc_project/network/snmp/manager |-/xyz/openbmc_project/network/snmp/manager/1 busctl introspect xyz.openbmc_project.Network.SNMP /xyz/openbmc_project/network/snmp/manager/1 xyz.openbmc_project.Network.Client NAME TYPE SIGNATURE RESULT/VALUE FLAGS .Address property s "192.168.31.89" emits-change writable .Port property q 162 emits-change writable 5. Use "busctl call" add client busctl call xyz.openbmc_project.Network.SNMP /xyz/openbmc_project/network/snmp/manager xyz.openbmc_project.Network.Client.Create Client sq 192.168.31.90 162 s "/xyz/openbmc_project/network/snmp/manager/2" We will see it use the redfish url: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/snmp2 { "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp2", "@odata.type": "#EventDestination.v1_7_0.EventDestination", "Context": "", "Destination": "snmp://192.168.31.90:162", "EventFormatType": "Event", "Id": "snmp2", "Name": "Event Destination snmp2", "Protocol": "SNMPv2c", "SubscriptionType": "SNMPTrap" } 6. Deleting snmp client using "busctl" First, we use redfish to add some SNMP clients: curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://192.168.31.90:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c", "Context": "testContext0"}' curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "snmp://192.168.31.91:162", "SubscriptionType": "SNMPTrap", "Protocol": "SNMPv2c", "Context": "testContext1"}' Then we can use redfish to get the subscriptions: curl -k -H "X-Auth-Token: $token" -XGET https://${bmc}/redfish/v1/EventService/Subscriptions { "@odata.id": "/redfish/v1/EventService/Subscriptions", "@odata.type":"#EventDestinationCollection.EventDestinationCollection", "Members": [ { "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp1" }, { "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp2" } ], "Members@odata.count": 2, "Name": "Event Destination Collections" } Now we use busctl to delete SNMP client 2: busctl call xyz.openbmc_project.Network.SNMP /xyz/openbmc_project/network/snmp/manager/2 xyz.openbmc_project.Object.Delete Delete Then we won't see snmp2 in the subscriptions of redfish: curl -k -H "X-Auth-Token: $token" -XGET https://${bmc}/redfish/v1/EventService/Subscriptions { "@odata.id": "/redfish/v1/EventService/Subscriptions", "@odata.type":"#EventDestinationCollection.EventDestinationCollection", "Members": [ { "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp1" } ], "Members@odata.count": 1, "Name": "Event Destination Collections" } 7. Test the generic event subscription to make sure it didn't impacted Add Redfish subscription: curl -k -H "X-Auth-Token: $token" -X POST https://${bmc}/redfish/v1/EventService/Subscriptions -d '{"Destination": "https://192.168.31.189:443", "SubscriptionType": "RedfishEvent", "Protocol": "Redfish", "Context": "testContext"}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The resource has been created successfully.", "MessageArgs": [], "MessageId": "Base.1.13.0.Created", "MessageSeverity": "OK", "Resolution": "None." } ] Get Redfish subscription: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/EventService/Subscriptions/1358109191 { "@odata.id": "/redfish/v1/EventService/Subscriptions/1358109191", "@odata.type": "#EventDestination.v1_8_0.EventDestination", "Context": "testContext", "DeliveryRetryPolicy": "TerminateAfterRetries", "Destination": "https://192.168.31.189:443", "EventFormatType": "Event", "HttpHeaders": [], "Id": "1358109191", "MessageIds": [], "MetricReportDefinitions": [], "Name": "Event Destination 1358109191", "Protocol": "Redfish", "RegistryPrefixes": [], "ResourceTypes": [], "SubscriptionType": "RedfishEvent" } Signed-off-by: Chicago Duan <duanzhijia01@inspur.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie589b3934ee749c7e0add35e3ed1b0b7e817c557
2023-06-21Move all ComputerSystem routes to bottomEd Tanous2-62/+32
Similar to what we've done elsewhere, consolidate all the BMCWEB_ROUTE calls on the bottom of the file. This is a consolidation such that you no longer have to hunt for all the entry points into these handlers. Tested: Code compiles Change-Id: I9f2a2c6772445048e9ade2bf9e95330d73bedb05 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-21Break out ComputerSystem methodsEd Tanous1-496/+504
Similar to what we're doing elsewhere, break down the computer system schemas into appropriate methods. Tested: Redfish service validator passes. Change-Id: I295bfe6ad9df8e8b23477d8ec6b49595d2771c66 Signed-off-by: Ed Tanous <edtanous@google.com>
2023-06-21Add an option flag for multi-computersystemEd Tanous9-47/+443
A number of discussions have occurred, and it's clear that multi-computer system is not a transition that can be done in a single series of commits, and needs to be done incrementally over time. This commit adds the initial option for multi-computer system support, with an option flag that can be enabled when the new behavior is desired. This is to prevent needing a long-lived fork. This option operatates such that if enabled, all ComputerSystem route options will now return 404. This is to allow the redfish service validator to pass, and to be used for incremental development. As the routes are moved over, they will be enabled, and service validator re-run. Per the description in the meson options, this option flag, and all code beneath of it will be removed on 9/1/23. The expectation is that by this date, given the appropriate level of effort in implementation, there will be no code remaining under that option flag. After this date, code beneath this option flag will be removed. Tested: No functional changes without option. With option enabled, /redfish/v1/Systems produces no entries. Spot check of various routes returns 404. Redfish service validator passes. Change-Id: I3b58642cb76d61df668076c2e0f1e7bed110ae25 Signed-off-by: Ed Tanous <ed@tanous.net>
2023-06-21json utils: add getEstimatedJsonSizeNan Zhou2-0/+63
Add a utility function which estimates the size of the JSON tree. It is used in the children change to limit the reponse size of expand query. Tested: 1. unit test passed; 2. tested on hardware, the following are real sizes and estimation ``` Real payload size, Estimation, query 15.69 KB, 10.21 KB, redfish/v1?$expand=.($levels=1) 95.76 KB, 62.11 KB, redfish/v1?$expand=.($levels=2) 117.14 KB, 72.71 KB, redfish/v1?$expand=.($levels=3) 127.65 KB, 77.64 KB, redfish/v1?$expand=.($levels=4) ``` Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Iae26d6732a6ec63ecc59eacf657b4bf33c07c046
2023-06-21Populate Memory attributesJayaprakash Mutyala1-4/+4
Change MemoryMedia, Slot and Socket memory attributes to be byte, in line with Phosphor-dbus-interfaces. Tested: 1. Redfish validator - passed for this new change 2. Populated MiemoryMedia, Slot and Socket values as expected. GET https://<BMC_IP>/redfish/v1/Systems/system/Memory/dimm0 Signed-off-by: poram srinivasa rao <poramx.srinivasa.rao@intel.com> Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib4894aca135af79d01ff0fda0ae8f3f1d03ea278
2023-06-21Fix Redfish validator failure in PCIeFunctionLakshmi Yadlapati1-1/+1
This commit addresses the Redfish validator failure related to the URI mismatch in PCIeFunction. The error reported that the URI "/redfish/v1/Systems/system/PCIeDevices/pcie_card1/PCIeFunctions/" does not match the required URI in the PCIeFunction schema. Commit that introduced the Redfish validator failure: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/63853 Tested: validator passed Change-Id: Ie96b7461ad64f9b1c6392e4905276a4fe7799781 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-20Use fillMessageArgs in log servicesEd Tanous1-48/+23
There's two instances of log service that the method from fillMessageArgs was copy/pasted to. This commit moves them to using the common, unit tested function. Tested: - Verified the GET on Event logs and works as expected. curl -k -u $USER:$PASSWORD --noproxy "*" https://${BMCIP}/redfish/v1/Systems/system/LogServices/EventLog/Entries -X GET - Verified the PostCode fetching and works as expected. curl -k -u $USER:$PASSWORD --noproxy "*" https://${BMCIP}/redfish/v1/Systems/system/LogServices/PostCodes/Entries -X GET Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I24eb13b83eff41e7dfd98ea9ecc160d578d2faa6
2023-06-20Refactor getManagedObjects methodGeorge Liu10-109/+103
Since the getManagedObjects method has been implemented in dbus_utility and this commit is to integrate all the places where the GetManagedObjects method is obtained, and use the method in dbus_utility uniformly. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ic13f2bef7b30f805cd3444a75d7df17b031f2eb0
2023-06-16Add Health information for PCIeDeviceLakshmi Yadlapati1-0/+29
This commit is to add Health information according to the Redfish PCIeDevice schema. ref: https://redfish.dmtf.org/schemas/v1/PCIeDevice.v1_9_0.json Code that updates the OperationalStatus for all the inventory https://github.com/openbmc/openpower-vpd-parser/blob/ \ 3fb026386546cfd288ab4f86156c9aa0ffa145d6/ibm_vpd_app.cpp#L620 Tested: Validator passed ''' curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card8 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card8", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", "Id": "pcie_card8", "Manufacturer": "", "Model": "6B87", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card8/PCIeFunctions" }, "PCIeInterface": { "LanesInUse": -1 }, "PartNumber": "03FL194", "SerialNumber": "Y131UF09S00J", "Slot": { "Location": { "PartLocation": { "ServiceLabel": "U78DB.ND0.WZS0018-P0-C8" } } }, "SparePartNumber": "03FL195", "Status": { "Health": "OK", "State": "Enabled" } } ''' Change-Id: I53026792d0c223c10065c58aef9f3b9dc04a24ed Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-16Move PCIe functions to common fileLakshmi Yadlapati3-99/+103
Move redfishPcieGenerationFromDbus, called from both pcie.hpp and pcie_slots.hpp, and busSlotTypeToRf functions, called from pcie_slots.hpp, to a common PCIe utility file. In the future commit, when integrating PCIeSlot with PCIeDevice, we will call the busSlotTypeToRf function from pcie.hpp, so having it in the common utility file will make it readily available. Tested: build successful, no additional testing needed. Change-Id: I6286bd5547ddafa6eac4f224ac56f6d790a44c7a Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-16Add ServiceLabel information for PowerSupplyGeorge Liu1-0/+26
This commit is to add Location/PartLocation/ServiceLabel information according to the Redfish PowerSupply schema. If the `xyz.openbmc_project.Inventory.Decorator.LocationCode` interface does not exist, the ServiceLabel information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/PowerSupply.v1_5_0.json Tested: Validator passes curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0 { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0", "@odata.type": "#PowerSupply.v1_5_0.PowerSupply", "FirmwareVersion": "383239323732", "Id": "powersupply0", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS00F6-E0" } }, "Manufacturer": "", "Model": "51E9", "Name": "powersupply0", "PartNumber": "03KP466", "SerialNumber": "YL10KY26E073", "SparePartNumber": "03FP378", "Status": { "Health": "OK" } } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Icd0c21719bb01f481a8cd4c56bdb1a9ee047b047
2023-06-15Fix regression in @odata failure pathsEd Tanous2-2/+17
5b224921d765a93c5f93a6012109a9a748ef7cd4 and a1e0871d2425b3f42d0e5893d548593e5ed576b Added code to handle links looked correct in review, but the deduplication of the HEAD methods now causes the return code of setUpRedfishRoute to be ignored. This means that query parameter or other header failures don't stop the request, which is bad. Tested: GET /redfish/v1 (ie ServiceRoot) returns the correct header. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iec01051221550747a7b99da5eb7713e18394d530
2023-06-15Add FirmwareVersion For PowerSupplyGeorge Liu1-0/+25
This commit is to add firmware version information according to the Redfish PowerSupply schema. If the `xyz.openbmc_project.Software.Version` interface does not exist, the firmware version information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/PowerSupply.v1_5_0.json Tested: Validator passes curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0 { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0", "@odata.type": "#PowerSupply.v1_5_0.PowerSupply", "FirmwareVersion": "383239323732", "Id": "powersupply0", "Manufacturer": "", "Model": "51E9", "Name": "powersupply0", "PartNumber": "03KP466", "SerialNumber": "YL10KY26E073", "SparePartNumber": "03FP378", "Status": { "Health": "OK" } } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I3ced467faf49d08c46a8b9bb2aa722f35353c811
2023-06-14Add asset information for PowerSupplyGeorge Liu1-0/+69
This commit is to add asset information according to the Redfish PowerSupply schema. If the `xyz.openbmc_project.Inventory.Decorator.Asset` interface does not exist, the asset information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/PowerSupply.v1_5_0.json Tested: Validator passes curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0 { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0", "@odata.type": "#PowerSupply.v1_5_0.PowerSupply", "Id": "powersupply0", "Manufacturer": "", "Model": "51E9", "Name": "powersupply0", "PartNumber": "03KP466", "SerialNumber": "YL10KY26E073", "SparePartNumber": "03FP378", "Status": { "Health": "OK" } } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I83f1a9375f83e3470089cb2b5207db9665cc69df
2023-06-13Make redfish::messages rely on typesafe structuresEd Tanous2-40/+66
The previous patches modified these fields one at a time, for the cases where we had code calling these in odd ways. This commit goes and effects the same change on the rest of the message handlers where it makes sense. Any input to a message function that mentions a "value" replaces the value with a nlohmann::json object, to make calling this code easier. The one exception is StringValueTooLong, which by definition, requires the input value to be a string, so that is left as string_view intentionally. Tested: Dead unused code. Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I00b9804b2aadf5584032be91a0ee53b9a94a7430
2023-06-13Make propertyValueIncorrect typesafeEd Tanous3-8/+9
Similar to the previous patches, make propertyValueIncorrect accept a nlohmann::json object as input. This removes the need for the dump() call, which oddly enough, in our one usage, was actually incorrect, and could cause bmcweb to throw an exception in parsing in theory. Tested: Only used in one error condition. Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie35d61101c2db88b16d42d71e66bceef540e8429
2023-06-13Make propertyValueFormatError more typesafeEd Tanous6-40/+23
Similar to other patches, make propertyValueFormatError accept a nlohmann::json object, which removes a lot of the unsafe dump code that we have littered about. Tested: No easy to replicate error. Code is identical to previous patchsets. Inspection and code compilation only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic9d0f196b6e198073189f744b738db7ffa2f1b74
2023-06-13Make propertyValueTypeError more typesafeEd Tanous6-46/+21
Similar to the prior patchset in this series, propertyValueTypeError can be moved to safer constructs. This ensures that we are minimizing how many places we are calling dump() from, and allows us to reduce the amount of code written for error handling. Tested: PATCH /redfish/v1/SessionService {"SessionTimeout": "foo"} Returns PropertyValueTypeError in the same behavior as prior to this patch. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iddff4b787f35c49bf923663d61bba156687f358c
2023-06-13Make propertyValueNotInList typesafeEd Tanous7-22/+19
The error codes for this function accept a string_view, which has caused a number of cases of users of this function to call dump() to_string() and all manner of other conversions. Considering that dump() is something that's difficult to call correctly, and overly wordy, it would be ideal if the message code just handled that for us. Therefore, this commit changes the prototype to include a nlohmann::json object as an argument instead of string_view, then audits the codebase for all uses, and moves them to a more normalized usage, which allows the calling code to call "dump" for them. Tested: PATCH /redfish/v1/SessionService {"SessionTimeout": 1} Returns the PropertyValueNotInList error as it did before. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If62909072db1f067ad1f8aa590bb716c84181219
2023-06-13Move registry code out of event service managerEd Tanous2-25/+29
This code was added into the registries namespace, from event service manager. It is operating on registries, it belongs in the registry header. Tested: Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I89e830dde185178b1d2e52b18a1a0a2baa4e0fb3
2023-06-13Add Status information for Power SupplyGeorge Liu1-8/+83
This commit is to add PowerSupply State/Health status according to the Redfish PowerSupply schema. If the `xyz.openbmc_project.Inventory.Item` interface does not exist, the state status property is set to default "Present". If the `xyz.openbmc_project.State.Decorator.OperationalStatus` interface does not exist, the health status property is set to default "OK". ref: http://redfish.dmtf.org/schemas/v1/PowerSupply.v1_5_0.json Code that updates the OperationalStatus for all the inventory https://github.com/openbmc/openpower-vpd-parser/blob/ \ 3fb026386546cfd288ab4f86156c9aa0ffa145d6/ibm_vpd_app.cpp#L620 Tested: Validator passes curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0 { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/ PowerSupplies/powersupply0", "@odata.type": "#PowerSupply.v1_5_0.PowerSupply", "Id": "powersupply0", "Name": "powersupply0", "Status": { "Health": "OK" "State": "Enabled" } } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I121b665a4e605024644cc7c9392f88a71703481e Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
2023-06-13chassis: Pass ec by referenceWilly Tu1-1/+1
Remove passing ec by value for getProperty. Change-Id: I9070ca7035fead14faa236eb1b17937ffe13045b Signed-off-by: Willy Tu <wltu@google.com>
2023-06-13Add content type check in the update serviceNinad Palsule1-15/+31
The content type check is required in the update service. This may be a security issue. The correct content types to update service are multipart/form-data and application/octet-stream. The multipart content type was missing from the contentTypes array which is added in this drop. Added couple of test cases. Tested: 1) Make sure that update service content type application/octet-stream are working correctly. $ curl -k -H 'X-Auth-Token: THIbp1G0DiNVj3JrCZMf' -H 'Content-Type: \ application/octet-stream' -X POST \ -T ./obmc-phosphor-image-everest.ext4.mmc.tar \ https://${bmc}/redfish/v1/UpdateService/update { "@odata.id": "/redfish/v1/TaskService/Tasks/0", "@odata.type": "#Task.v1_4_3.Task", "Id": "0", "TaskState": "Running", "TaskStatus": "OK" 2) Make sure that update service content type multipart/form-data are working correctly. $ curl -k -H 'X-Auth-Token: Vc7KBgM6z3uMs1G7uVqu' \ -H Content-Type:multipart/form-data \ -F 'UpdateParameters={"Targets":["/redfish/v1/Managers/bmc"], \ "@Redfish.OperationApplyTime":"Immediate"};type=application/json'\ -F 'UpdateFile=@obmc-phosphor-image-p10bmc.ext4.mmc.tar; \ type=application/octet-stream' \ https://${bmc}/redfish/v1/UpdateService/update { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request completed successfully.", "MessageArgs": [], "MessageId": "Base.1.16.0.Success", "MessageSeverity": "OK", "Resolution": "None" } ], "@odata.id": "/redfish/v1/TaskService/Tasks/0", "@odata.type": "#Task.v1_4_3.Task", "Id": "0", "TaskState": "Running", "TaskStatus": "OK" 3) Make sure that command fails when content type is missing. $ curl -k -H 'X-Auth-Token: vH3B88sh323sfy0YG8eN' -H Content-Type: \ -X POST -T ./obmc-phosphor-image-everest.ext4.mmc.tar \ https://${bmc}/redfish/v1/UpdateService/update Bad Request [INFO "http_connection.hpp":201] Request: 0x177f920 HTTP/1.1 POST \ /redfish/v1/UpdateService/update ::ffff:x.x.xx.xxx | [DEBUG "update_service.hpp":687] doPost: contentType= [DEBUG "update_service.hpp":692] Bad content type specified: 4) Make sure that command fails when wrong cotent type specified. $ curl -k -H 'X-Auth-Token: OQzODMaR0G29AjpD2YmT' -H 'Content-Type: \ application/octet-json' -X POST \ -T ./obmc-phosphor-image-everest.ext4.mmc.tar \ https://${bmc}/redfish/v1/UpdateService/update Bad Request [INFO "http_connection.hpp":201] Request: 0x17a69d0 HTTP/1.1 POST \ /redfish/v1/UpdateService/update ::ffff:x.x.xx.xxx | [DEBUG "update_service.hpp":687] doPost: contentType=application/octet-json [DEBUG "update_service.hpp":720] Bad content type specified: application/octet-json 5) Make sure that command fails when header is not specified. $ curl -k -H 'X-Auth-Token: Z1AEXg075qGKi0xISu6o' -X POST \ -T ./obmc-phosphor-image-everest.ext4.mmc.tar \ https://${bmc}/redfish/v1/UpdateService/update Bad Request [INFO "http_connection.hpp":201] Request: 0x17a69d0 HTTP/1.1 \ POST /redfish/v1/UpdateService/update ::ffff:x.x.xx.xxx | [DEBUG "update_service.hpp":687] doPost: contentType= [DEBUG "update_service.hpp":692] Bad content type specified: Change-Id: I48b709b6219debfed9ff60dd46ab87652e5a1fe5 Signed-off-by: Ninad Palsule <ninad@linux.ibm.com>