History log of /openbmc/bmcweb/features/redfish/include/utils/json_utils.hpp (Results 51 – 74 of 74)
Revision Date Author Comments
# 2c70f800 28-Sep-2020 Ed Tanous <ed@tanous.net>

Fix naming conventions

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

Fix naming conventions

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

show more ...


# cb13a392 25-Jul-2020 Ed Tanous <ed@tanous.net>

Enable unused variable warnings and resolve

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 th

Enable unused variable warnings and resolve

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>

show more ...


# 1214b7e7 04-Jun-2020 Gunnar Mills <gmills@us.ibm.com>

clang-format: update to latest from docs repo

This is from openbmc/docs/style/cpp/.clang-format

Other OpenBMC repos are doing the same.

Tested: Built and validator passed.
Change-Id: Ief26c755c9ce

clang-format: update to latest from docs repo

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>

show more ...


# 471a5eb8 19-May-2020 AppaRao Puli <apparao.puli@linux.intel.com>

Update json helper function - readJson

The json helper functions are currently coupled
with response(crow::response) and limiting it to
use only while sending response. There are some
use cases wher

Update json helper function - readJson

The json helper functions are currently coupled
with response(crow::response) and limiting it to
use only while sending response. There are some
use cases where we don't send crow::response
instead we extract json data from files and load
configuration.

Decoupled the business logic for validating json
key existence, json value type checking and range
validation with top level use cases. So this json
helper functions can be used for validating json
and extracting value from json object during
init cases also(Ex: Used in EventService config
initialization)

Added new API in helper function which checks
key existence, value is of desired Type and
value is in acceptable range and assign value
in output parameter.

Tested:
Verified post and patch methods with different
kinds of value types( int, bool, string, vector
array, json etc..) and it works.

Change-Id: I21a6f9a12aef09f6ca79a02bc01d96efeeb3a20a
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>

show more ...


# 5eb2bef2 16-Dec-2019 AppaRao Puli <apparao.puli@linux.intel.com>

Fix: bug fixes in readJson

This commit contains bug fixes in readJson function call
1) Handled invalid double value which is leading to crash
bmcweb. If user give string for double value key, i

Fix: bug fixes in readJson

This commit contains bug fixes in readJson function call
1) Handled invalid double value which is leading to crash
bmcweb. If user give string for double value key, its
not handled in readJson which intern causes exception
and crash.
2) If any of input types of floating_point, signed or unsigned
int type values are provided with wrong type, it should
return error, instead its returning 200 success response.
Added code to return proper error response.

Tested:
- Tested invalid case by giving wrong type values in PATCH.
URI: /redfish/v1/Chassis/WC_Baseboard/Thermal
METHOD: Patch
REQUEST:
{
"Fans": [
{
"MemberId": "Fan_1a",
"Reading": "200"
}
]
}
RESPONSE:
{
"Reading@Message.ExtendedInfo": [
{
"@odata.type": "/redfish/v1/$metadata#Message.v1_0_0.Message",
"Message": "The value \"200\" for the property Reading is of a different type than the property can accept.",
"MessageArgs": [
"\"200\"",
"Reading"
],
"MessageId": "Base.1.4.0.PropertyValueTypeError",
"Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.",
"Severity": "Warning"
}
]
}

- Also performed some positive and negative tests with other URI's.
- Redfish validator ran successfully without any issue(No impact though)

Change-Id: Ie98384e67a863ab96aa537f492a686b2c7ebb3a2
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>

show more ...


# c94ad49b 10-Oct-2019 Ed Tanous <ed.tanous@intel.com>

Make references to crow less obvious

Recently, a number of people in the community have made the (admittedly
easy) mistake that we use a significant portion of crow.

Today, we use crow for the rout

Make references to crow less obvious

Recently, a number of people in the community have made the (admittedly
easy) mistake that we use a significant portion of crow.

