redfish: Add Chassis listing associated drive

If chassis has drives a drive url is added to the chassis, of the form:
redfish/v1/Chassis/<chassis>/Drives

When queried, the drive URL will list all drives associated with the
chassis. This is in accordance with the redfish schema.

Samples for the following URLs are below

wget -qO- http://localhost:80/redfish/v1/Chassis/DC_SCM/Drives
{
  "@odata.id": "/redfish/v1/Chassis/DC_SCM/Drives",
  "@odata.type": "#DriveCollection.DriveCollection",
  "Members": [
    {
      "@odata.id": "/redfish/v1/Chassis/DC_SCM/Drives/mmcblk0"
    }
  ],
  "Members@odata.count": "1",
  "Name": "Drive Collection"
}

Tested:
With the redfish validator: No new errors

Change-Id: Ibdbe7fee5014d6515a77683c8eaca9ca86b6b148
Signed-off-by: John Edward Broadbent <jebr@google.com>
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 2961513..181ef3d 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -284,6 +284,24 @@
                 asyncResp->res.jsonValue["PCIeDevices"]["@odata.id"] =
                     "/redfish/v1/Systems/system/PCIeDevices";
 
+                sdbusplus::asio::getProperty<std::vector<std::string>>(
+                    *crow::connections::systemBus,
+                    "xyz.openbmc_project.ObjectMapper", path + "/drive",
+                    "xyz.openbmc_project.Association", "endpoints",
+                    [asyncResp,
+                     chassisId](const boost::system::error_code ec3,
+                                const std::vector<std::string>& resp) {
+                    if (ec3 || resp.empty())
+                    {
+                        return; // no drives = no failures
+                    }
+
+                    nlohmann::json reference;
+                    reference["odata.id"] = crow::utility::urlFromPieces(
+                        "redfish", "v1", "Chassis", chassisId, "Drives");
+                    asyncResp->res.jsonValue["Drives"] = std::move(reference);
+                    });
+
                 const std::string& connectionName = connectionNames[0].first;
 
                 const std::vector<std::string>& interfaces2 =