Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vpd-manager/include/worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,5 +568,7 @@ class Worker

// List of EEPROM paths for which VPD collection thread creation has failed.
std::forward_list<std::string> m_failedEepromPaths;

std::shared_ptr<BackupAndRestore> m_backupAndRestoreObj;
};
} // namespace vpd
17 changes: 17 additions & 0 deletions vpd-manager/src/backup_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,21 @@ void BackupAndRestore::setBackupAndRestoreStatus(
{
m_backupAndRestoreStatus = i_status;
}

int BackupAndRestore::perfromIndividualBackupRestore(
const types::Path i_Path, const types::WriteVpdParams i_paramsToWriteData)
{
// check if path qualifies for back up and restore
if (!/*qualifies for B&R*/)
{
return 0;
}

// perform back up or restore based on the path
if (/*B&R is successful*/)
{
return 1;
}
return -1;
}
} // namespace vpd
27 changes: 21 additions & 6 deletions vpd-manager/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ Manager::Manager(
m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT);
}

if (!m_worker->getSysCfgJsonObj().empty() &&
jsonUtility::isBackupAndRestoreRequired(l_sysCfgJsonObj))
{
m_backupAndRestoreObj = std::make_shared<BackupAndRestore>(
m_worker->getSysCfgJsonObj());
}

// Set up minimal things that is needed before bus name is claimed.
m_worker->performInitialSetup();

Expand Down Expand Up @@ -294,12 +301,9 @@ void Manager::SetTimerToDetectVpdCollectionStatus()
m_interface->set_property("CollectionStatus",
std::string("Completed"));

const nlohmann::json& l_sysCfgJsonObj =
m_worker->getSysCfgJsonObj();
if (jsonUtility::isBackupAndRestoreRequired(l_sysCfgJsonObj))
if (m_backupAndRestoreObj)
{
BackupAndRestore l_backupAndRestoreObj(l_sysCfgJsonObj);
l_backupAndRestoreObj.backupAndRestore();
m_backupAndRestoreObj->backupAndRestore();
}
}
else
Expand Down Expand Up @@ -540,7 +544,18 @@ int Manager::updateKeyword(const types::Path i_vpdPath,
{
std::shared_ptr<Parser> l_parserObj =
std::make_shared<Parser>(l_fruPath, l_sysCfgJsonObj);
return l_parserObj->updateVpdKeyword(i_paramsToWriteData);
int l_rc = l_parserObj->updateVpdKeyword(i_paramsToWriteData);

if (l_rc > constants::VALUE_0 && m_backupRestoreObj)
{
if (m_backupRestoreObj->perfromIndividualBackupRestore(
l_fruPath, i_paramsToWriteData) < 0)
{
// write passed but back up and restore failed;
}
}

return l_rc;
}
catch (const std::exception& l_exception)
{
Expand Down