summaryrefslogtreecommitdiff
path: root/redfish-core
AgeCommit message (Collapse)AuthorFilesLines
2022-12-28Fix some use-after-move issuesEd Tanous1-79/+77
This diff looks bad. The only thing that changed functionally is changing: password(std::move(password)), roleId(std::move(roleId)) in the labmda capture to password, roldId because password and roleid are getting used later. Unfortunately, clang decides to rearrange this whole lambda. Tested: Passes cppcheck. ''' curl -vvvv --insecure --user root:0penBmc -X PATCH -d '{"Password": "0penBmc1"}' https://192.168.7.2/redfish/v1/AccountService/Accounts/root ''' Succeeds at patching the root password. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I97b10a40d0b271b211bf4e6c09888d3cd568a3d0
2022-12-22Use owning strings for aggregator URIEd Tanous1-2/+2
Clang correctly notes that, because the segments() object is an rvalue, and is destroyed after the std::string_view is used on the next line, this is technically undefined behavior. Make these use owning std::strings instead of std::string_view to avoid the lifetime problem. Tested: Enabled aggregation without including a satellite config. Sending a GET request to /redfish/v1/Chassis/5B247A_Test returned a 404 due to hitting one of the sections of changed code. The other section is not currently reachable, but uses the same type of change. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1b2b2ad444e2718c0cb167f4506ea1d0915b3a5b Signed-off-by: Carson Labrado <clabrado@google.com>
2022-12-22Fix cppcheck errorEd Tanous1-29/+15
cppcheck comments that this can be const. Unfortunately, this looks like a false positive, where cppcheck cannot see through the std::replace template. Tested: This is in the set pid loop handler that doesn't have any good tests with it. Code compiles, and only inspection is possible at this time. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I21eaadcc37b2f3993e63b39d471cbf118d88119a
2022-12-22Avoid copyEd Tanous1-1/+1
cppcheck warns that this is a copy, so fix it. Tested: cppcheck no longer warns on this line. Unfortunately, virtual media does not have a backend, so this is dead code. No way to test at this point. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1e98ca63ee346ad683844e5637a173f64286102a
2022-12-21Change variable scopesEd Tanous6-13/+12
cppcheck correctly notes that a lot of our variables can be declared at more specific scopes, and in every case, it seems to be correct. Tested: Redfish service validator passes. Unit test coverage on others. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416
2022-12-16Correct the dhcp object pathJian Zhang1-3/+2
Due to the path of the dhcp has been changed from `/xyz/openbmc_project/network/config/dhcp` to `/xyz/openbmc_project/network/dhcp`. Cause cannot get/set the dhcp configuration. See: https: //gerrit.openbmc.org/c/openbmc/phosphor-networkd/+/58725 Tested: ``` Without internal error. ~# curl -k -X PATCH -H "X-Auth-Token: $token" https://$bmc/redfish/v1/Managers/bmc/EthernetInterfaces/eth1 \ --data-raw '{"DHCPv4":{"DHCPEnabled":false}}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request completed successfully.", "MessageArgs": [], "MessageId": "Base.1.13.0.Success", "MessageSeverity": "OK", "Resolution": "None" } ] } ``` Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com> Change-Id: Ib455cbe69c47b3075321a8225a5a69bff136dbe8
2022-12-15Prepare for boost::url upgradeEd Tanous9-76/+51
The new boost URL now interops properly with std::string_view, which is great, and cleans up a bunch of mediocre code to convert one to another. It has also been pulled into boost-proper, so we no longer need a boost-url dependency that's separate. Unfortunately, boost url makes these improvements by changing boost::string_view for boost::urls::const_string, which causes us to have some compile errors on the missing type. The bulk of these changes fall into a couple categories, and have to be executed in one commit. string() is replaced with buffer() on the url and url_view types boost::string_view is replaced by std::string_view for many times, in many cases removing a temporary that we had in the code previously. Tested: Code compiles with boost 1.81.0 beta. Redfish service validator passes. Pretty good unit test coverage for URL-specific use cases. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8d3dc89b53d1cc390887fe53605d4867f75f76fd
2022-12-13Fix for incorrect Task Progress and State valuesGayathri Leburu1-13/+10
While performing the firmware updates, task will be created for tracking the background update progress and state. There are error associated with that code currently. Errors on TaskId's: - Internal errors "Messages": [ .... { "@odata.type": "#Message.v1_1_1.Message", "Message": "The request failed due to an internal service error. The service is still operational.", .... } ] - Always task is in RUNNING state. "PercentComplete": 0, "TaskState": "Running", Issue details: - Percentage: The "Progress" property in D-Bus interface "xyz.openbmc_project.Software.ActivationProgress" is of type "uint8_t" but bmcweb is reading type as string and that is leading to failure and invalid values. - TaskState: TaskState is read from d-bus after recieving associated signal but that is not updated properly and that caused the failure. this commit corrects the same. Tested: After fix, task which is created for firmware update is showing correct "PercentageComplete" and 'TaskState". "PercentComplete": 100, "TaskState": "Completed", Signed-off-by: Gayathri Leburu <gayathri.leburu@intel.com> Signed-off-by: moni kumar <monix.kumar@intel.com> Signed-off-by: AppaRao Puli <apparao.puli@intel.com> Change-Id: I0354cdecc9d9ddd47b017591402fd7b3149d12ca
2022-12-12Fix python packaging problemEd Tanous1-2/+2
Python packaging seems to have changed to be much more stringent about what version strings is accepts. It's not clear why this was done, but we need a fix to unbreak CI. This commit adds more parsing code into the script to parse out version numbers from the form of LogEntry.v1_2_3 to split them up into a custom class, and sort manually. Despite dropping the dependency, this ends up dropping a net 7 lines of code compared to using the library, so it seems worth it, especially given the breaking API change. One seemingly unrelated change was that we were adding schema folders to the sort lists, which don't sort well because they have no version numbers or extensions. This fixes to only add individual files to the list of things to sort. Tested: Code no longer crashes. Running update_schemas.py generates the same result (with one minor same-prefix sort order change). Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1a792ffb4ad7bc71637ab1aa0648a245949aeeee
2022-12-09Make inventory get inventory pathsEd Tanous1-1/+1
A recent regression causes failures on Thermal and Power paths that have to grab inventory items. This commit changes to search for the right path. Tested: Gunnar tested on a Witherspoon. No longer see Internal Errors. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0f7468ecf948f3cbfecb20c9ad470dced370ad3a Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2022-12-09Add Accuracy property to sensorsGeorge Liu1-0/+2
Base on Sensor.v1_2_0.json[1], add the Accuracy property to sensors. At present, the D-Bus interface[2] has been exposed in the phosphor-hwmon repo[3], and this function will be synchronized to the dbus-sensor repo in the future. [1]http://redfish.dmtf.org/schemas/v1/Sensor.v1_2_0.json [2]https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/53569 [3]https://gerrit.openbmc.org/c/openbmc/phosphor-hwmon/+/57839 Tested: built bmcweb successfully and validator passes get Accuracy: curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/ Chassis/chassis/Sensors/temperature_inlet { "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/temperature_inlet", "@odata.type": "#Sensor.v1_2_0.Sensor", "Accuracy": 5.0, "Id": "Sensors_inlet", "Name": "inlet", ... } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ie51356d810f63ba70c56ce702d6bbeb97e279530
2022-12-09Remove ObjectManager search code in sensorsEd Tanous1-152/+34
Per [1], daemons implementing sensors are supposed to implement an ObjectManager at /xyz/openbmc_project/sensors. Once this is made consistent, there is no need for this complex code to search for an ObjectManager instance, when we can simply look it up. This commit deletes the ObjectManager search code, which saves a Dbus call for any sensor read done within thermal or sensor schemas. This does have the negative of requiring that ObjectMapper implements its ObjectManager on "/". Considering there is only one implementation of ObjectMapper, this seems reasonable to hardcode. Tested: Redfish Service Validator passes. ''' curl --insecure --user root:0penBmc https://192.168.10.156/redfish/v1/Chassis/Tyan_S7106_Baseboard/Thermal ''' returns the sensors on an S7106 platform. [1] https://github.com/openbmc/phosphor-dbus-interfaces/blob/991b2b8bdbc950f2a85aebfc29d1b34ea3264686/yaml/xyz/openbmc_project/Sensor/Value.interface.yaml#L18 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I69071848c685c33320d920d9faec16e5a1b563ca
2022-12-08Generate Redfish enums from schemasEd Tanous51-42/+3995
OpenBMC tends to have a significant problem in doing the appropriate lookups from the schema files, and many bugs have been injected by users picking a bad enum, or mistyping the casing of an enum value. At the same time, nlohmann::json has recently added first class support for enums, https://json.nlohmann.me/features/enum_conversion/ This commit attempts to build a set of redfish includes file with all the available Redfish enums in an easy to use enum class. This makes it very clear which enums are supported by the schemas we produce, and adds very little to no extra boilerplate on the human-written code we produced previously. Note, in the generated enum class, because of our use of the clang-tidy check for macros, the clang-tidy check needs an exception for these macros that don't technically follow the coding standard. This seems like a reasonable compromise, and in this case, given that nlohmann doesn't support a non-macro version of this. One question that arises is what this does to the binary size.... Under the current compiler optimizations, and with the current best practices, it leads to an overall increase in binary size of ~1200 bytes for the enum machinery, then approximately 200 bytes for every call site we switch over. We should decide if this nominal increase is reasonable. Tested: Redfish protocol validator runs with same number of failures as previously. Redfish Service Validator passes (one unrelated qemu-specific exception) Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7c7ee4db0823f7c57ecaa59620b280b53a46e2c1
2022-12-08Aggregation: Detect and fix all URI propertiesCarson Labrado1-32/+37
There are a number of properties of Type "string (uri)" for which we do not currently support adding prefixes. This patch adds support for all existing URI properties which are missed by the existing implementation. This change will be needed by future patches which will expand aggregation support to all top level collections defined by the schema. Those collections that are not currently supported include properties whose URIs should be fixed, but would be missed by the existing implementation. Tested: New unit test passes. URI properties are still handled correctly. ```shell curl localhost/redfish/v1/Chassis/5B247A_<chassisID> { "@odata.id": "/redfish/v1/Chassis/5B247A_<chassisID>", "@odata.type": "#Chassis.v1_16_0.Chassis", "Actions": { "#Chassis.Reset": { "@Redfish.ActionInfo": "/redfish/v1/Chassis/5B247A_<chassisID>/ResetActionInfo", "target": "/redfish/v1/Chassis/5B247A_<chassisID>/Actions/Chassis.Reset" } }, ... } ``` Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I3b3e06ee3191564d266598f7bc9f1641e6fcb333
2022-12-07log_service: Fix behavior of getting single PostCode entryJiaqing Zhao1-78/+82
Currently getting single PostCode entry returns a LogEntryCollection with the specified LogEntry in its Members. Since Redfish Service Validator does not follow the links in LogServiceCollection[1], such unexpected behavior passes the validator. This commit makes it return the LogEntry itself (or 404 Not Found) when requesting it. Fixes Github issue #236 (https://github.com/openbmc/bmcweb/issues/236) [1] https://github.com/DMTF/Redfish-Service-Validator/issues/519 Tested: * Confirmed getting a valid PostCode entry now returns a LogEntry, and getting invalid entries like B0-1, B1-0, B1-999 or 123 (Not properly- formatted ID) responds with 404 Not Found. * Get PostCode log entries collection still returns LogEntryCollection containing first 1000 PostCode entries by default. * Redfish Service Validator passed. Change-Id: Ice6b8742caea96ad3d436d57898202fe7362b150 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-12-07Implement If-Match header in Http layerEd Tanous1-0/+74
If-Match is a header in the HTTP specification[1] designed for handling atomic operations within a given HTTP tree. It allows a mechanism for an implementation to explicitly declare "only take this action if the resource has not been changed". While most things within the Redfish tree don't require this level of interlocking, it continues to round out our redfish support for the specific use cases that might require it. Redfish specification 6.5 states: If a service supports the return of the ETag header on a resource, the service may respond with HTTP 428 status code if the If-Match or If-None-Match header is missing from the PUT or PATCH request for the same resource, as specified in RFC6585 This commit implements that behavior for all handlers to follow the following flow. If If-Match is present Repeat the same request as a GET Compare the ETag produced by the GET, to the one provided by If-Match If they don't match, return 428 if they do match, re-run the query. [1] https://www.rfc-editor.org/rfc/rfc2616#section-14.24 As a consequence, this requires declaring copy and move constructors onto the Request object, so the request object can have its lifetime extended through a request, which is very uncommon. Tested: Tests run on /redfish/v1/AccountService/Accounts/root PATCH with correct If-Match returns 200 success PATCH with an incorrect If-Match returns 419 precondition required GET returns the resource as expected Redfish service validator passes Redfish protocol validator passes! ! ! ! ! Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I530ab255259c32fe4402eb8e5104bd091925c77b
2022-12-05Prevent unconditionally writing over the LinkStatusJohnathan Mantey1-2/+1
The NIC LinkStatus was being assigned a LinkUp or NoLink value depending on whether the NIC is enabled. Subsequent code unconditionally overwrites the LinkStatus. The LinkStatus needs to take into account the NIC enabled state as well as the link up/down state. Tested: Confirmed NIC enabled/link active resulted in LinkUp. Confrimed NIC enabled/no-carrier resulted in LinkDown. Connfimred NIC disable resulted in NoLink. Change-Id: Iece3686cac9714e427b0e100f486a4ced334f7af Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2022-12-01Fix NTPServers property in RedfishEd Tanous1-2/+2
Recent changes to phosphor-network have changed the NTPServers property to be actually StaticNTPServers. This makes PATCH incorrect. Tested: Redfish-protocol-validator passes the NTPServers property again. ``` curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Managers/bmc/NetworkProtocol -X PATCH -d '{"NTP": {"NTPServers": ["time-a-b.nist.gov", "time-b-b.nist.gov"]}}' ``` Now succeeds. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie4bcfa6190797dd250421d1a512677841a4319e4
2022-11-29Add the GetSubTree and GetSubTreePaths method to dbus_utilityGeorge Liu1-18/+16
There are currently many files that use the GetSubTree and GetSubTreePaths methods. Since they are a general method, they are defined in the dbus_utility.hpp file and will be further refactored in subsequent patches. Also, Updated the doPath method of NetworkProtocol synchronously. Tested: Built bmcweb successfully and Validator passes 1. doGet NetworkProtocol curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol { "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol", "IPMI": { "Port": 623, "ProtocolEnabled": true }, ... } 2. change the ProtocolEnabled property to false curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PATCH -d '{"IPMI": {"ProtocolEnabled" :false}}' https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol 3. doGet NetworkProtocol again curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Managers/bmc/NetworkProtocol { "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol", "IPMI": { "Port": null, "ProtocolEnabled": false }, ... } Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I9ed3de74417d2662a7f433ea4a589f68f514a369
2022-11-29managers: fix interface patch and delete of pid objectPotin Lai1-3/+13
Only set createNewObject to true when corresponding interface not found in the object. Tested on Bletchley: - Add new StepwiseController called SWTest Body in JSON format ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "SWTest": { "Direction": "Floor", "Inputs": [ "MB_U402_THERM_LOCAL" ], "NegativeHysteresis": 1.0, "PositiveHysteresis": 2.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 15.0, "Target": 49.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } } } } } } ``` Checking object from dbus ``` root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \ > /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \ > xyz.openbmc_project.Configuration.Stepwise NAME TYPE SIGNATURE RESULT/VALUE FLAGS .Delete method - - - .Class property s "Floor" emits-change writable .Inputs property as 1 "MB U402 THERM LOCAL" emits-change writable .Name property s "SWTest" emits-change writable .NegativeHysteresis property d 1 emits-change writable .Output property ad 2 0 15 emits-change writable .PositiveHysteresis property d 2 emits-change writable .Reading property ad 2 48 49 emits-change writable .Type property s "Stepwise" emits-change writable .Zones property as 1 "Zone0" emits-change writable ``` - Patch SWTest properties Body in JSON format ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "SWTest": { "NegativeHysteresis": 3.0, "PositiveHysteresis": 4.0 } } } } } } ``` Checking object from dbus ``` root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \ > /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \ > xyz.openbmc_project.Configuration.Stepwise NAME TYPE SIGNATURE RESULT/VALUE FLAGS .Delete method - - - .Class property s "Floor" emits-change writable .Inputs property as 1 "MB U402 THERM LOCAL" emits-change writable .Name property s "SWTest" emits-change writable .NegativeHysteresis property d 3 emits-change writable .Output property ad 2 0 15 emits-change writable .PositiveHysteresis property d 4 emits-change writable .Reading property ad 2 48 49 emits-change writable .Type property s "Stepwise" emits-change writable .Zones property as 1 "Zone0" emits-change writable ``` - Delete SWTest object Body in JSON format ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "SWTest": null } } } } } ``` Object deleted from dbus ``` root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \ > /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \ > xyz.openbmc_project.Configuration.Stepwise Failed to introspect object /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest of service xyz.openbmc_project.EntityManager: Unknown object '/xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest'. ``` Signed-off-by: Potin Lai <potin.lai@quantatw.com> Change-Id: I482e942ee3c76dca17af522765d8b3aa9dc8678b
2022-11-28Populate cable properties if length is NaNShantappa Teekappanavar1-5/+7
Cable Length property value is NaN by default. The current implementation ignores processing other remaining Cable properties if the length is NaN. Per Ed's comment here we need to ignore if length is NaN and continue to process remaining properties: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/50265/4..7/redfish-core\ /lib/cable.hpp#b51 Testing: 1. Validator test not done, assumed it is OK since it is a minor change in the code logic. 2. curl testing: $ curl -k https://user:password@host:18080/redfish/v1/Cables/dp0_cable1 { "@odata.id": "/redfish/v1/Cables/dp0_cable1", "@odata.type": "#Cable.v1_0_0.Cable", "CableType": "", "Id": "dp0_cable1", "Name": "Cable" } Signed-off-by: Shantappa Teekappanavar <shantappa.teekappanavar@ibm.com> Change-Id: If73828484d91bbf2eee45a31973c825bab008ba4
2022-11-28sdbusplus: use shorter type aliasesPatrick Williams2-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: I4af62f309f4cd3bb51759fa18de2448235e557fe Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2022-11-28pcie:Fix get PCIeFunctionTony Lee1-1/+1
GET /redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions/<str> return resourceNotFound messages. Test: GET /redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions/<str> return the expected information of PCIeDevices. Signed-off-by: Tony Lee <tony.lee@quantatw.com> Change-Id: I1587a74e77225939dec8030bba7fb04865e8051e
2022-11-23Add Link header handling to ThermalSubsystemGeorge Liu1-2/+35
Along with adding Link header, this commit updates ThermalSubsystem to respond to HEAD requests. The link header is something required by the Redfish spec. Also, Removed redundant code[1] [1] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/58731/2/redfish-core/lib/thermal_subsystem.hpp#b48 Tested: HEAD /redfish/v1/Chassis/<str>/ThermalSubsystem returns a correct looking Link header. Following that Link header resolves the schema file. Get /redfish/v1/Chassis/BadChassis/ThermalSubsystem returns 404. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: Ib93573808e4370ac45c2051517cd3f1c28e0f8bb
2022-11-18Allow a lower DeliveryRetryIntervalSecondsGunnar Mills1-3/+3
The current DeliveryRetryIntervalSeconds range is 30 - 180 seconds. As far as I can tell, this is arbitrary. Lower the minimum to 5 seconds so the client (the IBM management console) can set it to this low. The current default will still be 30 seconds. The client wanted it this low because the data might not be correct by the time the event is retried. 5 seconds is arbitrary, decided on this only based on the client's request. A lower minimum of like 1 or even 0 is reasonable to me but going with 5 seconds because that is the request and what has been tested. Tested: Before: ``` curl -k -H "Content-Type: application/json" -X PATCH https://$bmc/redfish/v1/EventService/ -d '{"DeliveryRetryIntervalSeconds": 5}' { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value 5 for the query parameter DeliveryRetryIntervalSeconds is out of range [30-180].", "MessageArgs": [ "5", "DeliveryRetryIntervalSeconds", "[30-180]" ], "MessageId": "Base.1.8.1.QueryParameterOutOfRange", ... ``` After: ``` curl -v -k -H "Content-Type: application/json" -X PATCH https://$bmc/redfish/v1/EventService/ -d '{"DeliveryRetryIntervalSeconds": 5}' ... < HTTP/1.1 200 OK ``` We have this patch downstream and have seen retring at 5 secs. Change-Id: I462569969565bdc97c15cb190ed65201d50abdf0 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2022-11-17Remove support for priv-noaccess roleAsmitha Karunanithi2-32/+1
A user created with no-access privilege is allowed to login but can not logout. Any no-access user can create many and many login sessions and exhaust the bmc without logging out. No-access role was basically added to support the IPMI usecase, where a user can be created first and then is assigned a privilege. This is being reworked at IPMI interface and the dependency on the no-access privilege is being removed completely. Following two commits were added to support the priv-noaccess in user-manager and bmcweb: [1] https://github.com/openbmc/bmcweb/commit/e9e6d240ab85e515f8d264e39b47a75043b73374 [2] https://github.com/openbmc/phosphor-user-manager/commit/7c6e7cffaf061aabfe5489ef52442e2f7cbd0fb7 This commit removes the no-access role support at bmcweb by reverting the commit: [1] https://github.com/openbmc/bmcweb/commit/e9e6d240ab85e515f8d264e39b47a75043b73374 The user-manager change w.r.t this change is at: [1] https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-user-manager/+/52363 Tested By: 1. Create an LDAP user with priv-noaccess. Verify the login attempt fails with accessDenied error 2. Verified the other role users can login Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I5ac8a58d9146379c9ce3be804d476ea85835bb2f
2022-11-16Add Link header handling to PowerSubsystemGeorge Liu1-4/+32
This commit is to update PowerSubsystem to respond to HEAD requests in the way the redfish spec requires. Tested: HEAD /redfish/v1/Chassis/<str>/PowerSubsystem returns a correct looking Link header. Following that Link header resolves the schema file. Get /redfish/v1/Chassis/BadChassis/PowerSubsystem returns 404. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I2f2a0e80b74471ddc037e899cfaf3ba307741475
2022-11-15Add Redfish EnvironmentMetrics schema in bmcwebAlbert Zhang3-0/+92
This commit implements Chassis' EnvironmentMetrics schema, a resource in Redfish version 2022.2 that represents the environment metrics implemented by Redfish. This resource includes Energy consumption, Fan speeds (percent), Power consumption (Watts), etc. And these data are mainly obtained from under sensors. Only the basic information of EnvironmentMetrics is implemented in the current commit. ref: https://www.dmtf.org/sites/default/files/standards/documents/ DSP0268_2022.2.pdf (6.31 EnvironmentMetrics 1.3.0) http://redfish.dmtf.org/schemas/v1/EnvironmentMetrics.v1_3_0.json Tested: Validator passes 1. doGet method to get EnvironmentMetrics curl -k -H "X-Auth-Token: $token" https://$bmc/redfish/v1/Chassis/ chassis/EnvironmentMetrics { "@odata.id": "/redfish/v1/Chassis/chassis/EnvironmentMetrics", "@odata.type": "#EnvironmentMetrics.v1_3_0.EnvironmentMetrics", "Id": "EnvironmentMetrics", "Name": "Chassis Environment Metrics" } 2. Input the wrong chassisId with the doGet method curl -k -H "X-Auth-Token: $token" https://$bmc/redfish/v1/Chassis/ chassisError/EnvironmentMetrics { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Chassis named 'chassisError' was not found.", "MessageArgs": [ "Chassis", "chassisError" ], "MessageId": "Base.1.13.0.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.0.ResourceNotFound", "message": "The requested resource of type Chassis named 'chassisError' was not found." } } Signed-off-by: Albert Zhang <zhanghaodi@inspur.com> Change-Id: I6a75dfbc94f39d90a1368770076b874608394691 Signed-off-by: George Liu <liuxiwei@inspur.com>
2022-11-14Processor: Implement links and HEADNikhil Namjoshi1-0/+45
Adds Links and Head handler for Processor and ProcessorCollection Tested: All of the below return a link header HEAD /redfish/v1/Systems/system/Processors HEAD /redfish/v1/Systems/system/Processors/cpu0 GET /redfish/v1/Systems/system/Processors GET /redfish/v1/Systems/system/Processors/cpu0 Change-Id: Iad19d577afb7cd9d5e652bed2d5884b6ea8260da Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2022-11-11thermal subsystem: iwyuNan Zhou1-0/+4
Tested: unit tests; just added a few used headers Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I3299f0445aedadd1411f4d3a407e9543197e22e1
2022-11-11Aggregation: Fix header clobberingCarson Labrado1-6/+0
We attempt to sanitize the response body of the asyncResp object as the first step of copying over the satellite response into the object. This is clobbering the "OData-Version" from the response header. We can completely remove this step since the body will already be empty. Tested: OData-Version is still present in the header when querying a satellite resource curl -s -D- localhost/redfish/v1/Chassis/5B247A_test | grep OData OData-Version: 4.0 Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I82f54ae9b990504a3236b7a1273c794b1ee6f090
2022-11-08power subsystem: fix headerNan Zhou1-0/+1
Added the logging header. Tested: code compiles. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ie707780e195766b37a3d307818615c6be36d424e
2022-11-08Add ThermalMetrics schemaGeorge Liu1-0/+1
Based on DSP8010_2022.2 and adds the ThermalMetrics schema. ThermalMetrics is child of the ThermalSubsystem schema. It is part of the new Power/Thermal Schemas. ThermalMetrics contains temperature readings and the corresponding link to that sensor in the sensor collection. Temperatures such as Ambient, Exhaust, Intake, and Internal can be found in the schema. Tested: built bmcweb successfully and validator passes. Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I16ad2f922acc963a0434f3d9ab5583d2242b0013
2022-11-07Implement links and HEAD for NetworkProtocolEd Tanous1-0/+21
Along the lines of changes we've made elsewhere, add Links, and a HEAD handler for bmc NetworkProcotol instances. Tested: ``` curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/JsonSchemas/NetworkProtocol/NetworkProtocol.json ``` Returns a links header as part of the response. Adding -X HEAD to the curl request results in the same header being included. Redfish service validator passes. Redfish PROTOCOL VALIDATOR PASSES ! ! ! ! ! with zero failures. Summary - PASS: 392, WARN: 0, FAIL: 0, NOT_TESTED: 32 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib96f7c8d5d8d960000a1bb77065fc06d2829e4b8
2022-11-02Update CollectionMembers to use UrlFromPiecesWilly Tu8-25/+29
Refactor getCollectionMembers to make sure all Url created with dbus paths are generated via UrlFromPieces helper function. This allow us to manage all URL generated from dbus in one place and allow us to make future changes to affect all resources. We can make changes to all resources easier if they are all managed by one function. Tested: Redfish Validator Passed. All Collections working as expected and match previous implmentation. Change-Id: I5d3b2b32f047ce4f20a2287a36a3e099efd6eace Signed-off-by: Willy Tu <wltu@google.com>
2022-10-31pcie: Fixed return nothing when get PCIeDeviceIdTony Lee1-5/+3
GET /redfish/v1/Systems/system/PCIeDevices/<str> nothing will be returned if their 'generationInUse' is Unknown. The original intention is that if it is Unknown, there is no need to display '"PCIeType"'. But the others still have to show. After fix: PCIeType is not Unknown: GET http://${bmc}/redfish/v1/Systems/system/PCIeDevices/<str> { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>.", "@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice", "DeviceType": "SingleFunction", "Id": "<str>", "Manufacturer": "Intel Corporation", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions" }, "PCIeInterface": { "PCIeType": "Gen1" } } PCIeType is Unknown: GET http://${bmc}/redfish/v1/Systems/system/PCIeDevices/<str> { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>", "@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice", "DeviceType": "SingleFunction", "Id": "<str>", "Manufacturer": "Intel Corporation", "Name": "PCIe Device", "PCIeFunctions": { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions" } } Signed-off-by: Tony Lee <tony.lee@quantatw.com> Change-Id: I85a97e0370a5789e4526964272381a557ce942a0
2022-10-31LogService: Increase dump timestamp precisionClaire Weinan1-20/+4
This is a follow-on to "LogService: Increase Fault Log timestamp precision" [1]. Since microsecond precision timestamp support for other dump types (in addition to FaultLog) have recently been added in phosphor-debug-collector (see "Populate timestamps with microsecond precision" [2]), we now update bmcweb to expose these timestamps with microsecond precision. Dump entry "Created" timestamps are based on the "Elapsed" property of the D-Bus interface xyz.openbmc_project.Time.EpochTime [3], which is defined as time elapsed since the epoch in microseconds. Client impact: Dump entry "Created" timestamps are shown with microsecond precision instead of second precision, for entries of all dump types (not just FaultLog). Tested: Forced creation of a system dump entry from BMC console: ``` busctl call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/system xyz.openbmc_project.Dump.NewDump Notify ut 1 2 ``` Retrieved the entry individually and as part of its collection: ``` curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Systems/system/LogServices/Dump/Entries/1 curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Systems/system/LogServices/Dump/Entries ``` Before change: `"Created": "2022-10-25T22:56:13+00:00",` After change: `"Created": "2022-10-25T22:56:13.271157+00:00",` Redfish Service Validator passed on the following URI trees: /redfish/v1/Managers/bmc/LogServices/Dump/Entries /redfish/v1/Managers/bmc/LogServices/FaultLog/Entries /redfish/v1/Systems/system/LogServices/Dump/Entries [1] https://github.com/openbmc/bmcweb/commit/c6fecdabd58b4c380caf1b83801ad4eb54922fff [2] https://github.com/openbmc/phosphor-debug-collector/commit/c0ab9d43d5e19123cca1a1592ee07fc064b84199 [3] https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Time/EpochTime.interface.yaml Signed-off-by: Claire Weinan <cweinan@google.com> Change-Id: Ia1682d09cf196c63da7d236df31695be5a5ad34b
2022-10-29Fix privileges on default handlersEd Tanous1-2/+8
Regardless of what privileges are allowed on a resource, we should almost always be pulling from the PrivilegeRegistry for the information. This corrects the handlers in redfish_v1.hpp. Namely that JsonSchemaCollection now pulls from the generated privilege registry files, and the 404 handler now requires a valid login to hit the route. This allows 401 to be returned on routes that would 404. Arguably users should not be able to see what routes bmcweb implements if they are not authenticated. Marking the 404 route as login is largely ceremonial and for documentation, because there is a separate check for a user being authenticated. Tested: Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4c03b0ae05d9fb7712d6ec3b6f2feaf034ca0750
2022-10-26redfish.hpp: fix header pathNan Zhou1-34/+34
This must be historical reason that we use relative path in these includes. Given that redfish-core/lib is already in include path, these relative paths are not necessary. Tested: code compiles. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ia6b6be8a7aded98c96cdca150467bc7d825230af
2022-10-25certificate: Allow deleting LDAP client certificateJiaqing Zhao1-0/+21
Users should be able to delete LDAP client certificate, and phosphor- certificate-manager already supports this. This patch adds the Redfish API endpoint for it. Tested: DELETE /redfish/v1/AccountService/LDAP/Certificates/1 removes the LDAP client certificate installed on system. Change-Id: If1c082c78c404b5877e74ba50de3a970cd823a90 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-10-21Implements PowerSubsystem schemaChicago Duan3-0/+69
This commit implements the Redfish PowerSubsystem schema and collects default property values. PowerSupplies will be implemented in the next commit. ref: https://www.dmtf.org/sites/default/files/standards/documents/ DSP0268_2022.2.pdf (6.86 PowerSubsystem 1.1.0) https://redfish.dmtf.org/schemas/v1/PowerSupply.v1_1_0.json Tested: Validator and UT passes 1. curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem", "@odata.type": "#PowerSubsystem.v1_1_0.PowerSubsystem", "Id": "PowerSubsystem", "Name": "Power Subsystem", "Status": { "Health": "OK", "State": "Enabled" } } 2. bad chassisID curl -k -H "X-Auth-Token: $token" -X GET https://${bmc} /redfish/v1/Chassis/badchassisID/PowerSubsystem/ PowerSupplies/powersupply0 { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Chassis named badchassisID was not found.", "MessageArgs": [ "Chassis", "badchassisID" ], "MessageId": "Base.1.13.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.1.ResourceNotFound", "message": "The requested resource of type Chassis named badchassisID was not found." } } Signed-off-by: Chicago Duan <duanzhijia01@inspur.com> Change-Id: I6885b1777082538eceaf7ea85a8f69966459ee43
2022-10-19Revert "NetworkProtocol: Support NetworkSuppliedServers property"Gunnar Mills1-25/+7
This reverts commit 525fc07224884d3640e5c4a1b6a551aee024f7bd. As discussed in discord, https://gerrit.openbmc.org/c/openbmc/openbmc/+/57931 is a legit fail. [1] https://discord.com/channels/775381525260664832/776550056391606352/1030497797121777768 The validator is failing due to: ERROR - NetworkSuppliedServers not defined in Complex NTPManagerNetworkProtocol.v1_2_0.NTPProtocol (check version, spelling and casing) Since the bmcweb bump merged, seeing validator fails in openbmc/openbmc. Revert, get the validator passing again, will open an issue with redfish since this looks like an issue with the schema itself. Tested: None. Change-Id: Ie8046c93eaf2f69c71eb5162dacb961032f9366c Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2022-10-18Add EnvironmentMetrics schemaGeorge Liu1-0/+1
Based on DSP8010_2022.2 and adds the EnvironmentMetrics schema. Tested: built bmcweb successfully and validator passes Signed-off-by: George Liu <liuxiwei@inspur.com> Change-Id: I994b48c544edc22a6bf99187b536f3e51e10b052
2022-10-18pcie: fixed filpped empty checkNan Zhou1-1/+1
It's obvious that we want to skip if the string is empty, not if it is valid. Tested: code compiles. Trivial change. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I892e81fb0f87a8999eb880100fd284419054eece
2022-10-18pcie: fix Members@odata.countNan Zhou1-1/+1
I believe this was a typo. We shouldn't return when a deviceId is not found. Tested: s7106 doesn't have PCIe backend configured. I tested it on a downstream system and Members@odata.count shows up. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I38491caf8998fac5fafa0c0f07396cf32066348b
2022-10-14NetworkProtocol: Support NetworkSuppliedServers propertySunitha Harish1-7/+25
There was no way to differentiate between the static and DHCP assigned NTP servers. Networkd and Dbus has added support for StaticNTPServers to save the static configuration. PATCH command will now set the StaticNTPServers property at the backend. NTPServers property will contain network supplied dynamic NTP Servers at the system. Tested by: 1. PATCH /redfish/v1/Managers/bmc/NetworkProtocol -d '{"NTP":{"NTPServers": [<ip>]}}' Verify that this adds the NTPs server to the NetworkProtocol 2. Enable DHCP to fetch NTP servers list from the DHCP server. Verify that they are listed when GET on NetworkProtocol as below "NTP": { "NTPServers": [ <static ntp server ip> ], "NetworkSuppliedServers": [ <dynamic ntp server ip> ], "ProtocolEnabled": true }, 3. Redfish validator run Signed-off-by: sunharis <sunithaharish04@gmail.com> Change-Id: Ifac77485485839292b770d36def35da17d723c4e
2022-10-12header cleanupsNan Zhou1-1/+1
This commit fixed several places (but not all) where wrong include directory is specified and prevent the clean up in the chidren changes. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ibbba62e2c0cfe3583a65f1befa1b233bd3eebf19
2022-10-11bmcweb: Add strictAccountTypes error messageShantappa Teekappanavar2-0/+30
Error message to be thrown when StrictAccountTypes is true and the specified value(s) for AccountTypes or OEMAccountTypes was not accepted. Testing: strictAccountTypes() error message was tested while testing redfish PATCH API for patching AccountTypes. Signed-off-by: Shantappa Teekappanavar <shantappa.teekappanavar@ibm.com> Change-Id: I13abcd142ddfb04a2a187c9373fa996ecfe987a1
2022-10-11CreateDump: Accept dump object pathAsmitha Karunanithi1-38/+176
This commit contains changes to accept the object path instead of the dumpId for user-initiated dumps. Earlier a task would be started to monitor the 'interfaces added' signal when a new dump object is created. Now, this change checks if the created dump object has implemented Progress interface, if yes, then the 'Status' property is used to track the dump creation progress. Else, task will be marked completed. With this change failed dumps will now be returning an internal error back to the user, as a part of the task message. The createDump dbus call has been changed in the backend to accept additional arguments with the below commits: [1] https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/36331 [2] https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-debug-collector/+/37792 [3] https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/44380 This commit also bumps up the task timeout. During system boot, the BMC dump takes more than 3 minutes to complete and task expires with a timeout. This commit increases this timeout to be 6 minutes. Tested-By: * POST https://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Actions/ LogService.CollectDiagnosticData -d '{"DiagnosticDataType":"Manager"}' => A task will be returned as the redfish response * GET https://${bmc}/redfish/v1/TaskService/Tasks/1 => Get on the task URI to verify the task status for success and failure scenarios Signed-off-by: Asmitha Karunanithi <asmitk01@in.ibm.com> Change-Id: I1686823a86eae836f770c19f33ffb21c98dd79ef
2022-10-10log_service: Fix error message for non-existing log entriesJiaqing Zhao1-21/+13
When requesting a log extry that does not exist on system, a 404 Not Found HTTP status code and corresponding ResourceNotFound error message should be returned. Current code mistakenly uses ResourceMissingAtURI error which should be used for referencing a non-existing resource in request properties. Tested: Verified requesting on a non-existing now responds with HTTP 404 and NotFound message manually. (This cannot be checked with Redfish Service Validator.) Change-Id: I3ef525eec3622918921bb9eb0b93fb6195c1a5b9 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>