summaryrefslogtreecommitdiff
path: root/redfish-core/lib/ethernet.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-13Fix missed bmcweb::AsyncRespGunnar Mills1-4/+3
8d1b46d7 moves bmcweb to using AsyncResp everywhere, and not have each individual handler creating its own object. 9010ec2e should not have been merged yet. This fixes a miss in the review. Tested: Built and validator passes. From webui-vue, changed the IP Address. Change-Id: I04b070ed61b788fa87e9d6fddede502701e9742d Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2021-04-12Redfish(Network): Modified to support Default gateway on EthernetInterfaceRavi Teja1-36/+75
Earlier we have the gateway at system level, Now with the change https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-networkd/+/34852/ Gateway has been associated with interface level. This commit fixes this behaviour. Tested by: GET https://${BMC_IP}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0/ PATCH -D '{"IPv4StaticAddresses": [{},{"Address": "10.7.8.7","SubnetMask": "255.255.0.0","Gateway":"10.7.8.1"}]}' https://${BMC_IP}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 Ran Redfish validator Signed-off-by: Ravi Teja <raviteja28031990@gmail.com> Change-Id: I39e76b9552dacfe249c459590b1986d6eba8bb89
2021-04-08Using AsyncResp everywherezhanghch051-63/+66
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-22ethernet: Fix for MAC address patch responseJayaprakash Mutyala1-0/+1
While Patching MAC address from Redfish, response is showing as empty but HTTPS status code is "200 OK" on successful case. So provided fix for Proper response on Success. Tested: 1. Verified RedFish validator passed 2. Verified the response on Redfish by updating MAC address. PATCH: https://<bmc_ip>/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 Body: { "MACAddress": "xx:xx:xx:xx:xx:xx" } Response: { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "Successfully Completed Request", "MessageArgs": [], "MessageId": "Base.1.8.1.Success", "MessageSeverity": "OK", "Resolution": "None" } ] } Signed-off-by: Sunita Kumari <sunitax.kumari@intel.com> Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com> Change-Id: I91a34f414b854593b4873e4ed923734030d6562d
2021-03-17Fix IPv6DefaultGateway validator warningsRavi Teja1-1/+7
This commit fixes below warnings WARNING - IPv6DefaultGateway: Empty string found Tested By: Ran validator Signed-off-by: Ravi Teja <raviteja28031990@gmail.com> Change-Id: Iac41feeb6cf245348f69915e0f58dd24ae46330e
2021-02-19Fix nlohmann::json::dump callsEd Tanous1-8/+26
The nlohmann::json::dump call needs to be called with specific arguments to avoid throwing in failure cases. http connection already does this properly, but a bunch of code has snuck in (mostly in redfish) that ignores this, and calls it incorrectly. This can potentially lead to a crash if the wrong thing throws on invalid UTF8 characters. This audits the whole codebase, and replaces every dump() call with the correct dump(2, ' ', true, nlohmann::json::error_handler_t::replace) call. For correct output, the callers should expect no change, and in practice, this would require injecting non-utf8 characters into the BMC. Tested: Ran several of the endpoints/error conditions in question, including some of the error cases. Observed correct responses. I don't know of a security issue that would allow injecting invalid utf8 into the BMC, but in theory if it were possible, this would prevent a crash. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4a15b8e260e3db129bc20484ade4ed5449f75ad0
2021-02-19Start using sdbusplus::message::filename()Ed Tanous1-6/+5
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-41/+41
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-11-02Improve loops & fix cpp check warningManojkiran Eda1-18/+10
- This commit improves certain while loops to range based for loops. - This commit also fixes the cppcheck warning that mentions about performance issues when using postfix operators on non-primitive types. Tested By: - A function is unittested. - GET on both EthernetInterfaces & certificate service looks good without any issues. Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I85420f7bf9af45a97e1a93b916f292c2516f5802
2020-10-23Turn on ALL perf checksEd Tanous1-26/+28
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-10-15Lots of performance improvementsEd Tanous1-19/+21
(In the voice of the kid from sixth sense) I see string copies... Apparently there are a lot of places we make unnecessary copies. This fixes all of them. Not sure how to split this up into smaller patches, or if it even needs split up. It seems pretty easy to review to me, because basically every diff is identical. Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369 Signed-off-by: Ed Tanous <ed@tanous.net> Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
2020-10-09Write the clang-tidy file OpenBMC needsEd Tanous1-30/+12
Now that CI can handle clang-tidy, and a lot of the individual fixes have landed for the various static analysis checks, lets see how close we are. This includes bringing a bunch of the code up to par with the checks that require. Most of them fall into the category of extraneous else statements, const correctness problems, or extra copies. Tested: CI only. Unit tests pass. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I9fbd346560a75fdd3901fa40c57932486275e912
2020-09-29Fix naming conventionsEd Tanous1-176/+173
Lots of code has been checked in that doesn't match the naming conventions. Lets fix that. Tested: Code compiles. Variable/function renames only. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I6bd107811d0b724f1fad990016113cdf035b604b
2020-08-17Enable unused variable warnings and resolveEd Tanous1-26/+23
This commit enables the "unused variables" warning in clang. Throughout this, it did point out several issues that would've been functional bugs, so I think it was worthwhile. It also cleaned up several unused variable from old constructs that no longer exist. Tested: Built with clang. Code no longer emits warnings. Downloaded bmcweb to system and pulled up the webui, observed webui loads and logs in properly. Change-Id: I51505f4222cc147d6f2b87b14d7e2ac4a74cafa8 Signed-off-by: Ed Tanous <ed@tanous.net>
2020-08-17Enable clang warningsEd Tanous1-6/+6
This commit enables clang warnings, and fixes all warnings that were found. Most of these fall into a couple categories: Variable shadow issues were fixed by renaming variables unused parameter warnings were resolved by either checking error codes that had been ignored, or removing the name of the variable from the scope. Other various warnings were fixed in the best way I was able to come up with. Note, the redfish Node class is especially insidious, as it causes all imlementers to have variables for parameters, regardless of whether or not they are used. Deprecating the Node class is on my list of things to do, as it adds extra overhead, and in general isn't a useful abstraction. For now, I have simply fixed all the handlers. Tested: Added the current meta-clang meta layer into bblayers.conf, and added TOOLCHAIN_pn-bmcweb = "clang" to my local.conf Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ia75b94010359170159c703e535d1c1af182fe700
2020-08-17Remove middlewaresEd Tanous1-8/+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-03Redfish: GET command for Hypervisor DHCP networkSunitha Harish1-0/+1
This commit adds support to GET the DHCP configuration details on the Hypervisor's Ethernet Interface Tested by: Set the DHCPEnabled property on /xyz/openbmc_project/network/hypervisor/eth0 Run the redfish GET command below to check the value set. GET https://${bmc}/redfish/v1/Systems/hypervisor/EthernetInterfaces/eth0 Successfully ran the Redfish Validator Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Change-Id: Iacfc2b975fc6e4b759082419aa8f0b9c193d7787
2020-07-10Codespell redfish-core spelling fixesGunnar Mills1-3/+3
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-180/+181
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-05-16vlan id should be 32 bitAndrew Geissler1-1/+1
Upstream yocto appears to bring in a new compiler which is flagging the inconsistency of the VLAN ID data type and failing to compile bmcweb because of it. The redfish specification lists the datatype for VLANId as a integer that can range from 0-4094. Here's the error: /lib/ethernet.hpp:2221:58: error: no matching function for call to 'std::variant<unsigned int>::variant(uint64_t&)' | 2221 | std::variant<uint32_t>(vlanId)); Change-Id: Ic92ad6518a9529f5099a1eaf1250df106119d319 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
2020-05-16Add OCP mandatory entry for IPv6AddressPolicyTableJohnathan Mantey1-0/+3
The Open Compute Project mandates the presence of the IPv6AddrssPolicyTable collection in Redfish. This commit adds the mandatory collection as an empty collection. Tested: Ran redfish service validator and confirmed the table collection was found. Change-Id: I6e98295f2a33acd49a3bb01d97aa840525875dd2 Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2020-05-14Create the IPv6 AddressState Redfish node for OCPJohnathan Mantey1-2/+4
The Open Compute Project defines the IPv6 AddressState entry to be a mandatory field. OpenBMC does not have any support in phosphor-network for reporting the actual IPv6 state. The AddressState field is allowed to be null. This commit returns the AddressState as a null. Tested: Ran service validator Ran a GET on Managers/bmc/EthernetInterfaces/eth0 and saw the addition of the AddressState, and that it was null. Change-Id: Ia2847f94ac73fc05ff2ca1be40a3f601fa0a3dfc Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2020-05-14Redfish(Network): Fix PATCH of existing IPv4StaticAddresses propertiesRavi Teja1-7/+0
Currently Unable to modify(PATCH) existing IP address properties. Failure case: add an ipv4 static address and try to do patch operation to modify properties of this static address entry. say existing entry "IPv4StaticAddresses": [ { "Address": "223.7.7.7", "AddressOrigin": "Static", "Gateway": "223.7.7.1", "SubnetMask": "255.255.0.0" }] do patch operation, it returns success but does not update properties. 1.PATCH -D '{"IPv4StaticAddresses": [{"Address": "10.7.7.20","SubnetMask": "255.255.0.0","Gateway":"223.7.7.1"}]}' 2.PATCH -D '{"IPv4StaticAddresses": [{},{"Address": "10.8.8.8"}]} both cases expected to work. . Test By: Pacthing existing entry properties and creating new entries. 1.PATCH -d '{"IPv4StaticAddresses": [{},{"Address": "10.7.7.20","SubnetMask": "255.255.0.0","Gateway":"10.7.7.1"}]}' 2.PATCH -D '{"IPv4StaticAddresses": [{},{"Address": "10.8.8.8"}]} 3.PATCH -d '{"IPv4StaticAddresses": [{},{"Address": "10.8.8.8"},{"Address": "10.9.9.9","SubnetMask": "255.255.0.0","Gateway":"9.41.164.1"}]}' 4.GET https://${IP}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0/ Signed-off-by: Ravi Teja <raviteja28031990@gmail.com> Change-Id: Ic23330592e9041ddd1e9f96d08ea0bb88c6d8ca7
2020-05-14sdbusplus: replace message::variant with std::variantPatrick Williams1-4/+4
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ia5d0845741f1d8d4bc6fd227c6d2e6f3a8d42b2e
2020-05-14sdbusplus: remove deprecated variant_nsPatrick Williams1-12/+6
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I86e11299512704fa1df1e5f6517ea25cc6eced8f
2020-04-16Redfish: Allow slash at the end of ResourceGunnar Mills1-1/+1
This is defined in the Redfish protocol. Easiest way to allow this is to end the Node URL with "/", which most Nodes in bmcweb already had. Before: curl -k https://${bmc}/redfish/v1/TaskService/ Not Found After both /redfish/v1/TaskService/ and /redfish/v1/TaskService return the Task Service. Tested: Validator passed. Change-Id: Ic806dc5c91f631b87642e49b486a6b6da7fdf955 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-04-09Support for NameServers & StaticNameServersmanojkiran.eda@gmail.com1-12/+19
- As per the proposal made in the mentioned mailing list thread https://lists.ozlabs.org/pipermail/openbmc/2019-September/018399.html As mentioined in the proposal, it is agreed that configuring the Nameservers by the DHCP server is an optional step, and therefore the Static and Dynamic Configurations can co-exist. The commit supports : 1. NameServers - A readonly property which contains all the nameservers (Static & Dynamic) configured on an interface. 2. StaticNameServers - A writable property which can be used by a redfish client to set a NameServer(Static) on the interface. TestedBy: 1. Redfish Validator - PASS 2. Pass the DNS via DHCP Server and make sure we populate NameServers with the DNS supplied by DHCP. 3. With the DNS supplied via DHCP intact, set another Namserver by PATCH on the StaticNameServers property, and Made sure StaticNameServers and NameServers populates the respective information. 4. PATCH opteration on NameServers should throw an Error Saying it is a Readonly property. Signed-off-by: manojkiran.eda@gmail.com <manojeda@in.ibm.com> Change-Id: I43b75091cce6938ea2fa094692f2c3f434e5a774
2020-04-01[Redfish-Ethernet Inf] Enable Read/Write for FQDNJoshi-Mansi1-10/+106
Enabling read/write requirement of FQDN in Ethernet Interface Schema to make it OCP compliant. Tested: 1. Tested using PATCH: - https://bmc-ip/redfish/v1/Managers/bmc/EthernetInterfaces/eth-id {"FQDN": "hostname.domainname"} GET Response- "FQDN": "hostname.domainname" //Success - When given invalid hostname/domainname Error Message "propertyValueFormatError" 2. Ran the Redfish validator and no new issues found. Signed-off-by: Joshi-Mansi <mansi.joshi@linux.intel.com> Change-Id: Ief2e94f8b499be59196b0e7073ceffe8d49268ca
2020-02-19Permit Redfish to enable/disable the network interface cardJohnathan Mantey1-15/+74
The InterfaceEnabled property for an EthernetInterfaces element was hardcoded to "true". This change gets the actual state of the NIC. It also permits the NIC to be enabled or disabled. Tested: GET sut_ip/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 (and eth1) PATCH InterfaceEnabled to false GET sut_ip/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 (and eth1) PATCH InterfaceEnabled to true GET sut_ip/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 (and eth1) Confirmed the NIC was disabled from the BMC console using "ip link" Confirmed the Get NIC status reported the correct enabled state. Performed the tests above on a different network to confirm the second NIC can be controlled orthogonally. Passed service validator. Change-Id: I09b703118fe71765c7b1020688a803c74648c7c4 Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2020-02-15ethernet: Remove odata.contextGunnar Mills1-13/+0
Redfish made odata.context optional (1.6.0 of DSP0266), 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. Change-Id: I5a78856c510f063df67999bb8196e77401c56aac Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
2020-02-14Report NIC link status via netlink carrier stateJohnathan Mantey1-2/+12
Update Redfish to use a DBus boolean value specifically intended for communicating the NIC link state. Existing Intel server boards have a NCSI channel with a speed value always assigned to 100Mbps. This makes identifying link state impossible via the network speed value. The DBus boolean uses the netlink carrier on/off state which is more accurate. Tested: BMC Console commands: ip link set down dev eth0 Get managers/bmc/eth0 state ;; LinkStatus is LinkDown ip link set up dev eth0 Get managers/bmc/eth0 state ;; LinkStatus is LinkUp Remove NIC cable from RJ45 connector Get managers/bmc/eth0 state ;; LinkStatus is LinkDown Insert NIC cable into RJ45 connector Get managers/bmc/eth0 state ;; LinkStatus is LinkUp Change-Id: I93d3f716a0afc563e3312e99b4a4163187985521 Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2019-11-06Redfish: Implement DHCPv4 and DHCPv6 handlingJohnathan Mantey1-95/+256
The Redfish DHCP handling has independent control of DHCPv4 and DHCPv6. This change combines with phosphor-network and phosphor-dbus-interface changes to implement the independent control capability. Tested by: Verified DHCP is able to be enabled for both DHCPv4 and DHCPv6 Verified DHCPv4 can be enabled, and static IPv6 addresses configured Verified DHCPv6 can be enabled, and static IPv4 addresses configured Verified DHCP can be disabled for both interfaces Confirmed enable/disable of UseNTP, UseDNS, and UseHostname Passes Redfish Service Validator Change-Id: I449ec096a3c41231c9bc9aa1bf67824982525cec Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2019-10-11Fix a bunch of warningsEd Tanous1-13/+22
using the list of warnings from here: https://github.com/lefticus/cppbestpractices/blob/e73393f25a85f83fed7399d8b65cb117d00b2231/02-Use_the_Tools_Available.md#L100 Seems like a good place to start, and would improve things a bit type-wise. This patchset attempts to correct all the issues in one shot. Tested: It builds. Will test various subsystems that have been touched Signed-off-by: Ed Tanous <ed.tanous@intel.com> Change-Id: I588c26440e5a97f718a0f0ea74cc84107d53aa1e
2019-09-14Redfish: Make NIC HW reflect PATCH changesJohnathan Mantey1-459/+388
PATCH commands only changed the state of the DBus database. The PATCH did not actually change the state of the NIC settings. IPMITOOL and "ip addr" both delete the specific hash entry, and then create a new entry using the requested state. This change aligns Redfish with that behavior. The requested element is deleted, and subsequently recreated with the new values. This guarantees the NIC HW is actually updated, and in sync with the DBus database. Tested by: From eth1 modify eth0 state: IPv4 tests: Delete all addresses Create five new addresses Add a new entry to the end of the collection Delete the new entry just added Send a "keep" command that does not modify any state, and "keeps" more entries than are actually in the IPv4Addresses collection Keep all entries, and delete entries that do not exist Delete all entries except self assigned Send a PATCH with an empty IPv4StaticAddresses array IPv6 tests: Delete all entries except SLAAC Create five static entries Modify only the prefix for one entry Modify only the address for one entry Add an additional entry Delete the new entry Keep all entries, plus a few that don't exist Keep all entries, delete a few that don't exist Delete all entries except SLAAC Send a PATCH with an empty IPv6StaticAddresses array Change-Id: Id5f733f795588ba36b5d3ab3b0017a01ee3f2da7 Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2019-08-27Network : Fix the Service Validator FailureManojkiran Eda1-1/+1
On a DHCP Enabled System, the StaticNameServer property is not aligned to the redfish schema rules and the validator reports the below error: StaticNameServers: Value of Collection property is null but Collections cannot be null, only their entries. Testedby: Redfish Validator *** /redfish/v1/JsonSchemas/EthernetInterface Type (#JsonSchemaFile.v1_0_2.JsonSchemaFile), GET SUCCESS (time: 1.134773) PASS Note: - Previously missed this failure, as i verified the validator on Statically configured setup Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I6119e8d5783571ac75084301b49df1f44a558c8b
2019-08-20Avoid populating StaticNameServers propertyManojkiran Eda1-1/+9
Redfish ethernet schema has two properties for nameservers 1.NameServers - Represents nameservers currently in use on Interface 2.StaticNameServers -Represents only statically defined set of DNS As we have only one DBUS property `Nameservers` which is used for both the static and dynamic nameservers, So the idea behind this commit is to not populate the StaticnameServers property when DHCP mode is enabled. Tested By: GET https://${BMC_IP}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com> Change-Id: I64f66bde55ec41dc78befbb659a0cbc425bbc24b
2019-08-01Redfish(Network): IPV4 DHCP ipaddreses dont show gateway when in DHCP modeRavi Teja1-2/+3
Tested by: configuring DHCP, GET https://${BMC_IP}/redfish/v1/Managers/bmc/EthernetInterfaces/eth0 Signed-off-by: Ravi Teja <raviteja28031990@gmail.com> Change-Id: Ic7067db41fbb8327ef55cc7552f9153d1ecfb63a
2019-07-03Redfish(Network): Add support for IPv4StaticAddressesRavi Teja1-42/+97
Added GET and PATCH support for IPv4StaticAddresses and modified IPv4Addresses as read-only property Tested by: GET PATCH -D patch.txt -d '{"IPv4StaticAddresses": [{},{},{"Address": "10.7.8.7","SubnetMask": "255.255.0.0","Gateway":"10.7.8.1"}]}' PATCH -D patch.txt -d '{"IPv4StaticAddresses": [{},{"Address": "10.7.7.8","SubnetMask": "255.255.0.0","Gateway":"10.7.7.1"}]}' PATCH -D patch.txt -d '{"IPv4StaticAddresses": [null,{},{"Address": "10.7.7.9","SubnetMask": "255.255.0.0","Gateway":"10.7.7.1"}]}']}' PATCH -D patch.txt -d '{"IPv4StaticAddresses": [{},{"Address": "10.8.8.9"}]}' Tested with validator and no errors. Signed-off-by: Ravi Teja <raviteja28031990@gmail.com> Change-Id: I580787933f1d93d0734e32f71ac9fc80dc108247
2019-06-14[Redfish] Add FQDN and IPv6Address in NetworkProtocol and EthernetInterfaceJennifer Lee1-0/+17
FQDN and IPv6Address are mandatory properties in OCP profile. Tested: GET /redfish/v1/Managers/bmc/NetworkProtocol HTTP/1.1 Response: { "@odata.context": "/redfish/v1/$metadata#ManagerNetworkProtocol.ManagerNetworkProtocol", "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol", "@odata.type": "#ManagerNetworkProtocol.v1_4_0.ManagerNetworkProtocol", "Description": "Manager Network Service", "FQDN": <host name>.<domain name>, "HTTPS": { "Port": 443, "ProtocolEnabled": true }, "HostName": <host name>, ... } GET /redfish/v1/Managers/bmc/EthernetInterfaces/eth0 HTTP/1.1 Response: { "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface", "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0", "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface", ... "FQDN": <host name>.<domain name>, "HostName": <host name>, ... "IPv6Addresses": [], ... } Signed-off-by: Jennifer Lee <jennifer1.lee@intel.com> Change-Id: I0ca8f98523cbcfc935e0ac3bbf93f87762ff183b
2019-06-13Redfish: Remove "state" response content from PATCH commandsJohnathan Mantey1-131/+49
A PATCH command should not return any JSON content for the NICs. PATCH commands should only return success or failure responses. Reporting state based upon the input to the command is, in most instances, going to be incorrect in comparison to the actual state of the HW. For example: moving from static addresses to a DHCP assigned address cannot be predicted based upon the input. It also takes several seconds for a DHCP transaction to complete, which creates a significant temporal lag between what was sent and what will be. Tested: Performed the following tests: For IPv4: "IPv4Addresses": [ {}, { "Address": "192.168.20.12", "SubnetMask": "255.255.255.0", "Gateway": "192.168.20.1" } ] For IPv6: "IPv6StaticAddresses": [ { "Address": "2001::5:4:3:4", "PrefixLength": 64 } ] Both tests complete without emitting any JSON content. Change-Id: Ic7eb824eb6d996d85d52a3b7c855e9825f4a0d87 Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2019-06-13Redfish: Remove the IPv4 AddressOrigin read-only elementJohnathan Mantey1-88/+2
The AddressOrigin entry in the IPv4Addresses schema is read-only. It is not permitted to PATCH the AddressOrigin. Tested: Added the "AddressOrigin": "DHCP" to an IPv4Addresses PATCH command. The JSON response is "property is not in the list of valid properties". Change-Id: Id7d41e9f1b393738e20725495b3821dd2f9f69d0 Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2019-06-13Redfish: Correctly identify IPv4 LinkLocal vs. LinkGlobalJohnathan Mantey1-2/+2
Self assigned IPv4 addresses must be flagged as LinkLocal, not LinkGlobal. Likewise global IPv4 addresses must be flagged as LinkGlobal. Change-Id: I9f6f0ceb3d312dd0198cb54c59c579ed96fbc38a Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2019-06-10Redfish: Correct PATCH for IPv6 static addressesJohnathan Mantey1-12/+4
Manipulating IPv6 static addresses works the same way as IPv4 static addresses. Keep the IPv6StaticAddresses collection, and remove write access from the read-only IPv6Addresses collection. Change-Id: If58c858c676f7ae843e0642800a4083c5df79d1d Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
2019-06-06Redfish(Network): Add support for IPv6Addresses and IPv6StaticAddressesRavi Teja1-60/+445
Added GET support for IPv6Addresses Added GET and PATCH support for IPv6StaticAddresses Tested by: GET PATCH -D patch.txt -d '{"IPv6StaticAddresses": [{"Address": "2002:905:150e:301:72e2:84ff:fe14:222","PrefixLength": 64}]}' PATCH -D patch.txt -d '{"IPv6StaticAddresses": [{},{"Address": "2002:905:150e:301:72e2:84ff:fe14:333","PrefixLength": 64}]}' PATCH -D patch.txt -d '{"IPv6StaticAddresses": [null,{},{"Address": "2002:905:150e:301:72e2:84ff:fe14:444","PrefixLength": 64}]}' PATCH -D patch.txt -d '{"IPv6StaticAddresses": [{"Address": "2002:905:150e:301:72e2:84ff:fe14:555","PrefixLength": 64},{}]}' PATCH -D patch.txt -d '{"IPv6StaticAddresses": [{},{"Address": "2002:905:150e:301:72e2:84ff:fe14:666"}]}' PATCH -D patch.txt -d '{"IPv6StaticAddresses": [{},{"PrefixLength": 64}]}' Tested with validator and no errors. Change-Id: I7d1314a0c7843aae8425d66119f0d205a5cfac55 Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
2019-05-30[Redfish] Enable PATCH for DHCPv4 properties in EthernetInterface schemaJennifer Lee1-1/+86
DHCPv4 were read-only properties, this code change make following properties to be PATCHable: - DHCPEnabled - UseDNSServers - UseDomainName - UseNTPServers Tested: 1. Check DHCPv4 properties value GET /redfish/v1/Managers/bmc/EthernetInterfaces/<ethID> HTTP/1.1 Response: { ...... "DHCPv4": { "DHCPEnabled": true, "UseDNSServers": true, "UseDomainName": true, "UseNTPServers": true }, ...... } 2. PATCH DHCPv4 PATCH /redfish/v1/Managers/bmc/EthernetInterfaces/eth1 HTTP/1.1 { "DHCPv4": { "DHCPEnabled":false, "UseDNSServers": false, "UseDomainName": false, "UseNTPServers": false } } 3. Check whether DHCPv4 properties are set GET /redfish/v1/Managers/bmc/EthernetInterfaces/<ethID> HTTP/1.1 Response: { ...... "DHCPv4": { "DHCPEnabled": false, "UseDNSServers": false, "UseDomainName": false, "UseNTPServers": false }, ...... } Signed-off-by: Jennifer Lee <jennifer1.lee@intel.com> Change-Id: I125029ae4cdef329edabd18f6aa6a16db6e27d3d
2019-05-21Fix 404 handling in Redfish EthernetInterfacesEd Tanous1-16/+40
Previously, when a user requested a network interface that was non-sensical, like: /redfish/v1/Managers/bmc/EthernetInterfaces/foobar/VLANs OR /redfish/v1/Managers/bmc/EthernetInterfaces/foobar They would be presented with a 200-OK, and a partially filled in object. While this doesn't matter much for the casual redfish user, who uses the collection to properly enumerate devices, this causes an issue with security scanners, which think they've found some vulnerability when they can throw whatever injection text they want to in the message, and it shows up in the response. This patchset corrects this, and causes the urls referenced above to properly return 404, and the appropriate "ResourceNotFound" error message. Tested: Attempted both URLs shown above. Both return 404. Ran redfish service validator, observed no errors related to EthernetInterface, or sub nodes. Attempted good URLs, and observed no change to the payload. Signed-off-by: Ed Tanous <ed.tanous@intel.com> Change-Id: Idb2758858d4dbaf421c0cef28b1d5d02402e0ad8
2019-05-09Redfish(Network): Implemented PATCH of Nameservers arrayRAJESWARAN THILLAIGOVINDAN1-2/+11
Testing: "NameServers": [], "NameServers@Message.ExtendedInfo": [ { "@odata.type": "/redfish/v1/$metadata#Message.v1_0_0.Message", "Message": "The property NameServers is a read only property and cannot be assigned a value.", "MessageArgs": [ "NameServers" ], "MessageId": "Base.1.4.0.PropertyNotWritable", "Resolution": "Remove the property from the request body and resubmit the request if the operation failed.", "Severity": "Warning" } ] Change-Id: I12b8cb0ad9b8ad83371ee1d834f38e7537cc7b61 Signed-off-by: RAJESWARAN THILLAIGOVINDAN <rajeswgo@in.ibm.com>
2019-04-30Redfish(Network): Implement IPv6DefaultGateway supportRavi Teja1-1/+22
Added GET support for IPv6DefaultGateway.its read only property On Patch operation display "PropertyNotWritable" message. Tested by: GET PATCH -D patch.txt -d '{"IPv6DefaultGateway": "fe80::226:88ff:feac:8401"}' Tested with validator and no errors. Change-Id: Ib67234496b70ec53508a9be36cd86c1859b5d895 Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
2019-04-26Fix empty IPV4 gateway errorGunnar Mills1-1/+8
If an IPV4 gateway is empty use "0.0.0.0". The RedfishServiceValidator throws the following error on a Witherspoon system: "IPv4Addresses[0].Gateway: String '' does not match pattern ''^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$''" Tested: Ran RedfishServiceValidator and no longer observe the error. IPV4 addresses with gateways are untouched. Change-Id: I423aeeb0bec46fa5cc0c8cf5a017c16d20314984 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>