Refactor getAssociationEndPoints method

Since the getAssociationEndPoints method has been implemented in
dbus_utility and this commit is to integrate all the places where the
endpoints attribute is obtained, and use the method in dbus_utility
uniformly.

Tested:
1. Redfish Validator Passed
2. For all the endpoints we changed, we got the same result as before

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I91a5e80de5bc3b5712c2d5b81f2f8b982d1c884e
diff --git a/redfish-core/lib/pcie_slots.hpp b/redfish-core/lib/pcie_slots.hpp
index 42c8bb1..2b9ef2b 100644
--- a/redfish-core/lib/pcie_slots.hpp
+++ b/redfish-core/lib/pcie_slots.hpp
@@ -151,7 +151,7 @@
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
     const std::string& chassisID, const std::string& pcieSlotPath,
     const std::string& connectionName, const boost::system::error_code& ec,
-    const std::variant<std::vector<std::string>>& endpoints)
+    const dbus::utility::MapperEndPoints& pcieSlotChassis)
 {
     if (ec)
     {
@@ -165,24 +165,14 @@
         return;
     }
 
-    const std::vector<std::string>* pcieSlotChassis =
-        std::get_if<std::vector<std::string>>(&(endpoints));
-
-    if (pcieSlotChassis == nullptr)
-    {
-        BMCWEB_LOG_ERROR << "Error getting PCIe Slot association!";
-        messages::internalError(asyncResp->res);
-        return;
-    }
-
-    if (pcieSlotChassis->size() != 1)
+    if (pcieSlotChassis.size() != 1)
     {
         BMCWEB_LOG_ERROR << "PCIe Slot association error! ";
         messages::internalError(asyncResp->res);
         return;
     }
 
-    sdbusplus::message::object_path path((*pcieSlotChassis)[0]);
+    sdbusplus::message::object_path path(pcieSlotChassis[0]);
     std::string chassisName = path.filename();
     if (chassisName != chassisID)
     {
@@ -239,17 +229,14 @@
 
             // The association of this PCIeSlot is used to determine whether
             // it belongs to this ChassisID
-            crow::connections::systemBus->async_method_call(
+            dbus::utility::getAssociationEndPoints(
+                std::string{pcieSlotAssociationPath},
                 [asyncResp, chassisID, pcieSlotPath, connectionName](
                     const boost::system::error_code& ec2,
-                    const std::variant<std::vector<std::string>>& endpoints) {
+                    const dbus::utility::MapperEndPoints& endpoints) {
                 onMapperAssociationDone(asyncResp, chassisID, pcieSlotPath,
                                         connectionName, ec2, endpoints);
-                },
-                "xyz.openbmc_project.ObjectMapper",
-                std::string{pcieSlotAssociationPath},
-                "org.freedesktop.DBus.Properties", "Get",
-                "xyz.openbmc_project.Association", "endpoints");
+                });
         }
     }
 }