Skip to content

Commit

Permalink
catch exception for nonexistent service in is_service_running.
Browse files Browse the repository at this point in the history
  • Loading branch information
hdwhdw committed Jan 2, 2025
1 parent df7cfc4 commit e2568f7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/common/devices/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,12 @@ def is_host_service_running(self, service):
@param service: Service name
@return: True if specified service is running, else False
"""
service_status = self.shell("sudo systemctl status {} | grep 'Active'".format(service))
try:
service_status = self.shell("sudo systemctl status {} | grep 'Active'".format(service))
except RunAnsibleModuleFail as e:
if 'could not be found' in e.results['stderr']:
return False
raise
return "active (running)" in service_status['stdout']

def critical_services_status(self):
Expand Down

0 comments on commit e2568f7

Please sign in to comment.