manager: Save and Restore BIOS Attributes

This commit saves any updates made to BIOS attributes
to VPD.

It also restores the attributes from the VPD when we
start VPD manager.

Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: Idb28e2f89d21ccd89eb8e56490eb7f31397ff5f5
diff --git a/ibm_vpd_utils.cpp b/ibm_vpd_utils.cpp
index 4eb99cb..c7babf6 100644
--- a/ibm_vpd_utils.cpp
+++ b/ibm_vpd_utils.cpp
@@ -886,5 +886,28 @@
         map.emplace(interface, property);
     }
 }
+
+BIOSAttrValueType readBIOSAttribute(const std::string& attrName)
+{
+    std::tuple<std::string, BIOSAttrValueType, BIOSAttrValueType> attrVal;
+    auto bus = sdbusplus::bus::new_default();
+    auto method = bus.new_method_call(
+        "xyz.openbmc_project.BIOSConfigManager",
+        "/xyz/openbmc_project/bios_config/manager",
+        "xyz.openbmc_project.BIOSConfig.Manager", "GetAttribute");
+    method.append(attrName);
+    try
+    {
+        auto result = bus.call(method);
+        result.read(std::get<0>(attrVal), std::get<1>(attrVal),
+                    std::get<2>(attrVal));
+    }
+    catch (const sdbusplus::exception::SdBusError& e)
+    {
+        std::cerr << "Failed to read BIOS Attribute: " << attrName << std::endl;
+        std::cerr << e.what() << std::endl;
+    }
+    return std::get<1>(attrVal);
+}
 } // namespace vpd
 } // namespace openpower