1 Star 0 Fork 0

openbmc/openpower-vpd-parser

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
common_utility.cpp 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
#include "common_utility.hpp"
#include "const.hpp"
#include <iostream>
#include <phosphor-logging/log.hpp>
namespace openpower
{
namespace vpd
{
namespace common
{
namespace utility
{
using namespace constants;
using namespace inventory;
using namespace phosphor::logging;
std::string getService(sdbusplus::bus_t& bus, const std::string& path,
const std::string& interface)
{
auto mapper = bus.new_method_call(mapperDestination, mapperObjectPath,
mapperInterface, "GetObject");
mapper.append(path, std::vector<std::string>({interface}));
std::map<std::string, std::vector<std::string>> response;
try
{
auto reply = bus.call(mapper);
reply.read(response);
}
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>("D-Bus call exception",
entry("OBJPATH=%s", mapperObjectPath),
entry("INTERFACE=%s", mapperInterface),
entry("EXCEPTION=%s", e.what()));
throw std::runtime_error("Service name is not found");
}
if (response.empty())
{
throw std::runtime_error("Service name response is empty");
}
return response.begin()->first;
}
void callPIM(ObjectMap&& objects)
{
try
{
auto bus = sdbusplus::bus::new_default();
auto service = getService(bus, pimPath, pimIntf);
auto pimMsg =
bus.new_method_call(service.c_str(), pimPath, pimIntf, "Notify");
pimMsg.append(std::move(objects));
auto result = bus.call(pimMsg);
if (result.is_method_error())
{
std::cerr << "PIM Notify() failed\n";
}
}
catch (const std::runtime_error& e)
{
log<level::ERR>(e.what());
}
}
} // namespace utility
} // namespace common
} // namespace vpd
} // namespace openpower
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openbmc_masterhu/openpower-vpd-parser.git
git@gitee.com:openbmc_masterhu/openpower-vpd-parser.git
openbmc_masterhu
openpower-vpd-parser
openpower-vpd-parser
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385