blob: fd7b03be479876d1c747b2fe99319ea51793da8d [file] [log] [blame]
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05001#include "backup_restore.hpp"
2
3#include "constants.hpp"
4#include "event_logger.hpp"
5#include "exceptions.hpp"
6#include "logger.hpp"
7#include "parser.hpp"
8#include "types.hpp"
9
10#include <utility/json_utility.hpp>
11#include <utility/vpd_specific_utility.hpp>
12
13namespace vpd
14{
15BackupAndRestoreStatus BackupAndRestore::m_backupAndRestoreStatus =
16 BackupAndRestoreStatus::NotStarted;
17
18BackupAndRestore::BackupAndRestore(const nlohmann::json& i_sysCfgJsonObj) :
19 m_sysCfgJsonObj(i_sysCfgJsonObj)
20{
21 std::string l_backupAndRestoreCfgFilePath =
22 i_sysCfgJsonObj.value("backupRestoreConfigPath", "");
RekhaAparna011ef21002025-02-18 23:47:36 -060023
Rekha Aparnaca9a0862025-08-29 04:08:33 -050024 uint16_t l_errCode = 0;
RekhaAparna011ef21002025-02-18 23:47:36 -060025 m_backupAndRestoreCfgJsonObj =
Rekha Aparnaca9a0862025-08-29 04:08:33 -050026 jsonUtility::getParsedJson(l_backupAndRestoreCfgFilePath, l_errCode);
RekhaAparna011ef21002025-02-18 23:47:36 -060027
Rekha Aparnaca9a0862025-08-29 04:08:33 -050028 if (l_errCode)
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050029 {
Rekha Aparnaca9a0862025-08-29 04:08:33 -050030 throw JsonException(
31 "JSON parsing failed for file [" + l_backupAndRestoreCfgFilePath +
32 "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode),
33 l_backupAndRestoreCfgFilePath);
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050034 }
35}
36
37std::tuple<types::VPDMapVariant, types::VPDMapVariant>
38 BackupAndRestore::backupAndRestore()
39{
40 auto l_emptyVariantPair =
41 std::make_tuple(std::monostate{}, std::monostate{});
42
43 if (m_backupAndRestoreStatus >= BackupAndRestoreStatus::Invoked)
44 {
45 logging::logMessage("Backup and restore invoked already.");
46 return l_emptyVariantPair;
47 }
48
49 m_backupAndRestoreStatus = BackupAndRestoreStatus::Invoked;
50 try
51 {
52 if (m_backupAndRestoreCfgJsonObj.empty() ||
53 !m_backupAndRestoreCfgJsonObj.contains("source") ||
54 !m_backupAndRestoreCfgJsonObj.contains("destination") ||
55 !m_backupAndRestoreCfgJsonObj.contains("type") ||
56 !m_backupAndRestoreCfgJsonObj.contains("backupMap"))
57 {
58 logging::logMessage(
59 "Backup restore config JSON is missing necessary tag(s), can't initiate backup and restore.");
60 return l_emptyVariantPair;
61 }
62
63 std::string l_srcVpdPath;
64 types::VPDMapVariant l_srcVpdVariant;
65 if (l_srcVpdPath = m_backupAndRestoreCfgJsonObj["source"].value(
66 "hardwarePath", "");
67 !l_srcVpdPath.empty() && std::filesystem::exists(l_srcVpdPath))
68 {
69 std::shared_ptr<Parser> l_vpdParser =
70 std::make_shared<Parser>(l_srcVpdPath, m_sysCfgJsonObj);
71 l_srcVpdVariant = l_vpdParser->parse();
72 }
73 else if (l_srcVpdPath = m_backupAndRestoreCfgJsonObj["source"].value(
74 "inventoryPath", "");
75 l_srcVpdPath.empty())
76 {
77 logging::logMessage(
78 "Couldn't extract source path, can't initiate backup and restore.");
79 return l_emptyVariantPair;
80 }
81
82 std::string l_dstVpdPath;
83 types::VPDMapVariant l_dstVpdVariant;
84 if (l_dstVpdPath = m_backupAndRestoreCfgJsonObj["destination"].value(
85 "hardwarePath", "");
86 !l_dstVpdPath.empty() && std::filesystem::exists(l_dstVpdPath))
87 {
88 std::shared_ptr<Parser> l_vpdParser =
89 std::make_shared<Parser>(l_dstVpdPath, m_sysCfgJsonObj);
90 l_dstVpdVariant = l_vpdParser->parse();
91 }
92 else if (l_dstVpdPath = m_backupAndRestoreCfgJsonObj["destination"]
93 .value("inventoryPath", "");
94 l_dstVpdPath.empty())
95 {
96 logging::logMessage(
97 "Couldn't extract destination path, can't initiate backup and restore.");
98 return l_emptyVariantPair;
99 }
100
101 // Implement backup and restore for IPZ type VPD
102 auto l_backupAndRestoreType =
103 m_backupAndRestoreCfgJsonObj.value("type", "");
104 if (l_backupAndRestoreType.compare("IPZ") == constants::STR_CMP_SUCCESS)
105 {
106 types::IPZVpdMap l_srcVpdMap;
107 if (auto l_srcVpdPtr =
108 std::get_if<types::IPZVpdMap>(&l_srcVpdVariant))
109 {
110 l_srcVpdMap = *l_srcVpdPtr;
111 }
112 else if (!std::holds_alternative<std::monostate>(l_srcVpdVariant))
113 {
114 logging::logMessage("Source VPD is not of IPZ type.");
115 return l_emptyVariantPair;
116 }
117
118 types::IPZVpdMap l_dstVpdMap;
119 if (auto l_dstVpdPtr =
120 std::get_if<types::IPZVpdMap>(&l_dstVpdVariant))
121 {
122 l_dstVpdMap = *l_dstVpdPtr;
123 }
124 else if (!std::holds_alternative<std::monostate>(l_dstVpdVariant))
125 {
126 logging::logMessage("Destination VPD is not of IPZ type.");
127 return l_emptyVariantPair;
128 }
129
130 backupAndRestoreIpzVpd(l_srcVpdMap, l_dstVpdMap, l_srcVpdPath,
131 l_dstVpdPath);
132 m_backupAndRestoreStatus = BackupAndRestoreStatus::Completed;
133
134 return std::make_tuple(l_srcVpdMap, l_dstVpdMap);
135 }
136 // Note: add implementation here to support any other VPD type.
137 }
138 catch (const std::exception& ex)
139 {
140 logging::logMessage("Back up and restore failed with exception: " +
141 std::string(ex.what()));
142 }
143 return l_emptyVariantPair;
144}
145
146void BackupAndRestore::backupAndRestoreIpzVpd(
147 types::IPZVpdMap& io_srcVpdMap, types::IPZVpdMap& io_dstVpdMap,
148 const std::string& i_srcPath, const std::string& i_dstPath)
149{
150 if (!m_backupAndRestoreCfgJsonObj["backupMap"].is_array())
151 {
152 logging::logMessage(
153 "Invalid value found for tag backupMap, in backup and restore config JSON.");
154 return;
155 }
156
Rekha Aparna0578dd22025-09-02 08:20:21 -0500157 uint16_t l_errCode = 0;
158
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500159 const std::string l_srcFruPath =
Rekha Aparna0578dd22025-09-02 08:20:21 -0500160 jsonUtility::getFruPathFromJson(m_sysCfgJsonObj, i_srcPath, l_errCode);
161
162 if (l_errCode)
163 {
164 logging::logMessage(
165 "Failed to get source FRU path for [" + i_srcPath +
166 "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
167 return;
168 }
169
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500170 const std::string l_dstFruPath =
Rekha Aparna0578dd22025-09-02 08:20:21 -0500171 jsonUtility::getFruPathFromJson(m_sysCfgJsonObj, i_dstPath, l_errCode);
172
173 if (l_errCode)
174 {
175 logging::logMessage(
176 "Failed to get destination FRU path for [" + i_dstPath +
177 "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
178 return;
179 }
180
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500181 if (l_srcFruPath.empty() || l_dstFruPath.empty())
182 {
183 logging::logMessage(
184 "Couldn't find either source or destination FRU path.");
185 return;
186 }
187
Rekha Aparna017567a2025-08-13 02:07:06 -0500188 const std::string l_srcInvPath = jsonUtility::getInventoryObjPathFromJson(
189 m_sysCfgJsonObj, i_srcPath, l_errCode);
190
191 if (l_srcInvPath.empty())
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500192 {
Rekha Aparna017567a2025-08-13 02:07:06 -0500193 if (l_errCode)
194 {
195 logging::logMessage(
196 "Couldn't find source inventory path. Error : " +
197 vpdSpecificUtility::getErrCodeMsg(l_errCode));
198 return;
199 }
200
201 logging::logMessage("Couldn't find source inventory path.");
202 return;
203 }
204
205 const std::string l_dstInvPath = jsonUtility::getInventoryObjPathFromJson(
206 m_sysCfgJsonObj, i_dstPath, l_errCode);
207
208 if (l_dstInvPath.empty())
209 {
210 if (l_errCode)
211 {
212 logging::logMessage(
213 "Couldn't find destination inventory path. Error : " +
214 vpdSpecificUtility::getErrCodeMsg(l_errCode));
215 return;
216 }
217
218 logging::logMessage("Couldn't find destination inventory path.");
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500219 return;
220 }
221
222 const std::string l_srcServiceName =
Rekha Aparnae0d24c02025-09-02 00:15:06 -0500223 jsonUtility::getServiceName(m_sysCfgJsonObj, l_srcInvPath, l_errCode);
224
225 if (l_errCode)
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500226 {
227 logging::logMessage(
Rekha Aparnae0d24c02025-09-02 00:15:06 -0500228 "Failed to get service name for source FRU [" + l_srcInvPath +
229 "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
230 return;
231 }
232
233 const std::string l_dstServiceName =
234 jsonUtility::getServiceName(m_sysCfgJsonObj, l_dstInvPath, l_errCode);
235
236 if (l_errCode)
237 {
238 logging::logMessage(
239 "Failed to get service name for destination FRU [" + l_dstInvPath +
240 "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500241 return;
242 }
243
244 for (const auto& l_aRecordKwInfo :
245 m_backupAndRestoreCfgJsonObj["backupMap"])
246 {
247 const std::string& l_srcRecordName =
248 l_aRecordKwInfo.value("sourceRecord", "");
249 const std::string& l_srcKeywordName =
250 l_aRecordKwInfo.value("sourceKeyword", "");
251 const std::string& l_dstRecordName =
252 l_aRecordKwInfo.value("destinationRecord", "");
253 const std::string& l_dstKeywordName =
254 l_aRecordKwInfo.value("destinationKeyword", "");
255
256 if (l_srcRecordName.empty() || l_dstRecordName.empty() ||
257 l_srcKeywordName.empty() || l_dstKeywordName.empty())
258 {
259 logging::logMessage(
260 "Record or keyword not found in the backup and restore config JSON.");
261 continue;
262 }
263
264 if (!io_srcVpdMap.empty() &&
265 io_srcVpdMap.find(l_srcRecordName) == io_srcVpdMap.end())
266 {
267 logging::logMessage(
268 "Record: " + l_srcRecordName +
269 ", is not found in the source path: " + i_srcPath);
270 continue;
271 }
272
273 if (!io_dstVpdMap.empty() &&
274 io_dstVpdMap.find(l_dstRecordName) == io_dstVpdMap.end())
275 {
276 logging::logMessage(
277 "Record: " + l_dstRecordName +
278 ", is not found in the destination path: " + i_dstPath);
279 continue;
280 }
281
282 types::BinaryVector l_defaultBinaryValue;
283 if (l_aRecordKwInfo.contains("defaultValue") &&
284 l_aRecordKwInfo["defaultValue"].is_array())
285 {
286 l_defaultBinaryValue =
287 l_aRecordKwInfo["defaultValue"].get<types::BinaryVector>();
288 }
289 else
290 {
291 logging::logMessage(
292 "Couldn't read default value for record name: " +
293 l_srcRecordName + ", keyword name: " + l_srcKeywordName +
294 " from backup and restore config JSON file.");
295 continue;
296 }
297
298 bool l_isPelRequired = l_aRecordKwInfo.value("isPelRequired", false);
299
300 types::BinaryVector l_srcBinaryValue;
301 std::string l_srcStrValue;
302 if (!io_srcVpdMap.empty())
303 {
Souvik Roya55fcca2025-02-19 01:33:58 -0600304 l_srcStrValue = vpdSpecificUtility::getKwVal(
305 io_srcVpdMap.at(l_srcRecordName), l_srcKeywordName);
306
307 if (l_srcStrValue.empty())
308 {
309 std::runtime_error(
310 std::string("Failed to get value for keyword [") +
311 l_srcKeywordName + std::string("]"));
312 }
313
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500314 l_srcBinaryValue =
315 types::BinaryVector(l_srcStrValue.begin(), l_srcStrValue.end());
316 }
317 else
318 {
319 // Read keyword value from DBus
320 const auto l_value = dbusUtility::readDbusProperty(
321 l_srcServiceName, l_srcInvPath,
322 constants::ipzVpdInf + l_srcRecordName, l_srcKeywordName);
323 if (const auto l_binaryValue =
324 std::get_if<types::BinaryVector>(&l_value))
325 {
326 l_srcBinaryValue = *l_binaryValue;
327 l_srcStrValue = std::string(l_srcBinaryValue.begin(),
328 l_srcBinaryValue.end());
329 }
330 }
331
332 types::BinaryVector l_dstBinaryValue;
333 std::string l_dstStrValue;
334 if (!io_dstVpdMap.empty())
335 {
Souvik Roya55fcca2025-02-19 01:33:58 -0600336 l_dstStrValue = vpdSpecificUtility::getKwVal(
337 io_dstVpdMap.at(l_dstRecordName), l_dstKeywordName);
338
339 if (l_dstStrValue.empty())
340 {
341 std::runtime_error(
342 std::string("Failed to get value for keyword [") +
343 l_dstKeywordName + std::string("]"));
344 }
345
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500346 l_dstBinaryValue =
347 types::BinaryVector(l_dstStrValue.begin(), l_dstStrValue.end());
348 }
349 else
350 {
351 // Read keyword value from DBus
352 const auto l_value = dbusUtility::readDbusProperty(
353 l_dstServiceName, l_dstInvPath,
354 constants::ipzVpdInf + l_dstRecordName, l_dstKeywordName);
355 if (const auto l_binaryValue =
356 std::get_if<types::BinaryVector>(&l_value))
357 {
358 l_dstBinaryValue = *l_binaryValue;
359 l_dstStrValue = std::string(l_dstBinaryValue.begin(),
360 l_dstBinaryValue.end());
361 }
362 }
363
364 if (l_srcBinaryValue != l_dstBinaryValue)
365 {
366 // ToDo: Handle if there is no valid default value in the backup and
367 // restore config JSON.
368 if (l_dstBinaryValue == l_defaultBinaryValue)
369 {
370 // Update keyword's value on hardware
371 auto l_vpdParser =
372 std::make_shared<Parser>(l_dstFruPath, m_sysCfgJsonObj);
373
374 auto l_bytesUpdatedOnHardware = l_vpdParser->updateVpdKeyword(
375 types::IpzData(l_dstRecordName, l_dstKeywordName,
376 l_srcBinaryValue));
377
378 /* To keep the data in sync between hardware and parsed map
379 updating the io_dstVpdMap. This should only be done if write
380 on hardware returns success.*/
381 if (!io_dstVpdMap.empty() && l_bytesUpdatedOnHardware > 0)
382 {
383 io_dstVpdMap[l_dstRecordName][l_dstKeywordName] =
384 l_srcStrValue;
385 }
386 continue;
387 }
388
389 if (l_srcBinaryValue == l_defaultBinaryValue)
390 {
391 // Update keyword's value on hardware
392 auto l_vpdParser =
393 std::make_shared<Parser>(l_srcFruPath, m_sysCfgJsonObj);
394
395 auto l_bytesUpdatedOnHardware = l_vpdParser->updateVpdKeyword(
396 types::IpzData(l_srcRecordName, l_srcKeywordName,
397 l_dstBinaryValue));
398
399 /* To keep the data in sync between hardware and parsed map
400 updating the io_srcVpdMap. This should only be done if write
401 on hardware returns success.*/
402 if (!io_srcVpdMap.empty() && l_bytesUpdatedOnHardware > 0)
403 {
404 io_srcVpdMap[l_srcRecordName][l_srcKeywordName] =
405 l_dstStrValue;
406 }
407 }
408 else
409 {
410 /**
411 * Update io_srcVpdMap to publish the same data on DBus, which
412 * is already present on the DBus. Because after calling
413 * backupAndRestore API the map value will get published to DBus
414 * in the worker flow.
415 */
416 if (!io_srcVpdMap.empty() && io_dstVpdMap.empty())
417 {
418 io_srcVpdMap[l_srcRecordName][l_srcKeywordName] =
419 l_dstStrValue;
420 }
421
422 std::string l_errorMsg(
423 "Mismatch found between source and destination VPD for record : " +
424 l_srcRecordName + " and keyword : " + l_srcKeywordName +
Anupama B R6f142832025-04-11 04:17:49 -0500425 " . Value read from source : " +
426 commonUtility::convertByteVectorToHex(l_srcBinaryValue) +
427 " . Value read from destination : " +
428 commonUtility::convertByteVectorToHex(l_dstBinaryValue));
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500429
430 EventLogger::createSyncPel(
431 types::ErrorType::VpdMismatch, types::SeverityType::Warning,
432 __FILE__, __FUNCTION__, 0, l_errorMsg, std::nullopt,
433 std::nullopt, std::nullopt, std::nullopt);
434 }
435 }
436 else if (l_srcBinaryValue == l_defaultBinaryValue &&
437 l_dstBinaryValue == l_defaultBinaryValue && l_isPelRequired)
438 {
439 std::string l_errorMsg(
440 "Default value found on both source and destination VPD, for record: " +
441 l_srcRecordName + " and keyword: " + l_srcKeywordName);
442
443 EventLogger::createSyncPel(
444 types::ErrorType::DefaultValue, types::SeverityType::Error,
445 __FILE__, __FUNCTION__, 0, l_errorMsg, std::nullopt,
446 std::nullopt, std::nullopt, std::nullopt);
447 }
448 }
449}
450
451void BackupAndRestore::setBackupAndRestoreStatus(
452 const BackupAndRestoreStatus& i_status)
453{
454 m_backupAndRestoreStatus = i_status;
455}
Anupama B R8dedd1e2025-03-24 07:43:47 -0500456
457int BackupAndRestore::updateKeywordOnPrimaryOrBackupPath(
458 const std::string& i_fruPath,
Anupama B R7b293cd2025-03-28 05:35:01 -0500459 const types::WriteVpdParams& i_paramsToWriteData) const noexcept
Anupama B R8dedd1e2025-03-24 07:43:47 -0500460{
461 if (i_fruPath.empty())
462 {
463 logging::logMessage("Given FRU path is empty.");
464 return constants::FAILURE;
465 }
466
Anupama B Rd966f272025-07-21 02:40:16 -0500467 bool l_inputPathIsSourcePath = false;
468 bool l_inputPathIsDestinationPath = false;
Anupama B R7b293cd2025-03-28 05:35:01 -0500469
Anupama B R8dedd1e2025-03-24 07:43:47 -0500470 if (m_backupAndRestoreCfgJsonObj.contains("source") &&
471 m_backupAndRestoreCfgJsonObj["source"].value("hardwarePath", "") ==
472 i_fruPath &&
473 m_backupAndRestoreCfgJsonObj.contains("destination") &&
474 !m_backupAndRestoreCfgJsonObj["destination"]
475 .value("hardwarePath", "")
476 .empty())
477 {
Anupama B Rd966f272025-07-21 02:40:16 -0500478 l_inputPathIsSourcePath = true;
Anupama B R8dedd1e2025-03-24 07:43:47 -0500479 }
480 else if (m_backupAndRestoreCfgJsonObj.contains("destination") &&
481 m_backupAndRestoreCfgJsonObj["destination"].value(
482 "hardwarePath", "") == i_fruPath &&
483 m_backupAndRestoreCfgJsonObj.contains("source") &&
484 !m_backupAndRestoreCfgJsonObj["source"]
485 .value("hardwarePath", "")
486 .empty())
487 {
Anupama B Rd966f272025-07-21 02:40:16 -0500488 l_inputPathIsDestinationPath = true;
Anupama B R7b293cd2025-03-28 05:35:01 -0500489 }
490 else
491 {
492 // Input path is neither source or destination path of the
Anupama B Rd966f272025-07-21 02:40:16 -0500493 // backup&restore JSON or source and destination paths are not hardware
494 // paths in the config JSON.
Anupama B R7b293cd2025-03-28 05:35:01 -0500495 return constants::SUCCESS;
Anupama B R8dedd1e2025-03-24 07:43:47 -0500496 }
497
Anupama B Rd966f272025-07-21 02:40:16 -0500498 if (m_backupAndRestoreCfgJsonObj["backupMap"].is_array())
Anupama B R7b293cd2025-03-28 05:35:01 -0500499 {
500 std::string l_inpRecordName;
501 std::string l_inpKeywordName;
Anupama B Rd966f272025-07-21 02:40:16 -0500502 types::BinaryVector l_inpKeywordValue;
Anupama B R7b293cd2025-03-28 05:35:01 -0500503
504 if (const types::IpzData* l_ipzData =
505 std::get_if<types::IpzData>(&i_paramsToWriteData))
506 {
507 l_inpRecordName = std::get<0>(*l_ipzData);
508 l_inpKeywordName = std::get<1>(*l_ipzData);
Anupama B Rd966f272025-07-21 02:40:16 -0500509 l_inpKeywordValue = std::get<2>(*l_ipzData);
Anupama B R7b293cd2025-03-28 05:35:01 -0500510
511 if (l_inpRecordName.empty() || l_inpKeywordName.empty() ||
Anupama B Rd966f272025-07-21 02:40:16 -0500512 l_inpKeywordValue.empty())
Anupama B R7b293cd2025-03-28 05:35:01 -0500513 {
514 logging::logMessage("Invalid input received");
515 return constants::FAILURE;
516 }
517 }
518 else
519 {
520 // only IPZ type VPD is supported now.
521 return constants::SUCCESS;
522 }
523
524 for (const auto& l_aRecordKwInfo :
525 m_backupAndRestoreCfgJsonObj["backupMap"])
526 {
527 if (l_aRecordKwInfo.value("sourceRecord", "").empty() ||
528 l_aRecordKwInfo.value("sourceKeyword", "").empty() ||
529 l_aRecordKwInfo.value("destinationRecord", "").empty() ||
530 l_aRecordKwInfo.value("destinationKeyword", "").empty())
531 {
532 // invalid backup map found
533 logging::logMessage(
534 "Invalid backup map found, one or more field(s) found empty or not present in the config JSON: sourceRecord: " +
535 l_aRecordKwInfo.value("sourceRecord", "") +
536 ", sourceKeyword: " +
537 l_aRecordKwInfo.value("sourceKeyword", "") +
538 ", destinationRecord: " +
539 l_aRecordKwInfo.value("destinationRecord", "") +
540 ", destinationKeyword: " +
541 l_aRecordKwInfo.value("destinationKeyword", ""));
542 continue;
543 }
544
Anupama B Rd966f272025-07-21 02:40:16 -0500545 if (l_inputPathIsSourcePath &&
Anupama B R7b293cd2025-03-28 05:35:01 -0500546 (l_aRecordKwInfo["sourceRecord"] == l_inpRecordName) &&
547 (l_aRecordKwInfo["sourceKeyword"] == l_inpKeywordName))
548 {
549 std::string l_fruPath(
550 m_backupAndRestoreCfgJsonObj["destination"]
551 ["hardwarePath"]);
552 Parser l_parserObj(l_fruPath, m_sysCfgJsonObj);
553
554 return l_parserObj.updateVpdKeyword(std::make_tuple(
555 l_aRecordKwInfo["destinationRecord"],
Anupama B Rd966f272025-07-21 02:40:16 -0500556 l_aRecordKwInfo["destinationKeyword"], l_inpKeywordValue));
Anupama B R7b293cd2025-03-28 05:35:01 -0500557 }
Anupama B Rd966f272025-07-21 02:40:16 -0500558 else if (l_inputPathIsDestinationPath &&
Anupama B R7b293cd2025-03-28 05:35:01 -0500559 (l_aRecordKwInfo["destinationRecord"] ==
560 l_inpRecordName) &&
561 (l_aRecordKwInfo["destinationKeyword"] ==
562 l_inpKeywordName))
563 {
564 std::string l_fruPath(
565 m_backupAndRestoreCfgJsonObj["source"]["hardwarePath"]);
566 Parser l_parserObj(l_fruPath, m_sysCfgJsonObj);
567
568 return l_parserObj.updateVpdKeyword(std::make_tuple(
569 l_aRecordKwInfo["sourceRecord"],
Anupama B Rd966f272025-07-21 02:40:16 -0500570 l_aRecordKwInfo["sourceKeyword"], l_inpKeywordValue));
Anupama B R7b293cd2025-03-28 05:35:01 -0500571 }
572 }
573 }
574
575 // Received property is not part of backup & restore JSON.
Anupama B R8dedd1e2025-03-24 07:43:47 -0500576 return constants::SUCCESS;
577}
578
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500579} // namespace vpd