Today, we use crow for the router, and the "app" structure, and even
those have been significantly modified to meet the bmc needs. All other
components have been replaced with Boost beast. This commit removes the
crow mentions from the Readme, and moves the crow folder to "http" to
camouflage it a little. No code content has changed.

Tested:
Code compiles. No functional change made to any executable code.

Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: Iceb57b26306cc8bdcfc77f3874246338864fd118

show more ...


# 271584ab 09-Jul-2019 Ed Tanous <ed.tanous@intel.com>

Fix a bunch of warnings

using the list of warnings from here:
https://github.com/lefticus/cppbestpractices/blob/e73393f25a85f83fed7399d8b65cb117d00b2231/02-Use_the_Tools_Available.md#L100

Seems lik

Fix a bunch of warnings

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

show more ...


# 8ebc91f6 28-Aug-2019 Ed Tanous <ed.tanous@intel.com>

Fix readJson to allow null as a complex type

Given that very few people have actually needed to unpack a null value
with readJson, it's not surprising that there are bugs there.

the simplest case t

Fix readJson to allow null as a complex type

Given that very few people have actually needed to unpack a null value
with readJson, it's not surprising that there are bugs there.

the simplest case that failed was attempting to unpack an array which
might contain null values, which should be allowed to be unpacked with a
nlohmann::json object, to allow error handling and the new delete cases,
but were rejected.

Tested:
Reran the unit test here, which succeeded.
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/23954/2

Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I50ae26645ad16f6a6228c27e6d501c08de4c622b

show more ...


# ee344e0f 08-Aug-2019 Ed Tanous <ed.tanous@intel.com>

cleanup: Move a pointer to a reference

Minor cleanup to a routine that allows us to drop one nullptr check.

Tested:
Will test shortly. Code should be no-op.

Signed-off-by: Ed Tanous <ed.tanous@in

cleanup: Move a pointer to a reference

Minor cleanup to a routine that allows us to drop one nullptr check.

Tested:
Will test shortly. Code should be no-op.

Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I592dc0a9a311d6dd885cdd6289f343dd4b9b0567

show more ...


# 41352c24 03-Jul-2019 Santosh Puranik <santosh.puranik@in.ibm.com>

Fix Regression in PATCH on system node

Commit d573bb2a regressed the PATCH operation
on the system redfish node. By initializing
result to no_content, the commit broke the subsequent
json_util::read

Fix Regression in PATCH on system node

Commit d573bb2a regressed the PATCH operation
on the system redfish node. By initializing
result to no_content, the commit broke the subsequent
json_util::readJson, which checks if the result is "ok"
at the end of the function.

This commit fixes it by making readJsonValues() and its
descendants return a bool status. readJson() no longer
relies on the response object result to indicate success/
failure.

Tested:
-- Verified that PATCH operations on the system node now work.
-- Verified PATCH operations work on manager, accountservice and
ethernetinterfaces nodes.
-- No new errors from the Redfish validator.

Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: I54080392297a8f0276161da8b48d8f9518cbdcfe

show more ...


# 8102ddba 27-Dec-2018 AppaRao Puli <apparao.puli@linux.intel.com>

Redfish: Adding bool support in readJson

Adding boolean support in json_utils.

Test:
Validated by sending redfish POST/PATCH
request with boolean value in data.

Change-Id: Iddc7daebb3507a468cbb218

Redfish: Adding bool support in readJson

Adding boolean support in json_utils.

Test:
Validated by sending redfish POST/PATCH
request with boolean value in data.

Change-Id: Iddc7daebb3507a468cbb2187806908f821bd6da7
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>

show more ...


# a6acbb31 17-Dec-2018 James Feist <james.feist@linux.intel.com>

jsonRead: Add floating point support

Add support of reading floating point numbers.

Tested-by: Successfully unpacked doubles

Change-Id: I9cf5e33dbb99367a53013be28b8f905eae2e4518
Signed-off-by: Jam

jsonRead: Add floating point support

