Set Sel time response code fixed in ntp mode

While setting the SEl time via Set Sel Time command with NTP enabled,
getting unspecified error.

SEL time can be set in Manual mode only. See Time Settings section in below link.

https://github.com/openbmc/phosphor-time-manager

TESTED:

before:

busctl get-property  xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeS
yncMethod
s "xyz.openbmc_project.Time.Synchronization.Method.NTP"

ipmitool raw 0x0A 0x49 0x51 0xEF 0x99 0x07
Unable to send RAW command (channel=0x0 netfn=0xa lun=0x0 cmd=0x49 rsp=0xff): Unspecified error

After:

busctl get-property  xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeS
yncMethod
s "xyz.openbmc_project.Time.Synchronization.Method.NTP"

ipmitool raw 0x0a 0x49 0xfe 0x0e 0x0 0x01
Unable to send RAW command (channel=0x0 netfn=0xa lun=0x0 cmd=0x49 rsp=0xd5): Command not supported in present state

Signed-off-by: shamim ali <shamima@ami.com>
Change-Id: If415a1a7c1e862cbbd4a724bb32390cf01d0f450
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 2b9013a..bd31314 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -42,6 +42,10 @@
 constexpr uint8_t eventDataSize = 3;
 namespace
 {
+constexpr auto SystemdTimeService = "org.freedesktop.timedate1";
+constexpr auto SystemdTimePath = "/org/freedesktop/timedate1";
+constexpr auto SystemdTimeInterface = "org.freedesktop.timedate1";
+
 constexpr auto TIME_INTERFACE = "xyz.openbmc_project.Time.EpochTime";
 constexpr auto BMC_TIME_PATH = "/xyz/openbmc_project/time/bmc";
 constexpr auto DBUS_PROPERTIES = "org.freedesktop.DBus.Properties";
@@ -597,6 +601,14 @@
     try
     {
         sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
+        bool ntp = std::get<bool>(
+            ipmi::getDbusProperty(bus, SystemdTimeService, SystemdTimePath,
+                                  SystemdTimeInterface, "NTP"));
+        if (ntp)
+        {
+            return ipmi::responseCommandNotAvailable();
+        }
+
         auto service = ipmi::getService(bus, TIME_INTERFACE, BMC_TIME_PATH);
         std::variant<uint64_t> value{(uint64_t)usec.count()};