diff --git a/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/os_clock_monitor.py b/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/os_clock_monitor.py index 169701a..9c3b533 100644 --- a/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/os_clock_monitor.py +++ b/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/common/helpers/os_clock_monitor.py @@ -100,12 +100,17 @@ class OsClockMonitor: pattern = "/hostsys/class/net/" + self.phc_interface + "/device/ptp/*" ptp_device = glob(pattern) if len(ptp_device) == 0: - LOG.error("No ptp device found at %s" % pattern) - return None + # Try the 0th interface instead, required for some NIC types + phc_interface_base = self.phc_interface[:-1] + "0" + LOG.error("No ptp device found at %s trying %s instead" % (pattern, phc_interface_base)) + pattern = "/hostsys/class/net/" + phc_interface_base + "/device/ptp/*" + ptp_device = glob(pattern) + if len(ptp_device) == 0: + LOG.warning("No ptp device found for base interface at %s" % pattern) + return None if len(ptp_device) > 1: LOG.error("More than one ptp device found at %s" % pattern) return None - ptp_device = os.path.basename(ptp_device[0]) LOG.debug("Found ptp device %s at %s" % (ptp_device, pattern)) return ptp_device diff --git a/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_os_clock_monitor.py b/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_os_clock_monitor.py index 6682c58..805796b 100644 --- a/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_os_clock_monitor.py +++ b/notificationservice-base/docker/ptptrackingfunction/trackingfunctionsdk/tests/test_os_clock_monitor.py @@ -52,6 +52,7 @@ class OsClockMonitorTests(unittest.TestCase): side_effect=[['/hostsys/class/net/ens1f0/device/ptp/ptp0'], ['/hostsys/class/net/ens1f0/device/ptp/ptp0', '/hostsys/class/net/ens1f0/device/ptp/ptp1'], + [], [] ]) def test_get_interface_phc_device(self, glob_patched):