diff options
author | Harisuddin Mohamed Isa <harisuddin@gmail.com> | 2020-02-06 17:32:38 +0800 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2020-02-07 16:02:00 +0000 |
commit | e2d1bf317c0ddf25ddd305aa8f3c6f09118f799c (patch) | |
tree | de330de70c2a62ce6785bca2dae1faee0f89a50e /extensions/openpower-pels/failing_mtms.cpp | |
parent | 6fd0c1e70c1f63c44ffa69308569b1be144451ce (diff) | |
download | phosphor-logging-e2d1bf317c0ddf25ddd305aa8f3c6f09118f799c.tar.gz phosphor-logging-e2d1bf317c0ddf25ddd305aa8f3c6f09118f799c.zip |
PEL: Print Failing MTMS section into JSON
Remove any trailing whitespace for serial number.
"Failing MTMS": {
"Section Version": "1",
"Sub-section type": "0",
"Created by": "0x4552",
"Machine Type Model": "OPWR-131",
"Serial Number": "1318ABA"
},
Testing: Manually run peltool and verified output. All unit tests
passed.
Signed-off-by: Harisuddin Mohamed Isa <harisuddin@gmail.com>
Change-Id: I7a05790bdf406ef6d7946ffae831a45ee6dd5cda
Diffstat (limited to 'extensions/openpower-pels/failing_mtms.cpp')
-rw-r--r-- | extensions/openpower-pels/failing_mtms.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/extensions/openpower-pels/failing_mtms.cpp b/extensions/openpower-pels/failing_mtms.cpp index d4cdf37..b45c05d 100644 --- a/extensions/openpower-pels/failing_mtms.cpp +++ b/extensions/openpower-pels/failing_mtms.cpp @@ -15,6 +15,7 @@ */ #include "failing_mtms.hpp" +#include "json_utils.hpp" #include "pel_types.hpp" #include <phosphor-logging/log.hpp> @@ -85,5 +86,19 @@ void FailingMTMS::unflatten(Stream& stream) stream >> _header >> _mtms; } +std::optional<std::string> FailingMTMS::getJSON() const +{ + std::string json; + jsonInsert(json, "Section Version", getNumberString("%d", _header.version), + 1); + jsonInsert(json, "Sub-section type", getNumberString("%d", _header.subType), + 1); + jsonInsert(json, "Created by", getNumberString("0x%X", _header.componentID), + 1); + jsonInsert(json, "Machine Type Model", _mtms.machineTypeAndModel(), 1); + jsonInsert(json, "Serial Number", trimEnd(_mtms.machineSerialNumber()), 1); + json.erase(json.size() - 2); + return json; +} } // namespace pels } // namespace openpower |