From 3830b9736fbcd172b710d87c0688d97dc2807e2a Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Fri, 6 Aug 2021 13:09:20 +0200 Subject: [PATCH] [sairedis] Add comment api to recorder (#883) Use new api to record hardware info when creating switch for easy read. Since hardware info attribute type is s8list, it will be serialized as array of integers, so to actually improve readability of actual value, put it as comment in recording file. --- lib/inc/Recorder.h | 3 +++ lib/src/Recorder.cpp | 8 ++++++++ lib/src/RedisRemoteSaiInterface.cpp | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/lib/inc/Recorder.h b/lib/inc/Recorder.h index 85fcd8c01d25..627e356c06e6 100644 --- a/lib/inc/Recorder.h +++ b/lib/inc/Recorder.h @@ -379,6 +379,9 @@ namespace sairedis void requestLogRotate(); + void recordComment( + _In_ const std::string& comment); + public: // static helper functions static std::string getTimestamp(); diff --git a/lib/src/Recorder.cpp b/lib/src/Recorder.cpp index 5ecfe59b6828..791c972cc5d4 100644 --- a/lib/src/Recorder.cpp +++ b/lib/src/Recorder.cpp @@ -1153,3 +1153,11 @@ void Recorder::recordBulkGenericResponse( recordLine("E|" + sai_serialize_status(status) + "|" + statuses); } } + +void Recorder::recordComment( + _In_ const std::string& comment) +{ + SWSS_LOG_ENTER(); + + recordLine("#|" + comment); +} diff --git a/lib/src/RedisRemoteSaiInterface.cpp b/lib/src/RedisRemoteSaiInterface.cpp index 919f80d25526..ea2afba36573 100644 --- a/lib/src/RedisRemoteSaiInterface.cpp +++ b/lib/src/RedisRemoteSaiInterface.cpp @@ -194,6 +194,11 @@ sai_status_t RedisRemoteSaiInterface::create( auto hwinfo = getHardwareInfo(attr_count, attr_list); + if (hwinfo.size()) + { + m_recorder->recordComment("SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO=" + hwinfo); + } + switchId = m_virtualObjectIdManager->allocateNewSwitchObjectId(hwinfo); *objectId = switchId;