psu-ng: Do not log error for expected missing PSUs

Some systems like Rainier 2U support less PSUs than the number of PSU
slots. Therefore, check the expected number of PSUs in the supported
configuration and log an error for missing PSUs if the total number does
not match. Continue to set the Fault for the PSU that's not present to
mark it as already checked, to avoid creating multiple errors.

Tested: Verified on Rainier 2U that no error log was created for missing
        PSU.

Change-Id: Ie9a512b2e10a9a63a2007b0559a1b7368828e351
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index 1940eea..08b103d 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -354,20 +354,25 @@
 
     if (powerOn)
     {
+        std::map<std::string, std::string> additionalData;
+        auto requiredPSUsPresent = hasRequiredPSUs(additionalData);
+
         for (auto& psu : psus)
         {
-            std::map<std::string, std::string> additionalData;
             additionalData["_PID"] = std::to_string(getpid());
             // TODO: Fault priorities #918
             if (!psu->isFaultLogged() && !psu->isPresent())
             {
-                // Create error for power supply missing.
-                additionalData["CALLOUT_INVENTORY_PATH"] =
-                    psu->getInventoryPath();
-                additionalData["CALLOUT_PRIORITY"] = "H";
-                createError(
-                    "xyz.openbmc_project.Power.PowerSupply.Error.Missing",
-                    additionalData);
+                if (!requiredPSUsPresent)
+                {
+                    // Create error for power supply missing.
+                    additionalData["CALLOUT_INVENTORY_PATH"] =
+                        psu->getInventoryPath();
+                    additionalData["CALLOUT_PRIORITY"] = "H";
+                    createError(
+                        "xyz.openbmc_project.Power.PowerSupply.Error.Missing",
+                        additionalData);
+                }
                 psu->setFaultLogged();
             }
             else if (!psu->isFaultLogged() && psu->isFaulted())