blob: 8f7f07815c872c8a90ec340e4e1f1b92061268b9 [file] [log] [blame]
Shad Ansarid88692c2022-02-01 22:47:43 +00001"""
2SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
3SPDX-License-Identifier: LicenseRef-ONF-Member-1.01
4"""
5
Shad Ansarid88692c2022-02-01 22:47:43 +00006import subprocess
Shad Ansari0508ddf2022-03-24 03:16:51 +00007# import logging as log
Shad Ansarid88692c2022-02-01 22:47:43 +00008
9
10def ping(host):
Shad Ansari0508ddf2022-03-24 03:16:51 +000011 # log.debug("Pinging {}".format(host))
12 if host is not None:
Shad Ansarice3c67b2022-02-10 21:00:25 +000013 return subprocess.call(["ping", "-c", "2", "-W", "2", host],
Shad Ansarid88692c2022-02-01 22:47:43 +000014 stdout=subprocess.DEVNULL,
15 stderr=subprocess.STDOUT) == 0
16 else:
17 return False