forked from ibm-openbmc/phosphor-led-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathibm-sai.cpp
73 lines (63 loc) · 1.94 KB
/
ibm-sai.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "ibm-sai.hpp"
#include "utils.hpp"
#include <phosphor-logging/lg2.hpp>
#include <iostream>
namespace phosphor
{
namespace led
{
namespace ibm
{
// Set OperationalStatus functional according to the asserted state of the group
void setOperationalStatus(const std::string& path, bool value)
{
if (path != PARTITION_SAI && path != PLATFORM_SAI)
{
return;
}
// Get endpoints from the rType
std::string fru = path + "/fault_inventory_object";
// endpoint contains the vector of strings, where each string is a Inventory
// D-Bus object that this, associated with this LED Group D-Bus object
// pointed to by fru_fault
utils::PropertyValue endpoint{};
try
{
endpoint = utils::DBusHandler().getProperty(
fru, "xyz.openbmc_project.Association", "endpoints");
}
catch (const sdbusplus::exception::SdBusError& e)
{
lg2::error(
"Failed to get endpoints property, ERROR = {ERROR}, PATH = {PATH}",
"ERROR", e.what(), "PATH", fru);
return;
}
auto& endpoints = std::get<std::vector<std::string>>(endpoint);
if (endpoints.empty())
{
return;
}
for (const auto& fruInstancePath : endpoints)
{
std::cout << "SAI: FRU path: " << fruInstancePath << std::endl;
// Set OperationalStatus by fru instance path
try
{
utils::PropertyValue functionalValue{value};
utils::DBusHandler().setProperty(
fruInstancePath,
"xyz.openbmc_project.State.Decorator.OperationalStatus",
"Functional", functionalValue);
}
catch (const sdbusplus::exception::SdBusError& e)
{
lg2::error(
"Failed to set Functional property, ERROR = {ERROR}, PATH = {PATH}",
"ERROR", e.what(), "PATH", fruInstancePath);
}
}
}
} // namespace ibm
} // namespace led
} // namespace phosphor