Handle error scenarios in OEM handler
This commit updates the performInitialSetup API in OEM handler to
handle all error scenarios. With this change OEM handler will get
system config JSON in all error scenarios.
Change-Id: I3b05ed3e012a4e7605848542aeed9298743edc39
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-manager/oem-handler/ibm_handler.cpp b/vpd-manager/oem-handler/ibm_handler.cpp
index ea8bb97..250f815 100644
--- a/vpd-manager/oem-handler/ibm_handler.cpp
+++ b/vpd-manager/oem-handler/ibm_handler.cpp
@@ -570,26 +570,23 @@
{
try
{
+ if (m_worker.get() == nullptr)
+ {
+ throw std::runtime_error(
+ "Worker object not found. Can't perform initial setup.");
+ }
+
+ m_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
if (!dbusUtility::isChassisPowerOn())
{
- logging::logMessage("Chassis is in Off state.");
- if (m_worker.get() != nullptr)
- {
- m_worker->setDeviceTreeAndJson();
- // Get the system config JSON object.
- m_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
- }
- else
- {
- throw std::runtime_error(
- "Worker object not found. Can't set up device tree and Json.");
- }
- primeSystemBlueprint();
- }
- else
- {
- // get the JSON from worker.
+ m_worker->setDeviceTreeAndJson();
+
+ // Since the above function setDeviceTreeAndJson can change the json
+ // which is used, we would need to reacquire the json object again
+ // here.
m_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
+
+ primeSystemBlueprint();
}
// Enable all mux which are used for connecting to the i2c on the
@@ -600,7 +597,6 @@
// Nothing needs to be done. Service restarted or BMC re-booted for
// some reason at system power on.
- return;
}
catch (const std::exception& l_ex)
{