From 56fd833d55f62962f7d4c7c8421006cab7b98409 Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Tue, 31 Oct 2017 14:00:18 -0500 Subject: Add ResolveCallout class This class is a type of callback, and when triggered will resolve all error log entries that have the specified callout. It does this by setting the Resolved property on the log entry. It can be used to do things like resolve all errors against a particular part when that part is replaced, which would be done by specifying this class as a callback on a watch on the Present property for the part in the inventory. Change-Id: I50557938c9e15a91744ee2a16d67eaa7f367ef04 Signed-off-by: Matt Spinler --- src/Makefile.am | 3 ++- src/resolve_errors.cpp | 37 +++++++++++++++++++++++++++++ src/resolve_errors.hpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/test/Makefile.am | 3 ++- 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/resolve_errors.cpp create mode 100644 src/resolve_errors.hpp (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index c6a041f..29a4ba7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,8 @@ phosphor_dbus_monitor_SOURCES = \ journal.cpp \ elog.cpp \ main.cpp \ - propertywatch.cpp + propertywatch.cpp \ + resolve_errors.cpp phosphor_dbus_monitor_LDADD = \ $(SDBUSPLUS_LIBS) \ $(PHOSPHOR_DBUS_INTERFACES_LIBS) \ diff --git a/src/resolve_errors.cpp b/src/resolve_errors.cpp new file mode 100644 index 0000000..c08e489 --- /dev/null +++ b/src/resolve_errors.cpp @@ -0,0 +1,37 @@ +/** + * Copyright © 2017 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "resolve_errors.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +void ResolveCallout::operator()() +{ + //TODO: fill in +} + +void ResolveCallout::resolve(const std::string& logEntry) +{ + //TODO: fill in +} + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor diff --git a/src/resolve_errors.hpp b/src/resolve_errors.hpp new file mode 100644 index 0000000..a455ab4 --- /dev/null +++ b/src/resolve_errors.hpp @@ -0,0 +1,64 @@ +#pragma once +#include "callback.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +/** + * @class ResolveCallout + * @brief Resolves error logs with the associated callout + * + * Resolves a log by setting its Resolved property + * to true. + */ +class ResolveCallout : public Callback +{ + public: + + ResolveCallout() = delete; + ~ResolveCallout() = default; + ResolveCallout(const ResolveCallout&) = delete; + ResolveCallout& operator=(const ResolveCallout&) = delete; + ResolveCallout(ResolveCallout&&) = default; + ResolveCallout& operator=(ResolveCallout&&) = default; + + /** + * @brief constructor + * + * @param[in] callout - The callout whose errors need to be resolved. + * Normally an inventory path. + */ + explicit ResolveCallout(const std::string& callout) : + callout(callout) {} + + /** + * @brief Callback interface to resolve errors + * + * Resolves all error log entries that are associated + * with the callout. + */ + void operator()() override; + + private: + + /** + * @brief Resolves a single error log entry + * + * param[in] entry - the object path of the error log entry + */ + void resolve(const std::string& entry); + + /** + * @brief The object path of the callout, typically an inventory path + */ + std::string callout; +}; + + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 7dddccd..5a4d20d 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -196,4 +196,5 @@ callbacktest_LDADD = \ $(PHOSPHOR_DBUS_INTERFACES_LIBS) \ $(PHOSPHOR_LOGGING_LIBS) \ $(builddir)/../journal.o \ - $(builddir)/../elog.o + $(builddir)/../elog.o \ + $(builddir)/../resolve_errors.o -- cgit v1.2.1