[PTP] Fix startup crash with bad override.

During tests with the ptp-notification app it was observed that a bad
override could crash the startup script of ptptracking (notification
service). This minor change fixes that.

Test Plan:
PASS: Build and deploy new ptptracking image
PASS: Startup of ptptracking container

Story: 2010056
Task: 46496

Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
Change-Id: I659e0e1bc812cca73b34079f4cf207a91843dfdc
This commit is contained in:
Douglas Henrique Koerich 2022-09-30 18:04:32 -03:00
parent 34c945ed39
commit 30f691a06b

View File

@ -55,17 +55,19 @@ OS_CLOCK_POLL_FREQ_SECONDS = os.environ.get("OS_CLOCK_POLL_FREQ_SECONDS", 2)
OVERALL_HOLDOVER_SECONDS = os.environ.get("OVERALL_HOLDOVER_SECONDS", 30)
OVERALL_POLL_FREQ_SECONDS = os.environ.get("OVERALL_POLL_FREQ_SECONDS", 2)
PHC2SYS_CONFIG = None
PHC2SYS_SERVICE_NAME = None
if os.environ.get("PHC2SYS_SERVICE_NAME").lower() == "false":
LOG.info("OS Clock tracking disabled.")
PHC2SYS_CONFIG = None
else:
PHC2SYS_CONFIG = glob.glob("/ptp/ptpinstance/phc2sys-*")
if len(PHC2SYS_CONFIG) == 0:
PHC2SYS_CONFIGS = glob.glob("/ptp/ptpinstance/phc2sys-*")
if len(PHC2SYS_CONFIGS) == 0:
LOG.warning("No phc2sys config found.")
PHC2SYS_CONFIG = None
elif len(PHC2SYS_CONFIG) > 1:
LOG.warning("Multiple phc2sys instances found, selecting %s" % PHC2SYS_CONFIG[0])
PHC2SYS_CONFIG = PHC2SYS_CONFIG[0]
else:
PHC2SYS_CONFIG = PHC2SYS_CONFIGS[0]
if len(PHC2SYS_CONFIGS) > 1:
LOG.warning("Multiple phc2sys instances found, selecting %s" %
PHC2SYS_CONFIG)
pattern = '(?<=/ptp/ptpinstance/phc2sys-).*(?=.conf)'
match = re.search(pattern, PHC2SYS_CONFIG)
PHC2SYS_SERVICE_NAME = match.group()