blob: 14d47f2b294214f53b810e5637b3a98398727f14 [file] [log] [blame]
Shad Ansarid88692c2022-02-01 22:47:43 +00001"""
Shad Ansarib046c152022-06-07 14:34:14 -07002SPDX-FileCopyrightText: 2022-present Intel Corporation
Shad Ansarid88692c2022-02-01 22:47:43 +00003SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org>
Shad Ansarib046c152022-06-07 14:34:14 -07004SPDX-License-Identifier: Apache-2.0
Shad Ansarid88692c2022-02-01 22:47:43 +00005"""
6
Shad Ansarid88692c2022-02-01 22:47:43 +00007import subprocess
Shad Ansari0508ddf2022-03-24 03:16:51 +00008# import logging as log
Shad Ansarid88692c2022-02-01 22:47:43 +00009
10
11def ping(host):
Shad Ansari0508ddf2022-03-24 03:16:51 +000012 # log.debug("Pinging {}".format(host))
13 if host is not None:
Shad Ansarice3c67b2022-02-10 21:00:25 +000014 return subprocess.call(["ping", "-c", "2", "-W", "2", host],
Shad Ansarid88692c2022-02-01 22:47:43 +000015 stdout=subprocess.DEVNULL,
16 stderr=subprocess.STDOUT) == 0
17 else:
18 return False