diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 229ec0b..44c1170 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -24,613 +24,563 @@
 namespace redfish
 {
 
-/**
- * OnDemandSystemsProvider
- * Board provider class that retrieves data directly from dbus, before seting
- * it into JSON output. This does not cache any data.
- *
- * Class can be a good example on how to scale different data providing
- * solutions to produce single schema output.
- *
- * TODO(Pawel)
- * This perhaps shall be different file, which has to be chosen on compile time
- * depending on OEM needs
- */
-class OnDemandSystemsProvider
+template <typename CallbackFunc> void getBaseboardList(CallbackFunc &&callback)
 {
-  public:
-    template <typename CallbackFunc>
-    void getBaseboardList(CallbackFunc &&callback)
-    {
-        BMCWEB_LOG_DEBUG << "Get list of available boards.";
-        crow::connections::systemBus->async_method_call(
-            [callback{std::move(callback)}](
-                const boost::system::error_code ec,
-                const std::vector<std::string> &resp) {
-                // Callback requires vector<string> to retrieve all available
-                // board list.
-                std::vector<std::string> boardList;
-                if (ec)
+    BMCWEB_LOG_DEBUG << "Get list of available boards.";
+    crow::connections::systemBus->async_method_call(
+        [callback{std::move(callback)}](const boost::system::error_code ec,
+                                        const std::vector<std::string> &resp) {
+            // Callback requires vector<string> to retrieve all available board
+            // list.
+            std::vector<std::string> boardList;
+            if (ec)
+            {
+                // Something wrong on DBus, the error_code is not important at
+                // this moment, just return success=false, and empty output.
+                // Since size of vector may vary depending on information from
+                // Entity Manager, and empty output could not be treated same
+                // way as error.
+                callback(false, boardList);
+                return;
+            }
+            BMCWEB_LOG_DEBUG << "Got " << resp.size() << " boards.";
+            // Iterate over all retrieved ObjectPaths.
+            for (const std::string &objpath : resp)
+            {
+                std::size_t lastPos = objpath.rfind("/");
+                if (lastPos != std::string::npos)
                 {
-                    // Something wrong on DBus, the error_code is not important
-                    // at this moment, just return success=false, and empty
-                    // output. Since size of vector may vary depending on
-                    // information from Entity Manager, and empty output could
-                    // not be treated same way as error.
-                    callback(false, boardList);
-                    return;
+                    boardList.emplace_back(objpath.substr(lastPos + 1));
                 }
-                BMCWEB_LOG_DEBUG << "Got " << resp.size() << " boards.";
-                // Iterate over all retrieved ObjectPaths.
-                for (const std::string &objpath : resp)
-                {
-                    std::size_t lastPos = objpath.rfind("/");
-                    if (lastPos != std::string::npos)
-                    {
-                        boardList.emplace_back(objpath.substr(lastPos + 1));
-                    }
-                }
-                // Finally make a callback with useful data
-                callback(true, boardList);
-            },
-            "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-            "/xyz/openbmc_project/inventory", int32_t(0),
-            std::array<const char *, 1>{
-                "xyz.openbmc_project.Inventory.Item.Board"});
-    };
-
-    /**
-     * @brief Retrieves computer system properties over dbus
-     *
-     * @param[in] aResp Shared pointer for completing asynchronous calls
-     * @param[in] name  Computer system name from request
-     *
-     * @return None.
-     */
-    void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
-                           const std::string &name)
-    {
-        const std::array<const char *, 5> interfaces = {
-            "xyz.openbmc_project.Inventory.Decorator.Asset",
-            "xyz.openbmc_project.Inventory.Item.Cpu",
-            "xyz.openbmc_project.Inventory.Item.Dimm",
-            "xyz.openbmc_project.Inventory.Item.System",
-            "xyz.openbmc_project.Common.UUID",
-        };
-        BMCWEB_LOG_DEBUG << "Get available system components.";
-        crow::connections::systemBus->async_method_call(
-            [name, aResp{std::move(aResp)}](
-                const boost::system::error_code ec,
-                const std::vector<std::pair<
-                    std::string, std::vector<std::pair<
-                                     std::string, std::vector<std::string>>>>>
-                    &subtree) {
-                if (ec)
-                {
-                    BMCWEB_LOG_DEBUG << "DBUS response error";
-                    aResp->res.result(
-                        boost::beast::http::status::internal_server_error);
-                    return;
-                }
-                bool foundName = false;
-                // Iterate over all retrieved ObjectPaths.
-                for (const std::pair<
-                         std::string,
-                         std::vector<
-                             std::pair<std::string, std::vector<std::string>>>>
-                         &object : subtree)
-                {
-                    const std::string &path = object.first;
-                    BMCWEB_LOG_DEBUG << "Got path: " << path;
-                    const std::vector<
-                        std::pair<std::string, std::vector<std::string>>>
-                        &connectionNames = object.second;
-                    if (connectionNames.size() < 1)
-                    {
-                        continue;
-                    }
-                    // Check if computer system exist
-                    if (boost::ends_with(path, name))
-                    {
-                        foundName = true;
-                        BMCWEB_LOG_DEBUG << "Found name: " << name;
-                        const std::string connectionName =
-                            connectionNames[0].first;
-                        crow::connections::systemBus->async_method_call(
-                            [aResp, name(std::string(name))](
-                                const boost::system::error_code ec,
-                                const std::vector<
-                                    std::pair<std::string, VariantType>>
-                                    &propertiesList) {
-                                if (ec)
-                                {
-                                    BMCWEB_LOG_ERROR << "DBUS response error: "
-                                                     << ec;
-                                    aResp->res.result(
-                                        boost::beast::http::status::
-                                            internal_server_error);
-                                    return;
-                                }
-                                BMCWEB_LOG_DEBUG << "Got "
-                                                 << propertiesList.size()
-                                                 << "properties for system";
-                                for (const std::pair<std::string, VariantType>
-                                         &property : propertiesList)
-                                {
-                                    const std::string *value =
-                                        mapbox::getPtr<const std::string>(
-                                            property.second);
-                                    if (value != nullptr)
-                                    {
-                                        aResp->res.jsonValue[property.first] =
-                                            *value;
-                                    }
-                                }
-                                aResp->res.jsonValue["Name"] = name;
-                                aResp->res.jsonValue["Id"] =
-                                    aResp->res.jsonValue["SerialNumber"];
-                            },
-                            connectionName, path,
-                            "org.freedesktop.DBus.Properties", "GetAll",
-                            "xyz.openbmc_project.Inventory.Decorator.Asset");
-                    }
-                    else
-                    {
-                        // This is not system, so check if it's cpu, dimm, UUID
-                        // or BiosVer
-                        for (auto const &s : connectionNames)
-                        {
-                            for (auto const &i : s.second)
-                            {
-                                if (boost::ends_with(i, "Dimm"))
-                                {
-                                    BMCWEB_LOG_DEBUG
-                                        << "Found Dimm, now get it properties.";
-                                    crow::connections::systemBus->async_method_call(
-                                        [&, aResp](
-                                            const boost::system::error_code ec,
-                                            const std::vector<std::pair<
-                                                std::string, VariantType>>
-                                                &properties) {
-                                            if (ec)
-                                            {
-                                                BMCWEB_LOG_ERROR
-                                                    << "DBUS response error "
-                                                    << ec;
-                                                aResp->res.result(
-                                                    boost::beast::http::status::
-                                                        internal_server_error);
-                                                return;
-                                            }
-                                            BMCWEB_LOG_DEBUG
-                                                << "Got " << properties.size()
-                                                << "Dimm properties.";
-                                            for (const auto &p : properties)
-                                            {
-                                                if (p.first == "MemorySize")
-                                                {
-                                                    const std::string *value =
-                                                        mapbox::getPtr<
-                                                            const std::string>(
-                                                            p.second);
-                                                    if ((value != nullptr) &&
-                                                        (*value != "NULL"))
-                                                    {
-                                                        // 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
-                                                            ["TotalSystemMemory"
-                                                             "GiB"] +=
-                                                            memSize * unitCoeff;
-                                                        aResp->res.jsonValue
-                                                            ["MemorySummary"]
-                                                            ["Status"]
-                                                            ["State"] =
-                                                            "Enabled";
-                                                    }
-                                                }
-                                            }
-                                        },
-                                        s.first, path,
-                                        "org.freedesktop.DBus.Properties",
-                                        "GetAll",
-                                        "xyz.openbmc_project.Inventory.Item."
-                                        "Dimm");
-                                }
-                                else if (boost::ends_with(i, "Cpu"))
-                                {
-                                    BMCWEB_LOG_DEBUG
-                                        << "Found Cpu, now get it properties.";
-                                    crow::connections::systemBus->async_method_call(
-                                        [&, aResp](
-                                            const boost::system::error_code ec,
-                                            const std::vector<std::pair<
-                                                std::string, VariantType>>
-                                                &properties) {
-                                            if (ec)
-                                            {
-                                                BMCWEB_LOG_ERROR
-                                                    << "DBUS response error "
-                                                    << ec;
-                                                aResp->res.result(
-                                                    boost::beast::http::status::
-                                                        internal_server_error);
-                                                return;
-                                            }
-                                            BMCWEB_LOG_DEBUG
-                                                << "Got " << properties.size()
-                                                << "Cpu properties.";
-                                            for (const auto &p : properties)
-                                            {
-                                                if (p.first ==
-                                                    "ProcessorFamily")
-                                                {
-                                                    const std::string *value =
-                                                        mapbox::getPtr<
-                                                            const std::string>(
-                                                            p.second);
-                                                    if (value != nullptr)
-                                                    {
-                                                        aResp->res.jsonValue
-                                                            ["ProcessorSummary"]
-                                                            ["Count"] =
-                                                            aResp->res
-                                                                .jsonValue
-                                                                    ["Processor"
-                                                                     "Summary"]
-                                                                    ["Count"]
-                                                                .get<int>() +
-                                                            1;
-                                                        aResp->res.jsonValue
-                                                            ["ProcessorSummary"]
-                                                            ["Status"]
-                                                            ["State"] =
-                                                            "Enabled";
-                                                        aResp->res.jsonValue
-                                                            ["ProcessorSummary"]
-                                                            ["Model"] = *value;
-                                                    }
-                                                }
-                                            }
-                                        },
-                                        s.first, path,
-                                        "org.freedesktop.DBus.Properties",
-                                        "GetAll",
-                                        "xyz.openbmc_project.Inventory.Item."
-                                        "Cpu");
-                                }
-                                else if (boost::ends_with(i, "UUID"))
-                                {
-                                    BMCWEB_LOG_DEBUG
-                                        << "Found UUID, now get it properties.";
-                                    crow::connections::systemBus->async_method_call(
-                                        [aResp](
-                                            const boost::system::error_code ec,
-                                            const std::vector<std::pair<
-                                                std::string, VariantType>>
-                                                &properties) {
-                                            if (ec)
-                                            {
-                                                BMCWEB_LOG_DEBUG
-                                                    << "DBUS response error "
-                                                    << ec;
-                                                aResp->res.result(
-                                                    boost::beast::http::status::
-                                                        internal_server_error);
-                                                return;
-                                            }
-                                            BMCWEB_LOG_DEBUG
-                                                << "Got " << properties.size()
-                                                << "UUID properties.";
-                                            for (const std::pair<std::string,
-                                                                 VariantType>
-                                                     &p : properties)
-                                            {
-                                                if (p.first == "BIOSVer")
-                                                {
-                                                    const std::string *value =
-                                                        mapbox::getPtr<
-                                                            const std::string>(
-                                                            p.second);
-                                                    if (value != nullptr)
-                                                    {
-                                                        aResp->res.jsonValue
-                                                            ["BiosVersion"] =
-                                                            *value;
-                                                    }
-                                                }
-                                                if (p.first == "UUID")
-                                                {
-                                                    const std::string *value =
-                                                        mapbox::getPtr<
-                                                            const std::string>(
-                                                            p.second);
-                                                    BMCWEB_LOG_DEBUG
-                                                        << "UUID = " << *value
-                                                        << " length "
-                                                        << value->length();
-                                                    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
-                                                                correctedValue =
-                                                                    *value;
-                                                            correctedValue.append(
-                                                                32 -
-                                                                    value
-                                                                        ->length(),
-                                                                '0');
-                                                            value =
-                                                                &correctedValue;
-                                                        }
-                                                        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);
-                                                        }
-                                                    }
-                                                }
-                                            }
-                                        },
-                                        s.first, path,
-                                        "org.freedesktop.DBus.Properties",
-                                        "GetAll",
-                                        "xyz.openbmc_project.Common.UUID");
-                                }
-                            }
-                        }
-                    }
-                }
-                if (foundName == false)
-                {
-                    aResp->res.result(
-                        boost::beast::http::status::internal_server_error);
-                }
-            },
-            "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTree",
-            "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
-    }
-
-    /**
-     * @brief Retrieves identify led group properties over dbus
-     *
-     * @param[in] aResp     Shared pointer for completing asynchronous calls.
-     * @param[in] callback  Callback for process retrieved data.
-     *
-     * @return None.
-     */
-    template <typename CallbackFunc>
-    void getLedGroupIdentify(std::shared_ptr<AsyncResp> aResp,
-                             CallbackFunc &&callback)
-    {
-        BMCWEB_LOG_DEBUG << "Get led groups";
-        crow::connections::systemBus->async_method_call(
-            [aResp{std::move(aResp)},
-             &callback](const boost::system::error_code &ec,
-                        const ManagedObjectsType &resp) {
-                if (ec)
-                {
-                    BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
-                    aResp->res.result(
-                        boost::beast::http::status::internal_server_error);
-                    return;
-                }
-                BMCWEB_LOG_DEBUG << "Got " << resp.size()
-                                 << "led group objects.";
-                for (const auto &objPath : resp)
-                {
-                    const std::string &path = objPath.first;
-                    if (path.rfind("enclosure_identify") != std::string::npos)
-                    {
-                        for (const auto &interface : objPath.second)
-                        {
-                            if (interface.first ==
-                                "xyz.openbmc_project.Led.Group")
-                            {
-                                for (const auto &property : interface.second)
-                                {
-                                    if (property.first == "Asserted")
-                                    {
-                                        const bool *asserted =
-                                            mapbox::getPtr<const bool>(
-                                                property.second);
-                                        if (nullptr != asserted)
-                                        {
-                                            callback(*asserted, aResp);
-                                        }
-                                        else
-                                        {
-                                            callback(false, aResp);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            },
-            "xyz.openbmc_project.LED.GroupManager",
-            "/xyz/openbmc_project/led/groups",
-            "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-    }
-
-    template <typename CallbackFunc>
-    void getLedIdentify(std::shared_ptr<AsyncResp> aResp,
-                        CallbackFunc &&callback)
-    {
-        BMCWEB_LOG_DEBUG << "Get identify led properties";
-        crow::connections::systemBus->async_method_call(
-            [aResp{std::move(aResp)},
-             &callback](const boost::system::error_code ec,
-                        const PropertiesType &properties) {
-                if (ec)
-                {
-                    BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
-                    aResp->res.result(
-                        boost::beast::http::status::internal_server_error);
-                    return;
-                }
-                BMCWEB_LOG_DEBUG << "Got " << properties.size()
-                                 << "led properties.";
-                std::string output;
-                for (const auto &property : properties)
-                {
-                    if (property.first == "State")
-                    {
-                        const std::string *s =
-                            mapbox::getPtr<std::string>(property.second);
-                        if (nullptr != s)
-                        {
-                            BMCWEB_LOG_DEBUG << "Identify Led State: " << *s;
-                            const auto pos = s->rfind('.');
-                            if (pos != std::string::npos)
-                            {
-                                auto led = s->substr(pos + 1);
-                                for (const std::pair<const char *, const char *>
-                                         &p :
-                                     std::array<
-                                         std::pair<const char *, const char *>,
-                                         3>{{{"On", "Lit"},
-                                             {"Blink", "Blinking"},
-                                             {"Off", "Off"}}})
-                                {
-                                    if (led == p.first)
-                                    {
-                                        output = p.second;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-                callback(output, aResp);
-            },
-            "xyz.openbmc_project.LED.Controller.identify",
-            "/xyz/openbmc_project/led/physical/identify",
-            "org.freedesktop.DBus.Properties", "GetAll",
-            "xyz.openbmc_project.Led.Physical");
-    }
-
-    /**
-     * @brief Retrieves host state properties over dbus
-     *
-     * @param[in] aResp     Shared pointer for completing asynchronous calls.
-     *
-     * @return None.
-     */
-    void getHostState(std::shared_ptr<AsyncResp> aResp)
-    {
-        BMCWEB_LOG_DEBUG << "Get host information.";
-        crow::connections::systemBus->async_method_call(
-            [aResp{std::move(aResp)}](const boost::system::error_code ec,
-                                      const PropertiesType &properties) {
-                if (ec)
-                {
-                    BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
-                    aResp->res.result(
-                        boost::beast::http::status::internal_server_error);
-                    return;
-                }
-                BMCWEB_LOG_DEBUG << "Got " << properties.size()
-                                 << "host properties.";
-                for (const auto &property : properties)
-                {
-                    if (property.first == "CurrentHostState")
-                    {
-                        const std::string *s =
-                            mapbox::getPtr<const std::string>(property.second);
-                        BMCWEB_LOG_DEBUG << "Host state: " << *s;
-                        if (nullptr != s)
-                        {
-                            const auto pos = s->rfind('.');
-                            if (pos != std::string::npos)
-                            {
-                                // Verify Host State
-                                if (s->substr(pos + 1) == "Running")
-                                {
-                                    aResp->res.jsonValue["PowerState"] = "On";
-                                    aResp->res.jsonValue["Status"]["State"] =
-                                        "Enabled";
-                                }
-                                else
-                                {
-                                    aResp->res.jsonValue["PowerState"] = "Off";
-                                    aResp->res.jsonValue["Status"]["State"] =
-                                        "Disabled";
-                                }
-                            }
-                        }
-                    }
-                }
-            },
-            "xyz.openbmc_project.State.Host",
-            "/xyz/openbmc_project/state/host0",
-            "org.freedesktop.DBus.Properties", "GetAll",
-            "xyz.openbmc_project.State.Host");
-    }
+            }
+            // Finally make a callback with useful data
+            callback(true, boardList);
+        },
+        "xyz.openbmc_project.ObjectMapper",
+        "/xyz/openbmc_project/object_mapper",
+        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
+        "/xyz/openbmc_project/inventory", int32_t(0),
+        std::array<const char *, 1>{
+            "xyz.openbmc_project.Inventory.Item.Board"});
 };
 
 /**
+ * @brief Retrieves computer system properties over dbus
+ *
+ * @param[in] aResp Shared pointer for completing asynchronous calls
+ * @param[in] name  Computer system name from request
+ *
+ * @return None.
+ */
+void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
+                       const std::string &name)
+{
+    const std::array<const char *, 5> interfaces = {
+        "xyz.openbmc_project.Inventory.Decorator.Asset",
+        "xyz.openbmc_project.Inventory.Item.Cpu",
+        "xyz.openbmc_project.Inventory.Item.Dimm",
+        "xyz.openbmc_project.Inventory.Item.System",
+        "xyz.openbmc_project.Common.UUID",
+    };
+    BMCWEB_LOG_DEBUG << "Get available system components.";
+    crow::connections::systemBus->async_method_call(
+        [name, aResp{std::move(aResp)}](
+            const boost::system::error_code ec,
+            const std::vector<std::pair<
+                std::string,
+                std::vector<std::pair<std::string, std::vector<std::string>>>>>
+                &subtree) {
+            if (ec)
+            {
+                BMCWEB_LOG_DEBUG << "DBUS response error";
+                aResp->res.result(
+                    boost::beast::http::status::internal_server_error);
+                return;
+            }
+            bool foundName = false;
+            // Iterate over all retrieved ObjectPaths.
+            for (const std::pair<std::string,
+                                 std::vector<std::pair<
+                                     std::string, std::vector<std::string>>>>
+                     &object : subtree)
+            {
+                const std::string &path = object.first;
+                BMCWEB_LOG_DEBUG << "Got path: " << path;
+                const std::vector<
+                    std::pair<std::string, std::vector<std::string>>>
+                    &connectionNames = object.second;
+                if (connectionNames.size() < 1)
+                {
+                    continue;
+                }
+                // Check if computer system exist
+                if (boost::ends_with(path, name))
+                {
+                    foundName = true;
+                    BMCWEB_LOG_DEBUG << "Found name: " << name;
+                    const std::string connectionName = connectionNames[0].first;
+                    crow::connections::systemBus->async_method_call(
+                        [aResp, name(std::string(name))](
+                            const boost::system::error_code ec,
+                            const std::vector<std::pair<
+                                std::string, VariantType>> &propertiesList) {
+                            if (ec)
+                            {
+                                BMCWEB_LOG_ERROR << "DBUS response error: "
+                                                 << ec;
+                                aResp->res.result(boost::beast::http::status::
+                                                      internal_server_error);
+                                return;
+                            }
+                            BMCWEB_LOG_DEBUG << "Got " << propertiesList.size()
+                                             << "properties for system";
+                            for (const std::pair<std::string, VariantType>
+                                     &property : propertiesList)
+                            {
+                                const std::string *value =
+                                    mapbox::getPtr<const std::string>(
+                                        property.second);
+                                if (value != nullptr)
+                                {
+                                    aResp->res.jsonValue[property.first] =
+                                        *value;
+                                }
+                            }
+                            aResp->res.jsonValue["Name"] = name;
+                            aResp->res.jsonValue["Id"] =
+                                aResp->res.jsonValue["SerialNumber"];
+                        },
+                        connectionName, path, "org.freedesktop.DBus.Properties",
+                        "GetAll",
+                        "xyz.openbmc_project.Inventory.Decorator.Asset");
+                }
+                else
+                {
+                    // This is not system, so check if it's cpu, dimm, UUID or
+                    // BiosVer
+                    for (auto const &s : connectionNames)
+                    {
+                        for (auto const &i : s.second)
+                        {
+                            if (boost::ends_with(i, "Dimm"))
+                            {
+                                BMCWEB_LOG_DEBUG
+                                    << "Found Dimm, now get it properties.";
+                                crow::connections::systemBus->async_method_call(
+                                    [&, aResp](
+                                        const boost::system::error_code ec,
+                                        const std::vector<
+                                            std::pair<std::string, VariantType>>
+                                            &properties) {
+                                        if (ec)
+                                        {
+                                            BMCWEB_LOG_ERROR
+                                                << "DBUS response error " << ec;
+                                            aResp->res.result(
+                                                boost::beast::http::status::
+                                                    internal_server_error);
+                                            return;
+                                        }
+                                        BMCWEB_LOG_DEBUG << "Got "
+                                                         << properties.size()
+                                                         << "Dimm properties.";
+                                        for (const auto &p : properties)
+                                        {
+                                            if (p.first == "MemorySize")
+                                            {
+                                                const std::string *value =
+                                                    mapbox::getPtr<
+                                                        const std::string>(
+                                                        p.second);
+                                                if ((value != nullptr) &&
+                                                    (*value != "NULL"))
+                                                {
+                                                    // 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;
+                                                    aResp->res.jsonValue
+                                                        ["MemorySummary"]
+                                                        ["Status"]["State"] =
+                                                        "Enabled";
+                                                }
+                                            }
+                                        }
+                                    },
+                                    s.first, path,
+                                    "org.freedesktop.DBus.Properties", "GetAll",
+                                    "xyz.openbmc_project.Inventory.Item.Dimm");
+                            }
+                            else if (boost::ends_with(i, "Cpu"))
+                            {
+                                BMCWEB_LOG_DEBUG
+                                    << "Found Cpu, now get it properties.";
+                                crow::connections::systemBus->async_method_call(
+                                    [&, aResp](
+                                        const boost::system::error_code ec,
+                                        const std::vector<
+                                            std::pair<std::string, VariantType>>
+                                            &properties) {
+                                        if (ec)
+                                        {
+                                            BMCWEB_LOG_ERROR
+                                                << "DBUS response error " << ec;
+                                            aResp->res.result(
+                                                boost::beast::http::status::
+                                                    internal_server_error);
+                                            return;
+                                        }
+                                        BMCWEB_LOG_DEBUG << "Got "
+                                                         << properties.size()
+                                                         << "Cpu properties.";
+                                        for (const auto &p : properties)
+                                        {
+                                            if (p.first == "ProcessorFamily")
+                                            {
+                                                const std::string *value =
+                                                    mapbox::getPtr<
+                                                        const std::string>(
+                                                        p.second);
+                                                if (value != nullptr)
+                                                {
+                                                    aResp->res.jsonValue
+                                                        ["ProcessorSummary"]
+                                                        ["Count"] =
+                                                        aResp->res
+                                                            .jsonValue
+                                                                ["ProcessorSumm"
+                                                                 "ary"]["Count"]
+                                                            .get<int>() +
+                                                        1;
+                                                    aResp->res.jsonValue
+                                                        ["ProcessorSummary"]
+                                                        ["Status"]["State"] =
+                                                        "Enabled";
+                                                    aResp->res.jsonValue
+                                                        ["ProcessorSummary"]
+                                                        ["Model"] = *value;
+                                                }
+                                            }
+                                        }
+                                    },
+                                    s.first, path,
+                                    "org.freedesktop.DBus.Properties", "GetAll",
+                                    "xyz.openbmc_project.Inventory.Item.Cpu");
+                            }
+                            else if (boost::ends_with(i, "UUID"))
+                            {
+                                BMCWEB_LOG_DEBUG
+                                    << "Found UUID, now get it properties.";
+                                crow::connections::systemBus->async_method_call(
+                                    [aResp](
+                                        const boost::system::error_code ec,
+                                        const std::vector<
+                                            std::pair<std::string, VariantType>>
+                                            &properties) {
+                                        if (ec)
+                                        {
+                                            BMCWEB_LOG_DEBUG
+                                                << "DBUS response error " << ec;
+                                            aResp->res.result(
+                                                boost::beast::http::status::
+                                                    internal_server_error);
+                                            return;
+                                        }
+                                        BMCWEB_LOG_DEBUG << "Got "
+                                                         << properties.size()
+                                                         << "UUID properties.";
+                                        for (const std::pair<std::string,
+                                                             VariantType> &p :
+                                             properties)
+                                        {
+                                            if (p.first == "BIOSVer")
+                                            {
+                                                const std::string *value =
+                                                    mapbox::getPtr<
+                                                        const std::string>(
+                                                        p.second);
+                                                if (value != nullptr)
+                                                {
+                                                    aResp->res.jsonValue
+                                                        ["BiosVersion"] =
+                                                        *value;
+                                                }
+                                            }
+                                            if (p.first == "UUID")
+                                            {
+                                                const std::string *value =
+                                                    mapbox::getPtr<
+                                                        const std::string>(
+                                                        p.second);
+                                                BMCWEB_LOG_DEBUG
+                                                    << "UUID = " << *value
+                                                    << " length "
+                                                    << value->length();
+                                                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
+                                                            correctedValue =
+                                                                *value;
+                                                        correctedValue.append(
+                                                            32 -
+                                                                value->length(),
+                                                            '0');
+                                                        value = &correctedValue;
+                                                    }
+                                                    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);
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    },
+                                    s.first, path,
+                                    "org.freedesktop.DBus.Properties", "GetAll",
+                                    "xyz.openbmc_project.Common.UUID");
+                            }
+                        }
+                    }
+                }
+            }
+            if (foundName == false)
+            {
+                aResp->res.result(
+                    boost::beast::http::status::internal_server_error);
+            }
+        },
+        "xyz.openbmc_project.ObjectMapper",
+        "/xyz/openbmc_project/object_mapper",
+        "xyz.openbmc_project.ObjectMapper", "GetSubTree",
+        "/xyz/openbmc_project/inventory", int32_t(0), interfaces);
+}
+
+/**
+ * @brief Retrieves identify led group properties over dbus
+ *
+ * @param[in] aResp     Shared pointer for completing asynchronous calls.
+ * @param[in] callback  Callback for process retrieved data.
+ *
+ * @return None.
+ */
+template <typename CallbackFunc>
+void getLedGroupIdentify(std::shared_ptr<AsyncResp> aResp,
+                         CallbackFunc &&callback)
+{
+    BMCWEB_LOG_DEBUG << "Get led groups";
+    crow::connections::systemBus->async_method_call(
+        [aResp{std::move(aResp)},
+         &callback](const boost::system::error_code &ec,
+                    const ManagedObjectsType &resp) {
+            if (ec)
+            {
+                BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+                aResp->res.result(
+                    boost::beast::http::status::internal_server_error);
+                return;
+            }
+            BMCWEB_LOG_DEBUG << "Got " << resp.size() << "led group objects.";
+            for (const auto &objPath : resp)
+            {
+                const std::string &path = objPath.first;
+                if (path.rfind("enclosure_identify") != std::string::npos)
+                {
+                    for (const auto &interface : objPath.second)
+                    {
+                        if (interface.first == "xyz.openbmc_project.Led.Group")
+                        {
+                            for (const auto &property : interface.second)
+                            {
+                                if (property.first == "Asserted")
+                                {
+                                    const bool *asserted =
+                                        mapbox::getPtr<const bool>(
+                                            property.second);
+                                    if (nullptr != asserted)
+                                    {
+                                        callback(*asserted, aResp);
+                                    }
+                                    else
+                                    {
+                                        callback(false, aResp);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        "xyz.openbmc_project.LED.GroupManager",
+        "/xyz/openbmc_project/led/groups", "org.freedesktop.DBus.ObjectManager",
+        "GetManagedObjects");
+}
+
+template <typename CallbackFunc>
+void getLedIdentify(std::shared_ptr<AsyncResp> aResp, CallbackFunc &&callback)
+{
+    BMCWEB_LOG_DEBUG << "Get identify led properties";
+    crow::connections::systemBus->async_method_call(
+        [aResp{std::move(aResp)}, &callback](const boost::system::error_code ec,
+                                             const PropertiesType &properties) {
+            if (ec)
+            {
+                BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+                aResp->res.result(
+                    boost::beast::http::status::internal_server_error);
+                return;
+            }
+            BMCWEB_LOG_DEBUG << "Got " << properties.size()
+                             << "led properties.";
+            std::string output;
+            for (const auto &property : properties)
+            {
+                if (property.first == "State")
+                {
+                    const std::string *s =
+                        mapbox::getPtr<std::string>(property.second);
+                    if (nullptr != s)
+                    {
+                        BMCWEB_LOG_DEBUG << "Identify Led State: " << *s;
+                        const auto pos = s->rfind('.');
+                        if (pos != std::string::npos)
+                        {
+                            auto led = s->substr(pos + 1);
+                            for (const std::pair<const char *, const char *>
+                                     &p :
+                                 std::array<
+                                     std::pair<const char *, const char *>, 3>{
+                                     {{"On", "Lit"},
+                                      {"Blink", "Blinking"},
+                                      {"Off", "Off"}}})
+                            {
+                                if (led == p.first)
+                                {
+                                    output = p.second;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            callback(output, aResp);
+        },
+        "xyz.openbmc_project.LED.Controller.identify",
+        "/xyz/openbmc_project/led/physical/identify",
+        "org.freedesktop.DBus.Properties", "GetAll",
+        "xyz.openbmc_project.Led.Physical");
+}
+
+/**
+ * @brief Retrieves host state properties over dbus
+ *
+ * @param[in] aResp     Shared pointer for completing asynchronous calls.
+ *
+ * @return None.
+ */
+void getHostState(std::shared_ptr<AsyncResp> aResp)
+{
+    BMCWEB_LOG_DEBUG << "Get host information.";
+    crow::connections::systemBus->async_method_call(
+        [aResp{std::move(aResp)}](const boost::system::error_code ec,
+                                  const PropertiesType &properties) {
+            if (ec)
+            {
+                BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+                aResp->res.result(
+                    boost::beast::http::status::internal_server_error);
+                return;
+            }
+            BMCWEB_LOG_DEBUG << "Got " << properties.size()
+                             << "host properties.";
+            for (const auto &property : properties)
+            {
+                if (property.first == "CurrentHostState")
+                {
+                    const std::string *s =
+                        mapbox::getPtr<const std::string>(property.second);
+                    BMCWEB_LOG_DEBUG << "Host state: " << *s;
+                    if (nullptr != s)
+                    {
+                        const auto pos = s->rfind('.');
+                        if (pos != std::string::npos)
+                        {
+                            // Verify Host State
+                            if (s->substr(pos + 1) == "Running")
+                            {
+                                aResp->res.jsonValue["PowerState"] = "On";
+                                aResp->res.jsonValue["Status"]["State"] =
+                                    "Enabled";
+                            }
+                            else
+                            {
+                                aResp->res.jsonValue["PowerState"] = "Off";
+                                aResp->res.jsonValue["Status"]["State"] =
+                                    "Disabled";
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0",
+        "org.freedesktop.DBus.Properties", "GetAll",
+        "xyz.openbmc_project.State.Host");
+}
+
+/**
  * SystemsCollection derived class for delivering ComputerSystems Collection
  * Schema
  */
@@ -664,8 +614,8 @@
                const std::vector<std::string> &params) override
     {
         // Get board list, and call the below callback for JSON preparation
-        provider.getBaseboardList([&](const bool &success,
-                                      const std::vector<std::string> &output) {
+        getBaseboardList([&](const bool &success,
+                             const std::vector<std::string> &output) {
             if (success)
             {
                 // ... prepare json array with appropriate @odata.id links
@@ -688,8 +638,6 @@
             res.end();
         });
     }
-
-    OnDemandSystemsProvider provider;
 };
 
 /**
@@ -734,8 +682,6 @@
     }
 
   private:
-    OnDemandSystemsProvider provider;
-
     /**
      * Functions triggers appropriate requests on DBus
      */
@@ -758,14 +704,14 @@
 
         auto asyncResp = std::make_shared<AsyncResp>(res);
 
-        provider.getLedGroupIdentify(
+        getLedGroupIdentify(
             asyncResp,
             [&](const bool &asserted, const std::shared_ptr<AsyncResp> &aResp) {
                 if (asserted)
                 {
                     // If led group is asserted, then another call is needed to
                     // get led status
-                    provider.getLedIdentify(
+                    getLedIdentify(
                         aResp, [](const std::string &ledStatus,
                                   const std::shared_ptr<AsyncResp> &aResp) {
                             if (!ledStatus.empty())
@@ -780,8 +726,8 @@
                     aResp->res.jsonValue["IndicatorLED"] = "Off";
                 }
             });
-        provider.getComputerSystem(asyncResp, name);
-        provider.getHostState(asyncResp);
+        getComputerSystem(asyncResp, name);
+        getHostState(asyncResp);
     }
 
     void doPatch(crow::Response &res, const crow::Request &req,
@@ -832,8 +778,8 @@
         res.jsonValue = Node::json;
         res.jsonValue["@odata.id"] = "/redfish/v1/Systems/" + name;
 
-        provider.getHostState(asyncResp);
-        provider.getComputerSystem(asyncResp, name);
+        getHostState(asyncResp);
+        getComputerSystem(asyncResp, name);
 
         if (dbusLedState.empty())
         {
