psu-ng: Fix chassis association call

The association name from a power supply to its chassis changed from
'chassis' to 'powering', so change that in the code.

Also update the code to find the association using the new
GetAssociatedSubTreePaths mapper method which is like the existing
GetSubTreePaths but also ensures the results are an endpoint of the
passed in association path.  This way if the 'powering' association is
used to show the power supply powers other things it will still work.

Change-Id: I9076a6b1502ba43a29404a191bd8bc56a9c5df45
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/phosphor-power-supply/util.hpp b/phosphor-power-supply/util.hpp
index 01f5b0b..b09731a 100644
--- a/phosphor-power-supply/util.hpp
+++ b/phosphor-power-supply/util.hpp
@@ -199,21 +199,22 @@
     std::string getChassis(sdbusplus::bus_t& bus,
                            const std::string& invpath) const
     {
-        // Use the 'chassis' association to find the parent chassis.
-        auto assocPath = invpath + "/chassis";
-        std::vector<std::string> endpoints;
+        sdbusplus::message::object_path assocPath = invpath + "/powering";
+        sdbusplus::message::object_path basePath{"/"};
+        std::vector<std::string> interfaces{CHASSIS_IFACE};
 
-        phosphor::power::util::getProperty<decltype(endpoints)>(
-            ASSOCIATION_IFACE, ENDPOINTS_PROP, assocPath,
-            "xyz.openbmc_project.ObjectMapper", bus, endpoints);
+        // Find the object path that implements the chassis interface
+        // and also shows up in the endpoints list of the powering assoc.
+        auto chassisPaths = phosphor::power::util::getAssociatedSubTreePaths(
+            bus, assocPath, basePath, interfaces, 0);
 
-        if (endpoints.empty())
+        if (chassisPaths.empty())
         {
-            throw std::runtime_error(
-                fmt::format("Missing chassis association for {}", invpath));
+            throw std::runtime_error(fmt::format(
+                "No association to a chassis found for {}", invpath));
         }
 
-        return endpoints[0];
+        return chassisPaths[0];
     }
 };