Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable PEL for dbus_utility file #562

Open
wants to merge 1 commit into
base: 1110
Choose a base branch
from
Open
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
41 changes: 26 additions & 15 deletions vpd-manager/include/utility/dbus_utility.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "constants.hpp"
#include "event_logger.hpp"
#include "logger.hpp"
#include "types.hpp"

Expand Down Expand Up @@ -100,7 +101,11 @@ inline types::PropertyMap getPropertyMap(const std::string& i_service,
}
catch (const sdbusplus::exception::SdBusError& l_ex)
{
logging::logMessage(l_ex.what());
EventLogger::createSyncPel(
types::ErrorType::DbusFailure, types::SeverityType::Informational,
__FILE__, __FUNCTION__, 0,
"Failed to get property map, error: " + std::string(l_ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but I think we should have default std::optional<> = std::nullopt arguments for EventLogger::createSyncPel(), EventLogger::createAsyncPel() APIs, otherwise we have to pass std::nullopt in lot of calls.

}

return l_propertyValueMap;
Expand Down Expand Up @@ -150,7 +155,11 @@ inline types::MapperGetSubTree
}
catch (const sdbusplus::exception::SdBusError& l_ex)
{
logging::logMessage(l_ex.what());
EventLogger::createSyncPel(
types::ErrorType::DbusFailure, types::SeverityType::Informational,
__FILE__, __FUNCTION__, 0,
"Failed to get object subTree, error: " + std::string(l_ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}

return l_subTreeMap;
Expand Down Expand Up @@ -323,9 +332,12 @@ inline bool isServiceRunning(const std::string& i_serviceName)
}
catch (const sdbusplus::exception::SdBusError& l_ex)
{
logging::logMessage(
EventLogger::createSyncPel(
types::ErrorType::DbusFailure, types::SeverityType::Informational,
__FILE__, __FUNCTION__, 0,
"Call to check service status failed with exception: " +
std::string(l_ex.what()));
std::string(l_ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}

return l_retVal;
Expand Down Expand Up @@ -362,11 +374,12 @@ inline types::BiosAttributeCurrentValue
}
catch (const sdbusplus::exception::SdBusError& l_ex)
{
logging::logMessage(
EventLogger::createSyncPel(
types::ErrorType::DbusFailure, types::SeverityType::Informational,
__FILE__, __FUNCTION__, 0,
"Failed to read BIOS Attribute: " + i_attributeName +
" due to error " + std::string(l_ex.what()));

// TODO: Log an informational PEL here.
" due to error " + std::string(l_ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}

return std::get<1>(l_attributeVal);
Expand Down Expand Up @@ -396,13 +409,11 @@ inline bool isChassisPowerOn()
return false;
}

/*
TODO: Add PEL.
Callout: Firmware callout
Type: Informational
Description: Chassis state can't be determined, defaulting to chassis
off. : e.what()
*/
EventLogger::createSyncPel(
types::ErrorType::DbusFailure, types::SeverityType::Informational,
__FILE__, __FUNCTION__, 0,
"Chassis state can't be determined, defaulting to chassis off.",
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
return false;
}

Expand Down