Redfish- Clean up system schema implementation

Move the system schema awa from using single letter variable names.

Change-Id: I41f9c00f6a227a43126ad47f60e26950f0cf89ec
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 13ca905..2268897 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -110,14 +110,15 @@
                 {
                     // This is not system, so check if it's cpu, dimm, UUID or
                     // BiosVer
-                    for (auto const &s : connectionNames)
+                    for (const auto &connection : connectionNames)
                     {
-                        for (auto const &i : s.second)
+                        for (const auto &interfaceName : connection.second)
                         {
-                            if (boost::ends_with(i, "Dimm"))
+                            if (interfaceName ==
+                                "xyz.openbmc_project.Inventory.Item.Dimm")
                             {
                                 BMCWEB_LOG_DEBUG
-                                    << "Found Dimm, now get it properties.";
+                                    << "Found Dimm, now get its properties.";
                                 crow::connections::systemBus->async_method_call(
                                     [aResp](
                                         const boost::system::error_code ec,
@@ -136,50 +137,23 @@
                                         BMCWEB_LOG_DEBUG << "Got "
                                                          << properties.size()
                                                          << "Dimm properties.";
-                                        for (const auto &p : properties)
+                                        for (const std::pair<std::string,
+                                                             VariantType>
+                                                 &property : properties)
                                         {
-                                            if (p.first == "MemorySize")
+                                            if (property.first ==
+                                                "MemorySizeInKb")
                                             {
-                                                const std::string *value =
+                                                const uint64_t *value =
                                                     mapbox::getPtr<
-                                                        const std::string>(
-                                                        p.second);
-                                                if ((value != nullptr) &&
-                                                    (*value != "NULL"))
+                                                        const uint64_t>(
+                                                        property.second);
+                                                if (value != nullptr)
                                                 {
-                                                    // Remove units char
-                                                    int32_t unitCoeff;
-                                                    if (boost::ends_with(*value,
-                                                                         "MB"))
-                                                    {
-                                                        unitCoeff = 1000;
-                                                    }
-                                                    else if (boost::ends_with(
-                                                                 *value, "KB"))
-                                                    {
-                                                        unitCoeff = 1000000;
-                                                    }
-                                                    else
-                                                    {
-                                                        BMCWEB_LOG_ERROR
-                                                            << "Unsupported "
-                                                               "memory units";
-                                                        aResp->res.result(
-                                                            boost::beast::http::
-                                                                status::
-                                                                    internal_server_error);
-                                                        return;
-                                                    }
-
-                                                    auto memSize =
-                                                        boost::lexical_cast<
-                                                            int>(value->substr(
-                                                            0, value->length() -
-                                                                   2));
                                                     aResp->res.jsonValue
                                                         ["TotalSystemMemoryGi"
                                                          "B"] +=
-                                                        memSize * unitCoeff;
+                                                        *value / (1024 * 1024);
                                                     aResp->res.jsonValue
                                                         ["MemorySummary"]
                                                         ["Status"]["State"] =
@@ -188,14 +162,15 @@
                                             }
                                         }
                                     },
-                                    s.first, path,
+                                    connection.first, path,
                                     "org.freedesktop.DBus.Properties", "GetAll",
                                     "xyz.openbmc_project.Inventory.Item.Dimm");
                             }
-                            else if (boost::ends_with(i, "Cpu"))
+                            else if (interfaceName ==
+                                     "xyz.openbmc_project.Inventory.Item.Cpu")
                             {
                                 BMCWEB_LOG_DEBUG
-                                    << "Found Cpu, now get it properties.";
+                                    << "Found Cpu, now get its properties.";
                                 crow::connections::systemBus->async_method_call(
                                     [aResp](
                                         const boost::system::error_code ec,
@@ -214,44 +189,46 @@
                                         BMCWEB_LOG_DEBUG << "Got "
                                                          << properties.size()
                                                          << "Cpu properties.";
-                                        for (const auto &p : properties)
+                                        for (const auto &property : properties)
                                         {
-                                            if (p.first == "ProcessorFamily")
+                                            if (property.first ==
+                                                "ProcessorFamily")
                                             {
                                                 const std::string *value =
                                                     mapbox::getPtr<
                                                         const std::string>(
-                                                        p.second);
+                                                        property.second);
                                                 if (value != nullptr)
                                                 {
-                                                    aResp->res.jsonValue
-                                                        ["ProcessorSummary"]
-                                                        ["Count"] =
-                                                        aResp->res
-                                                            .jsonValue
+                                                    nlohmann::json
+                                                        &procSummary =
+                                                            aResp->res.jsonValue
                                                                 ["ProcessorSumm"
-                                                                 "ary"]["Count"]
-                                                            .get<int>() +
+                                                                 "ary"];
+                                                    nlohmann::json &procCount =
+                                                        procSummary["Count"];
+
+                                                    procCount =
+                                                        procCount.get<int>() +
                                                         1;
-                                                    aResp->res.jsonValue
-                                                        ["ProcessorSummary"]
-                                                        ["Status"]["State"] =
-                                                        "Enabled";
-                                                    aResp->res.jsonValue
-                                                        ["ProcessorSummary"]
-                                                        ["Model"] = *value;
+                                                    procSummary["Status"]
+                                                               ["State"] =
+                                                                   "Enabled";
+                                                    procSummary["Model"] =
+                                                        *value;
                                                 }
                                             }
                                         }
                                     },
-                                    s.first, path,
+                                    connection.first, path,
                                     "org.freedesktop.DBus.Properties", "GetAll",
                                     "xyz.openbmc_project.Inventory.Item.Cpu");
                             }
-                            else if (boost::ends_with(i, "UUID"))
+                            else if (interfaceName ==
+                                     "xyz.openbmc_project.Common.UUID")
                             {
                                 BMCWEB_LOG_DEBUG
-                                    << "Found UUID, now get it properties.";
+                                    << "Found UUID, now get its properties.";
                                 crow::connections::systemBus->async_method_call(
                                     [aResp](
                                         const boost::system::error_code ec,
@@ -271,15 +248,15 @@
                                                          << properties.size()
                                                          << "UUID properties.";
                                         for (const std::pair<std::string,
-                                                             VariantType> &p :
-                                             properties)
+                                                             VariantType>
+                                                 &property : properties)
                                         {
-                                            if (p.first == "BIOSVer")
+                                            if (property.first == "BIOSVer")
                                             {
                                                 const std::string *value =
                                                     mapbox::getPtr<
                                                         const std::string>(
-                                                        p.second);
+                                                        property.second);
                                                 if (value != nullptr)
                                                 {
                                                     aResp->res.jsonValue
@@ -287,59 +264,39 @@
                                                         *value;
                                                 }
                                             }
-                                            if (p.first == "UUID")
+                                            if (property.first == "UUID")
                                             {
                                                 const std::string *value =
                                                     mapbox::getPtr<
                                                         const std::string>(
-                                                        p.second);
-                                                BMCWEB_LOG_DEBUG
-                                                    << "UUID = " << *value
-                                                    << " length "
-                                                    << value->length();
+                                                        property.second);
+
                                                 if (value != nullptr)
                                                 {
-                                                    // Workaround for to short
-                                                    // return str in smbios demo
-                                                    // app, 32 bytes are
-                                                    // described by spec
-                                                    if (value->length() > 0 &&
-                                                        value->length() < 32)
+                                                    std::string valueStr =
+                                                        *value;
+                                                    if (valueStr.size() == 32)
                                                     {
-                                                        std::string
-                                                            correctedValue =
-                                                                *value;
-                                                        correctedValue.append(
-                                                            32 -
-                                                                value->length(),
-                                                            '0');
-                                                        value = &correctedValue;
+                                                        valueStr.insert(8, 1,
+                                                                        '-');
+                                                        valueStr.insert(13, 1,
+                                                                        '-');
+                                                        valueStr.insert(18, 1,
+                                                                        '-');
+                                                        valueStr.insert(23, 1,
+                                                                        '-');
                                                     }
-                                                    else if (value->length() ==
-                                                             32)
-                                                    {
-                                                        aResp->res
-                                                            .jsonValue["UUID"] =
-                                                            value->substr(0,
-                                                                          8) +
-                                                            "-" +
-                                                            value->substr(8,
-                                                                          4) +
-                                                            "-" +
-                                                            value->substr(12,
-                                                                          4) +
-                                                            "-" +
-                                                            value->substr(16,
-                                                                          4) +
-                                                            "-" +
-                                                            value->substr(20,
-                                                                          12);
-                                                    }
+                                                    BMCWEB_LOG_DEBUG
+                                                        << "UUID = "
+                                                        << valueStr;
+                                                    aResp->res
+                                                        .jsonValue["UUID"] =
+                                                        valueStr;
                                                 }
                                             }
                                         }
                                     },
-                                    s.first, path,
+                                    connection.first, path,
                                     "org.freedesktop.DBus.Properties", "GetAll",
                                     "xyz.openbmc_project.Common.UUID");
                             }
@@ -768,7 +725,7 @@
             {"None",      "Pxe",       "Hdd", "Cd",
              "BiosSetup", "UefiShell", "Usb"}; // TODO(Dawid), get real boot
                                                // data
-        Node::json["ProcessorSummary"]["Count"] = int(0);
+        Node::json["ProcessorSummary"]["Count"] = 0;
         Node::json["ProcessorSummary"]["Status"]["State"] = "Disabled";
         Node::json["MemorySummary"]["TotalSystemMemoryGiB"] = int(0);
         Node::json["MemorySummary"]["Status"]["State"] = "Disabled";
@@ -799,6 +756,9 @@
 
         const std::string &name = params[0];
 
+        res.jsonValue = Node::json;
+        res.jsonValue["@odata.id"] = "/redfish/v1/Systems/" + name;
+
         // TODO Need to support ForceRestart.
         res.jsonValue["Actions"]["#ComputerSystem.Reset"] = {
             {"target",