Add support of reading floating point numbers.

Tested-by: Successfully unpacked doubles

Change-Id: I9cf5e33dbb99367a53013be28b8f905eae2e4518
Signed-off-by: James Feist <james.feist@linux.intel.com>

show more ...


# 318226c2 13-Dec-2018 James Feist <james.feist@linux.intel.com>

json_utils: readJson add array support

Add std::array support to readJson.

Change-Id: I32bb28908f195fd3443556c40b71eaabd105db25
Signed-off-by: James Feist <james.feist@linux.intel.com>


# 0627a2c7 29-Nov-2018 Ed Tanous <ed.tanous@intel.com>

bmcweb: Enable redfish unpacking of complex types

In certain cases, redfish wants to unpack specialized types that might
be more complex than just simple structs. This commit adds the ability
to un

bmcweb: Enable redfish unpacking of complex types

In certain cases, redfish wants to unpack specialized types that might
be more complex than just simple structs. This commit adds the ability
to unpack a nlohman json object directly, and moves the ethernet schema
over to the new api

Change-Id: Ib3c25e6c4d8f0a163647092adfb454355d329170
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>

show more ...


# a24526dc 10-Dec-2018 Ed Tanous <ed.tanous@intel.com>

bmcweb: Move boost::optional to std::optional

This change is largely a sed replace, and gets us closer to standards
compliance.

Change-Id: Ie60437eff43de830ef19389344a55430dabd9d16
Signed-off-by: E

bmcweb: Move boost::optional to std::optional

This change is largely a sed replace, and gets us closer to standards
compliance.

Change-Id: Ie60437eff43de830ef19389344a55430dabd9d16
Signed-off-by: Ed Tanous <ed.tanous@intel.com>

show more ...


# b1556427 16-Oct-2018 Ed Tanous <ed.tanous@intel.com>

Move Redfish PECI to the new json interface

This change adds vector handling to the new json interface
and modifies the SendRawPECI Redfish command to utilize it.

Tested: Executed raw PECI commands

Move Redfish PECI to the new json interface

This change adds vector handling to the new json interface
and modifies the SendRawPECI Redfish command to utilize it.

Tested: Executed raw PECI commands with good and bad input
to check that it will work and error out correctly.

Change-Id: Ic1c837f5823d28555f727849156b4dabf1b8acef
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>

show more ...


# 771cfa0f 06-Nov-2018 Jason M. Bills <jason.m.bills@linux.intel.com>

Add automatic range-checking and type-casting for readJson

This change allows numerical types to be passed to readJson
with the desired type. They will then be automatically
range-checked and cast

Add automatic range-checking and type-casting for readJson

This change allows numerical types to be passed to readJson
with the desired type. They will then be automatically
range-checked and cast to that type.

Tested: Requested variables of type uint64_t, uint8_t, int,
int16_t, and int8_t and confirmed that the range was correctly
checked for each.

Change-Id: Ia55cb03ba2c4321a7de35a7c7b566980a72c5449
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>

show more ...


# a08b46cc 06-Nov-2018 Jason M. Bills <jason.m.bills@linux.intel.com>

Simplify Redfish error message property interface

The error message code used a json_pointer object which must
begin with a '/' character and had to be sent as an extra
parameter. This change simpl

Simplify Redfish error message property interface

The error message code used a json_pointer object which must
begin with a '/' character and had to be sent as an extra
parameter. This change simplifies the interface by using a
string so there doesn't have to be a '/'. This allowed the
same property argument passed for the message to be used
for the property field path.

Tested: Sent an error with a property and verified that it is
correctly displayed.

Change-Id: I0571e2eee627cedf29d751588a4f1bceee66f084
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>

show more ...


# a282ac4d 26-Oct-2018 Ed Tanous <ed.tanous@intel.com>

Fix a bug in optional json parsing

A small logic error caused bugs in the required-ness of optional params.
In the error case, a bad_request return code would be returned with no
error message. Thi

