summaryrefslogtreecommitdiff
path: root/redfish-core/lib/virtual_media.hpp
AgeCommit message (Collapse)AuthorFilesLines
2021-06-03Remove Redfish Node classJohn Edward Broadbent1-0/+1
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-22Fix comparison for proxy/legacy modePrzemyslaw Czarnowski1-1/+15
After sdbusplus made available string path wrapper VM code has been updated to use it. This makes legacy mode unusable as appropriate change introduced a problem with comparison of DBus object path, which is now fixed. Tested: After applying this fix, legacy mode has InsertMedia action enabled again. Change-Id: I6339ae2977faacf50ce708199aaf3b13b4314398 Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2021-04-08Using AsyncResp everywherezhanghch051-58/+60
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-03-11bmcweb build issue fixAppaRao Puli1-1/+1
The bmcweb compile is failing when Virtual Media is enabled(BMCWEB_ENABLE_VM_NBDPROXY). This patch correct the code which is introduced recently. Tested: - Builds successful with VM. Change-Id: Ib8f65dd648d342a5f5dee5c4ead43949e08ace32 Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
2021-02-19Start using sdbusplus::message::filename()Ed Tanous1-15/+8
Lots of code gets checked in that does this path checking incorrectly. So much so, that we have it documented in COMMON_ERRORS.md, yet, we persist. This patchset starts using the new object_path::filename() method that was added recently to sdbusplus. Overall, it deletes code, and makes for a much better developer experience. Tested: Pulled down several endpoints and verified that filename() method works properly, and the collections are returned as expected. curl -vvvv --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/AccountService/Accounts Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ief1e0584394fb139678d3453265f7011bc931f3c
2020-12-18Fix .clang-tidyEd Tanous1-23/+21
camelLower is not a type, camelBack is. Changes were made automatically with clang-tidy --fix-errors To be able to apply changes automatically, the only way I've found that works was to build the version of clang/clang-tidy that yocto has, and run the fix script within bitbake -c devshell bmcweb. Unfortunately, yocto has clang-tidy 11, which can apparently find a couple extra errors in tests we already had enabled. As such, a couple of those are also included. Tested: Ran clang-tidy-11 and got a clean result. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9d1080b67f0342229c2f267160849445c065ca51
2020-12-04VirtualMedia doesn't propagate information to WebUIAnna Platash1-32/+77
Information if the image is mounted in read-only mode or not wasn't propagated from VirtualMedia to Web UI. Also TransportProtocolType value wasn't updated. Added the WriteProtected field value update using the WriteProtected property from MountPoint interface. Added TransportProtocolType field value update using image URL. Tested manually on ArcherCity by mounting images via RedFish interface with and without write protection, using HTTP and Samba. Schema validated by Redfish validator. Signed-off-by: Anna Platash <anna.platash@intel.com> Change-Id: I41d4a377d9fe3a978e8a3b654338c7a3d961b1c1
2020-11-09Fix Image and ImageName values in schemaPrzemyslaw Czarnowski1-7/+13
According to design document and schema Image shall contain URL of image location and ImageName only name of the image. Testing: Manual tests with mounting resource and checking redfish item. Change-Id: Ie1a906c66aa2a10113c307eb1e7d2d7da2810fbd Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2020-10-23Turn on ALL perf checksEd Tanous1-4/+4
1st, alphabetize the tidy-list for good housekeeping. Next, enable all the clang-tidy performance checks, and resolve all the issues. most of the issues boil down to: 1. Using std::move on const variables. This does nothing. 2. Passing big variables (like std::string) by value. 3. Using double quotes on a find call, which constructs an intermediate string, rather than using the character overload. Tested Loaded on system, logged in successfully and pulled down webui-vue. No new errors. Walked the Redfish tree a bit, and observed no new problems. Ran redfish service validator. Got no new failures (although there are a lot of log service deprecation warnings that we should look at). Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I2238958c4b22c1e554e09a0a1787c744bdbca43e
2020-08-26Fix unused param errorsVikram Bodireddy1-4/+3
Unused param errors are throwing from this sources by the recent CMake changes. Looks like CI build didn't catch these errors then. Tested: Build is verified. Signed-off-by: Vikram Bodireddy <vikram.bodireddy@linux.intel.com> Change-Id: I139c01a78babc1c370c0c5de787291726ea42b53
2020-08-17Remove middlewaresEd Tanous1-4/+4
Middlewares, while kinda cool from an academic standpoint, make our build times even worse than they already are. Given that we only really use 1 real middleware today (token auth) and it needs to move into the parser mode anyway (for security limiting buffer sizes), we might as well use this as an opportunity to delete some code. Some other things that happen: 1. Persistent data now moves out of the crow namespace 2. App is no longer a template 3. All request_routes implementations no longer become templates. This should be a decent (unmeasured) win on compile times. This commit was part of a commit previously called "various cleanups". This separates ONLY the middleware deletion part of that. Note, this also deletes about 400 lines of hard to understand code. Change-Id: I4c19e25491a153a2aa2e4ef46fc797bcb5b3581a Signed-off-by: Ed Tanous <ed@tanous.net>
2020-08-11VirtualMedia fixes for Redfish Service ValidatorPrzemyslaw Czarnowski1-2/+2
Removes all warnings and errors for VirtualMedia - rework for OemVirtualMedia - minor adjustments for jsons Tested: Redfish Service Validator ran with no errors and/or warnings Change-Id: Ic027166153a807a8bd3a6c04f042969f16e0dc6a Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2020-07-10Codespell redfish-core spelling fixesGunnar Mills1-1/+1
These spelling errors were found using https://github.com/codespell-project/codespell Tested: Top commit (along with this) was built and ran against validator. Change-Id: Ic9dce27b1de8567eedf7753164ef564d3aedf8ca Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-06-11clang-format: update to latest from docs repoGunnar Mills1-90/+90
This is from openbmc/docs/style/cpp/.clang-format Other OpenBMC repos are doing the same. Tested: Built and validator passed. Change-Id: Ief26c755c9ce012823e16a506342b0547a53517a Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-03-31Add handling of additional parameters of Insert Media action.Agata Olender1-39/+241
Add handling for new parameters: * Inserted - indicates if virtual media is inserted in the virtual device, current implementation supports only True value, * TransferMethod - the transfer method to use with the image, current implementation supports only Stream method, * transferProtocolType - the network protocol to use with the image, current implementation supports CIFS and HTTPS. Protocol type should be consistent with image URI prefix. Make writeProtected param optional. Tested manually from parameters validation perspective: - valid values for new params, - invalid values for new params, - presence of optional params. Change-Id: I135cb5ac181a442578d70821468214d0a8bcf0f6 Signed-off-by: Agata Olender <agata.olender@intel.com>
2020-03-31 Authentication support for Legacy modeAdrian Ambrożewicz1-5/+206
This change introduces new 'Mount' API argument - UNIX_FD for unnamed pipe. This unnamed pipe is utilized to securely send secret data over D-Bus. Currently data consists of null-terminated char buffers with username and password, that are passed as InsertMedia action parameters. Data on receiving side is encapsulated into classes whose role is to: - keep secret as short-lived as possible - erase secret from memory when it's not needed - pass secrets (and format them) to another secure container with above capabilities New classes: - Credentials: is a class encapsulating login and password. It zeroes them at destruction. - CredentialProvider: contains Credentials, specifies SecureBuffer, allows to store credentials in SecureBuffer New behavior: - When credentials are provided they are encapsulated as char array of two null-terminated strings - Pipe is opened as a medium to send this buffer - UNIX_FD of the pipe source is passed in ‘Mount’ call. Virtual-Media service reads from credentials over the pipe Tested: Manual and automated tests: - positive and negative tests for authentication on both CIFS and HTTPS resources - error injection (ill-formed data transfered over pipe, pipe broken etc.) Signed-off-by: Agata Olender <agata.olender@intel.com> Change-Id: I5b330b18c4bff222eab3062abfe27b5adaebf877
2020-03-16Add handling of WriteProtected parameter to InsertMedia action.Adrian Ambrożewicz1-39/+26
As continuation for VirtualMedia Redfish support, this patch adds handling and passing WriteProtected parameter to Virtual Media 'Mount' D-Bus call. WriteProtected parameter determines Read-Only mode for both USB Gadget and NBD stack. Tested: Manual and automated tests on WilsonCity platform: - mounting and unmounting images over CIFS and HTTPS (single, multiple at the same time etc) - positive and negative tests for D-Bus calls - ensuring proper information is exposed on D-Bus Signed-off-by: Agata Olender <agata.olender@intel.com> Change-Id: I5920c389785f5568754803f3c4989c188f9e0826
2020-02-20virtual media: Remove odata.contextGunnar Mills1-4/+0
Redfish made odata.context optional (1.6.0 of DSP0266, Sept 2018). Redfish has removed odata.context from example payloads in the specification (1.7.0 of DSP0266), removed it from the mockups, and Redfish recommended not using. The reason for making optional and removing from mockups/examples, "no one could figure out how to use it and it did not add value". Don't see value in it for our implementation. Change-Id: I3972fea43d89267ba91f5a0f7c0aac00a18e0f6c Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-01-27Add OemVirtualMedia schemaPrzemyslaw Czarnowski1-4/+7
OEM Schema for VirtualMedia added. Also OpenBMC level has been added to OEM field in the code to conform to schema standard. Tested: Manually using full stack of VirtualMedia. * Inserting/ejecting media in both legacy and proxy mode * Redfish Service Validator 1.3.2 ran Change-Id: Iaa87dd767a4bf2062bd4e74dd790a2496aca96de Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2020-01-27InsertMedia and EjectMedia actions added to VirtualMedia schemaPrzemyslaw Czarnowski1-1/+376
As continuation for VirtualMedia Redfish support, this patch adds insertion and eject actions into existing VirtualMedia code base. Testing: * Manual tests together with nbd proxy and virtual media app - For requests: Postman and/or HTTPie, with logs enabled and Valgrind) - Manual result validation * Tests run: - GET on collection with manual validation - PUT/POST/DELETE on collection - GET on item/nonexistent item - PUT/POST/DELETE on item - GET/PUT/DELETE on action - POST on action - EjectMedia/InsertMedia, legacy mode - POST on action - InsertMedia, proxy mode - POST on action - input validation (empty, invalid URL), legacy mode * Redfish Service Validator tested, no new issues found. Change-Id: Icccc433c1e84bc2ac37d9c295fe72749187fb735 Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
2020-01-27Add VirtualMedia schema to RedfishPrzemyslaw Czarnowski1-0/+373
This change adds VirtualMedia scheme to Redfish. Implementation is based on input from virtual-media module and nbd proxy which is a bmcweb part. The code is used only in case ndb-proxy is supported in bmcweb (BMCWEB_ENABLE_VM_NBDPROXY compilation flag). Tested: * Manual tests together with nbd proxy and virtual media app - For requests: Postman and/or HTTPie, started with logs enabled and Valgrind - Manual result validation * Tests ran: - GET on collection with manual validation - PUT/POST/DELETE on collection - GET on item/nonexistent item - PUT/POST/DELETE on item * Redfish Service Validator tested, no new issues found. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Change-Id: I5415dc0ffe52069fd35bc614b0378bbc4ad41ff6