blob: 6f3c4bee65ec61280dd0249e2a7145c9bb2e83cb [file] [log] [blame]
Matt Spinler56fd8332017-10-31 14:00:18 -05001/**
2 * Copyright © 2017 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Matt Spinler4eaa77b2017-10-31 14:25:27 -050016#include <phosphor-logging/log.hpp>
Matt Spinler56fd8332017-10-31 14:00:18 -050017#include "resolve_errors.hpp"
Matt Spinler4eaa77b2017-10-31 14:25:27 -050018#include "sdbusplus.hpp"
Matt Spinler56fd8332017-10-31 14:00:18 -050019
20namespace phosphor
21{
22namespace dbus
23{
24namespace monitoring
25{
26
Matt Spinler4eaa77b2017-10-31 14:25:27 -050027constexpr auto PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
28constexpr auto ASSOCIATION_IFACE = "org.openbmc.Association";
29constexpr auto ENDPOINTS_PROPERTY = "endpoints";
30
31using namespace phosphor::logging;
32using EndpointList = std::vector<std::string>;
33using EndpointsProperty = sdbusplus::message::variant<EndpointList>;
34
Matt Spinler56fd8332017-10-31 14:00:18 -050035void ResolveCallout::operator()()
36{
Matt Spinler4eaa77b2017-10-31 14:25:27 -050037 //Resolve all errors for this callout:
38 // 1) Read the 'endpoints' property for the callout/fault object
39 //
40 // 2) Follow each endpoint to its log entry
41 //
42 // 3) Set the Resolved property to true on the entry
43
44 try
45 {
46 auto path = callout + "/fault";
47 auto busName = SDBusPlus::getBusName(path, ASSOCIATION_IFACE);
48
49 if (busName.empty())
50 {
51 //Just means there are no error logs with this callout
52 return;
53 }
54
55 auto endpoints = SDBusPlus::callMethodAndRead<EndpointsProperty>(
56 busName,
57 path,
58 PROPERTY_IFACE,
59 "Get",
60 ASSOCIATION_IFACE,
61 ENDPOINTS_PROPERTY);
62
63 const auto& logEntries = endpoints.get<EndpointList>();
64
65 //Resolve each log entry
66 for (const auto& logEntry : logEntries)
67 {
68 resolve(logEntry);
69 }
70 }
71 catch (const std::exception& e)
72 {
73 log<level::ERR>(
74 "Failed getting callout fault associations",
75 entry("CALLOUT=%s", callout.c_str()),
76 entry("MESSAGE=%s", e.what()));
77 }
Matt Spinler56fd8332017-10-31 14:00:18 -050078}
79
80void ResolveCallout::resolve(const std::string& logEntry)
81{
82 //TODO: fill in
83}
84
85} // namespace monitoring
86} // namespace dbus
87} // namespace phosphor