Add Callout class
This class will be used to put a hardware callout object
on D-Bus that shows the serial number and part number information
for what is being called out in an error log.
It will remain even after that part is replaced with a new part with
a new SN, so the data needs to be persisted as opposed to being
looked up in the inventory on startup. The persisting will be
done in a future commit. Note it will also survive an error log
being resolved, which would delete the inventory assocation interface
on the error log.
The object path of the callout objects will look something like
/xyz/openbmc_project/logging/entry/5/callouts/0, where this would be
the first callout on error log 5.
Tested: N/A - not used yet
Change-Id: I7e2f0c61705880ad70d5f6a49209f73a499785b9
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/callout.cpp b/callout.cpp
new file mode 100644
index 0000000..ef72414
--- /dev/null
+++ b/callout.cpp
@@ -0,0 +1,70 @@
+/** Copyright © 2018 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 "callout.hpp"
+
+namespace ibm
+{
+namespace logging
+{
+
+Callout::Callout(sdbusplus::bus::bus& bus, const std::string& objectPath,
+ size_t id, uint64_t timestamp) :
+ CalloutObject(bus, objectPath.c_str(), true),
+ entryID(id), timestamp(timestamp)
+{
+}
+
+Callout::Callout(sdbusplus::bus::bus& bus, const std::string& objectPath,
+ const std::string& inventoryPath, size_t id,
+ uint64_t timestamp, const DbusPropertyMap& properties) :
+ CalloutObject(bus, objectPath.c_str(), true),
+ entryID(id), timestamp(timestamp)
+{
+ path(inventoryPath);
+
+ auto it = properties.find("BuildDate");
+ if (it != properties.end())
+ {
+ buildDate(it->second.get<std::string>());
+ }
+
+ it = properties.find("Manufacturer");
+ if (it != properties.end())
+ {
+ manufacturer(it->second.get<std::string>());
+ }
+
+ it = properties.find("Model");
+ if (it != properties.end())
+ {
+ model(it->second.get<std::string>());
+ }
+
+ it = properties.find("PartNumber");
+ if (it != properties.end())
+ {
+ partNumber(it->second.get<std::string>());
+ }
+
+ it = properties.find("SerialNumber");
+ if (it != properties.end())
+ {
+ serialNumber(it->second.get<std::string>());
+ }
+
+ emit_object_added();
+}
+}
+}