Add ServiceLabel information for PowerSupply

This commit is to add Location/PartLocation/ServiceLabel information
according to the Redfish PowerSupply schema.
If the `xyz.openbmc_project.Inventory.Decorator.LocationCode`
interface does not exist, the ServiceLabel information property is
not displayed.

ref: http://redfish.dmtf.org/schemas/v1/PowerSupply.v1_5_0.json

Tested: Validator passes
curl -k -H "X-Auth-Token: $token" -X GET
https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem/
PowerSupplies/powersupply0
{
"@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem/
              PowerSupplies/powersupply0",
"@odata.type": "#PowerSupply.v1_5_0.PowerSupply",
"FirmwareVersion": "383239323732",
"Id": "powersupply0",
"Location": {
"PartLocation": {
"ServiceLabel": "U78DA.ND0.WZS00F6-E0"
}
},
"Manufacturer": "",
"Model": "51E9",
"Name": "powersupply0",
"PartNumber": "03KP466",
"SerialNumber": "YL10KY26E073",
"SparePartNumber": "03FP378",
"Status": {
"Health": "OK"
}
}

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Icd0c21719bb01f481a8cd4c56bdb1a9ee047b047
diff --git a/Redfish.md b/Redfish.md
index dbbbfd1..ca33c81 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -380,6 +380,7 @@
 ##### PowerSupply
 
 - FirmwareVersion
+- Location
 - Manufacturer
 - Model
 - PartNumber
diff --git a/redfish-core/lib/power_supply.hpp b/redfish-core/lib/power_supply.hpp
index 4fc0ce9..190352a 100644
--- a/redfish-core/lib/power_supply.hpp
+++ b/redfish-core/lib/power_supply.hpp
@@ -334,6 +334,30 @@
 }
 
 inline void
+    getPowerSupplyLocation(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+                           const std::string& service, const std::string& path)
+{
+    sdbusplus::asio::getProperty<std::string>(
+        *crow::connections::systemBus, service, path,
+        "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
+        [asyncResp](const boost::system::error_code& ec,
+                    const std::string& value) {
+        if (ec)
+        {
+            if (ec.value() != EBADR)
+            {
+                BMCWEB_LOG_ERROR << "DBUS response error for Location "
+                                 << ec.value();
+                messages::internalError(asyncResp->res);
+            }
+            return;
+        }
+        asyncResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+            value;
+        });
+}
+
+inline void
     doPowerSupplyGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                      const std::string& chassisId,
                      const std::string& powerSupplyId,
@@ -384,6 +408,8 @@
                                 powerSupplyPath);
             getPowerSupplyFirmwareVersion(asyncResp, object.begin()->first,
                                           powerSupplyPath);
+            getPowerSupplyLocation(asyncResp, object.begin()->first,
+                                   powerSupplyPath);
             });
     });
 }