Fix a bug in optional json parsing

A small logic error caused bugs in the required-ness of optional params.
In the error case, a bad_request return code would be returned with no
error message. This commit allows the request to suceed unharmed.

Change-Id: I1c1cbaf08e79bc1f52485ae12d73701d74e0e2aa
Signed-off-by: Ed Tanous <ed.tanous@intel.com>

show more ...


# f12894f8 09-Oct-2018 Jason M. Bills <jason.m.bills@linux.intel.com>

Improve the Redfish error reporting interface

Makes the Redfish error reporting interface automatically handle
setting the http status and JSON content in the response object.

When using an AsyncRe

Improve the Redfish error reporting interface

Makes the Redfish error reporting interface automatically handle
setting the http status and JSON content in the response object.

When using an AsyncResp object, this allows for simply calling
the Redfish error and returning.

Change-Id: Icfdce2de763225f070e8dd61e591f296703f46bb
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>

show more ...


# 9712f8ac 21-Sep-2018 Ed Tanous <ed.tanous@intel.com>

Implement a new way of unpacking json to structs

The existing way of decoding json structures, while fast has some disadvantages.
1. it's very verbose to write.
2. It requires in depth knowlege of r

Implement a new way of unpacking json to structs

The existing way of decoding json structures, while fast has some disadvantages.
1. it's very verbose to write.
2. It requires in depth knowlege of redfish error messages to get
correct.
3. It _can_ lead to undesired behavior, like half of a patch being
applied, if only some of the values have bad types.

This commit implements a new interface for decoding redfish json
named.... readJson. It is a templated function, that lets you decode
json values based on type easily, while still handling all the correct
error codes that were handled previously. Use is done similar to the
example below:

std::string required;
boost::optional<std::string> optional;
if (!json_util::readJson(req, res, "OptionalParam", optional,
"RequiredParam", required))
{
return;
}

if (optional){
// optional param was given, take action.
}

As part of this patchset, the systems schema is moved to the new
interface, which deletes some of the code involved and shows the
improvement in clarity.

Change-Id: I041a97c84d294df8cd4de4c2702e5ee22c0bc120
Signed-off-by: Ed Tanous <ed.tanous@intel.com>

show more ...


# 1abe55ef 05-Sep-2018 Ed Tanous <ed.tanous@intel.com>

Move to clang-format-6.0

This commit moves the codebase to the lastest clang-format file from
upstream, as well as clang-format-6.0.

Change-Id: Ice8313468097c0c42317fbb9e10ddf036e8cff4c
Signed-off-

Move to clang-format-6.0

This commit moves the codebase to the lastest clang-format file from
upstream, as well as clang-format-6.0.

Change-Id: Ice8313468097c0c42317fbb9e10ddf036e8cff4c
Signed-off-by: Ed Tanous <ed.tanous@intel.com>

show more ...


# 55c7b7a2 22-May-2018 Ed Tanous <ed.tanous@intel.com>

Move over to upstream c++ style

This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.

This

Move over to upstream c++ style

This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.

This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables. At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.

Tested: Code still compiles, and appears to run, although other issues
are possible and likely.

Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>

show more ...


# 77dd8813 03-Apr-2018 Kowalski, Kamil <kamil.kowalski@intel.com>

Added JSON utilities to allow easy exception-less usage of nlohmann JSON.

These functions are not yet used, but will be required by at least two upcoming
patchsets. This functionality has been cut o

Added JSON utilities to allow easy exception-less usage of nlohmann JSON.

These functions are not yet used, but will be required by at least two upcoming
patchsets. This functionality has been cut out from Configuration patchset for
easier merge without having to wait for that commit.

Change-Id: Ibe5d5cefd874d4a2d896b42a2b7cfc17480f3c5a
Signed-off-by: Kowalski, Kamil <kamil.kowalski@intel.com>

show more ...


123