Set Chassis Intrusion status dynamically

Set the Chassis Intrusion status in the Get Chassis Status command
dynamically by checking for the Chassis Intrusion service.

Tested:
Chassis Intrusion status is set as active on a platform with the service
running.  Chassis Intrusion status is set as inactive on a platform
without the service running.

Signed-off-by: Matt Simmering <matthew.simmering@intel.com>
Change-Id: I5eb503d3d0b456aad5c6b16a585aa10e18e8a0e1
diff --git a/src/chassiscommands.cpp b/src/chassiscommands.cpp
index edea2ea..4f748ff 100644
--- a/src/chassiscommands.cpp
+++ b/src/chassiscommands.cpp
@@ -498,6 +498,26 @@
         return ipmi::responseUnspecifiedError();
     }
 
+    bool chassisIntrusionActive = false;
+    try
+    {
+        constexpr const char* chassisIntrusionObj =
+            "/xyz/openbmc_project/Intrusion/Chassis_Intrusion";
+        constexpr const char* chassisIntrusionInf =
+            "xyz.openbmc_project.Chassis.Intrusion";
+
+        std::string intrusionService;
+        boost::system::error_code ec = ipmi::getService(
+            ctx, chassisIntrusionInf, chassisIntrusionObj, intrusionService);
+
+        chassisIntrusionActive = !intrusionService.empty();
+    }
+    catch (const std::exception& e)
+    {
+        log<level::ERR>("Failed to get Chassis Intrusion service",
+                        entry("ERROR=%s", e.what()));
+    }
+
     // This response has a lot of hard-coded, unsupported fields
     // They are set to false or 0
     constexpr bool powerOverload = false;
@@ -507,7 +527,6 @@
     constexpr bool powerDownOverload = false;
     constexpr bool powerDownInterlock = false;
     constexpr bool powerDownPowerFault = false;
-    constexpr bool chassisIntrusionActive = false;
     constexpr bool frontPanelLockoutActive = false;
     constexpr bool driveFault = false;
     constexpr bool coolingFanFault = false;