summaryrefslogtreecommitdiff
path: root/redfish-core/lib/metric_report.hpp
AgeCommit message (Collapse)AuthorFilesLines
2022-04-06Add setUpRedfishRoute to all nodes in redfishEd Tanous1-5/+15
For better or worse, the series ahead of this is making use of setUpRedfishRoute to do the common "redfish specified" things that need to be done for a connection, like header checking, filtering, and other things. In the current model, where BMCWEB_ROUTE is a common function for all HTTP routes, this means we need to propagate this injection call into the whole tree ahead of the requests being handled. In a perfect world, we would invent something like a REDFISH_ROUTE macro, but because macros are discouraged, the routes take a variadic template of parameters, and each call to the route has a .privileges() call in the middle, there's no good way to effect this change in a less costly manner. This was messaged both in the prior reviews, and on discord sourcing improvements on this pattern, to which none arose. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id29cc799e214edad41e48fc7ce6eed0521f90ecb
2022-03-30Use url_view for telemetry urisSzymon Dompke1-3/+11
This change refactor telemetry code to use bmcweb utility function for uri construction, which is safe and preferred way, instead of string operations. Testing done: - Some basic GET operations done on Telemetry, no regression. Signed-off-by: Szymon Dompke <szymon.dompke@intel.com> Change-Id: I6de5d79a078944d398357f27dc0c201c130c4302
2022-02-09Enable readability-avoid-const-params-in-declsEd Tanous1-1/+1
This check involves explicitly declaring variables const when they're declared auto, which helps in readability, and makes it more clear that the variables are const. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
2022-01-11Fixed timestamp in telemetry serviceKrzysztof Grobelny1-2/+2
Telemetry service is using timestamp with milliseconds accuracy. Bmcweb code assumed that timestamp is in seconds which produced a bad result. This patchset updates the APIs, and adds a getDateTimeUintMs method, which can be used to convert a millisecond timestamp into a string. In the future, this can be used to get more precision out of the API. Reference: '9.4.3. Date-Time values' https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.8.0.pdf Tested: - Telemetry service timestamp show correct timestamp with milliseconds precission. Example: 2022-01-11T13:06:58.648000+00:00 - Other timestamps in bmcweb did not change - All unit tests are passing Reference: Properties.Readings https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Telemetry/Report.interface.yaml Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5b40ef6889b5af8c045ec0d35a758967e53dbed2
2021-12-28Using sdbusplus::asio::getPropertyJonathan Doman1-21/+11
It simplifies a lot of code and after changing sdbusplus implementation slightly reduces binary size if used together with: https://gerrit.openbmc-project.xyz/c/openbmc/sdbusplus/+/49467 * Uncompressed size: 3033148 -> 3012164, -20984 B * gzip compressed size: 1220586 -> 1214625, -5961 B Tested: - Redfish validator output is the same before and after the change Change-Id: Ibe3227d3f4230de2363ba3d9396e51130c8240a5 Signed-off-by: Jonathan Doman <jonathan.doman@intel.com> Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
2021-12-28Move to common variantEd Tanous1-3/+3
This saves approximately 34kB in the compressed binary size of bmcweb due to reduced template instantiations. This amounts to a 2.5% reduction in the overall size. Note, there were a few places where we broke const-correctness in the form of pulling a non-const reference out of a const variant. This new variant now requires const correctness, so some consts are added where required. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
2021-12-11fix the year 2038 problem in getDateTimeNan Zhou1-4/+2
The existing codes cast uint64_t into time_t which is int32_t in most 32-bit systems. It results overflow if the timestamp is larger than INT_MAX. time_t will be 64 bits in future releases of glibc. See https://sourceware.org/bugzilla/show_bug.cgi?id=28182. This change workarounds the year 2038 problem via boost's ptime. std::chrono doesn't help since it is still 32 bits. Tested on QEMU. Example output for certificate: { "Name": "HTTPS Certificate", "Subject": null, "ValidNotAfter": "2106-01-28T20:40:31Z", "ValidNotBefore": "2106-02-06T18:28:16Z" } Previously, the format is like "1969-12-31T12:00:00+00:00". Note that the ending "+00:00" is the time zone, not ms. Tested the schema on QEMU. No new Redfish Service Validator errors. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8ef0bee3d724184d96253c23f3919447828d3f82
2021-12-01Sync Telmetry service with EventServiceWludzik, Jozef1-14/+15
Synced the latest changes in Telemetry service with Event Service code. Now assembling MetricReport is covered in single place in code. Updated method of fetching Readings from Telemetry by Event Service. Using ReportUpdate signal is no longer supported. Now Event Service monitors for PropertiesChanged signal from /xyz/openbmc_project/Telemetry/Reports path. Tested: - Verified that EventListener received MetricReport response from Event Service in insecure http push style eventing mode Change-Id: I2fc1841a6c9259a8bff30b34bddc0d4aabd41912 Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
2021-11-05Make telemetry use the common collection utilitiesEd Tanous1-5/+9
getReportCollection is almost a 1:1 copy of getCollectionMembers, but hardcoded for report interface. This commit moves to using the common implementation, rather than duplicating the code. In the course of writing this patchset, it looks like the definition in metric_report_definition.hpp is incorrect, as we pulling metric reports instead of pulling metric report definitions. This commit has the same behavior as the old, but will need to be looked at in the future. Tested: Basic touch testing done by Szymon Dompke. "Everything looks good to me" Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I643da1849aacc38848db1da3eeaad0c111521d34
2021-07-08Automate PrivilegeRegistry to codeEd Tanous1-2/+3
This commit attempts to automate the creation of our privileges structures from the redfish privilege registry. It accomplishes this by updating parse_registries.py to also pull down the privilege registry from DMTF. The script then generates privilege_registry.hpp, which include const defines for all the privilege registry entries in the same format that the Privileges struct accepts. This allows new clients to simply reference the variable to these privilege structures, instead of having to manually (ie error pronely) put the privileges in themselves. This commit updates all the routes. For the moment, override and OEM schemas are not considered. Today we don't have any OEM-specific Redfish routes, so the existing ones inherit their parents schema. Overrides have other issues, and are already incorrect as Redfish defines them. Binary size remains unchanged after this patchset. Tested: Ran redfish service validator Ran test case from f9a6708c4c6490257e2eb6a8c04458f500902476 to ensure that the new privileges constructor didn't cause us to regress the brace construction initializer. Checked binary size with: gzip -c $BBPATH/tmp/work/s7106-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/usr/bin/bmcweb | wc -c 1244048 (tested on previous patchset) Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ideede3d5b39d50bffe7fe78a0848bdbc22ac387f
2021-06-16Remove ambiguous privileges constructorEd Tanous1-2/+2
There are a number of endpoints that assume that a given routes privileges are governed by a single set of privileges, instead of multiple sets ORed together. To handle this, there were two overloads of the privileges() method, one that took a vector of Privileges, and one that took an initializer_list of const char*. Unfortunately, this leads some code in AccountService to pick the wrong overload when it's called like this .privileges( {{"ConfigureUsers"}, {"ConfigureManager"}, {"ConfigureSelf"}}) This is supposed to be "User must have ConfigureUsers, or ConfigureManager, or ConfigureSelf". Currently, because it selects the wrong overload, it computes to "User must have ConfigureUsers AND ConfigureManager AND ConfigureSelf. The double braces are supposed to cause this to form a vector of Privileges, but it appears that the initializer list gets consumed, and the single invocation of initializer list is called. Interestingly, trying to put in a privileges overload of intializer_list<initializer_list<const char*>> causes the compilation to fail with an ambiguous call error, which is what I would've expected to see previously in this case, but alas, I'm only a novice when it comes to how the C++ standard works in these edge cases. This is likely due in part to the fact that they were templates of an unused template param (seemingly copied from the previous method) and SFINAE rules around templates. This commit functionally removes one of the privileges overloads, and adds a second set of braces to every privileges call that previously had a single set of braces. Previous code will not compile now, which is IMO a good thing. This likely popped up in the Node class removal, because the Node class explicitly constructs a vector of Privilege objects, ensuing it can hit the right overload Tested: Ran Redfish service validator Tested the specific use case outlined on discord with: Creating a new user with operator privilege: ``` redfishtool -S Always -u root -p 0penBmc -vvvvvvvvv -r 192.168.7.2 AccountService adduser foo mysuperPass1 Operator ``` Then attempting to list accounts: ``` curl -vvvv --insecure --user foo:mysuperPass1 https://192.168.7.2/redfish/v1/AccountService/Accounts/foo ``` Which succeeded and returned the account in question. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I83e62b70e97f56dc57d43b9081f333a02fe85495
2021-06-03Remove Redfish Node classJohn Edward Broadbent1-85/+57
Reduces the total number of lines and will allow for easier testing of the redfish responses. A main purpose of the node class was to set app.routeDynamic(). However now app.routeDynamic can handle the complexity that was once in critical to node. The macro app.routeDynamic() provides a shorter cleaner interface to the unerlying app.routeDyanic call. The old pattern set permissions for 6 interfaces (get, head, patch, put, delete_, and post) even if only one interface is created. That pattern creates unneeded code that can be safely removed with no effect. Unit test for the responses would have to mock the node the class in order to fully test responses. see https://github.com/openbmc/bmcweb/issues/181 The following files still need node to be extracted. virtual_media.hpp account_service.hpp redfish_sessions.hpp ethernet.hpp The files above use a pattern that is not trivial to address. Often their responses call an async lambda capturing the inherited class. ie (https://github.com/openbmc/bmcweb/blob/ffed87b5ad1797ca966d030e7f979770 28d258fa/redfish-core/lib/account_service.hpp#L1393) At a later point I plan to remove node from the files above. Tested: I ran the docker unit test with the following command. WORKSPACE=$(pwd) UNIT_TEST_PKG=bmcweb ./openbmc-build-scripts/run-unit-test-docker.sh I ran the validator and this change did not create any issues. python3 RedfishServiceValidator.py -c config.ini Signed-off-by: John Edward Broadbent <jebr@google.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I147a0289c52cb4198345b1ad9bfe6fdddf57f3df
2021-04-08Using AsyncResp everywherezhanghch051-9/+8
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
2021-02-09Redfish TelemetryService schema implementationWludzik, Jozef1-0/+159
Now user is able to communicate with Telemetry service using Redfish. Added TelemetryService, MetricReports, MetricReportCollection, MetricReportDefinition and MetricReportDefinitionCollection nodes with GET method support. Added TelemetryService URI to root service. Implemented communication with backend - Telemetry: https://github.com/openbmc/telemetry Added schemes attributes that are supported by Telemetry service design, ref.: https://github.com/openbmc/docs/blob/master/designs/telemetry.md Change introduces function that converts decimal value into duration format that is described by ISO 8601 and Redfish specification. Tested: - Tested using romulus and s2600wf images on QEMU - Verified DBus method calls to Telemetry service from bmcweb - Verified bmcweb responses from new nodes in different cases: - Report collection is empty - Report collection is filled with artificial data - Telemetry service is disabled - Verified time_utils::toDurationString() output - Passed RedfishServiceValidator.py Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com> Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Change-Id: Ie6b0b49f4ef5eeaef07d1209b6c349270c04d570