Shad Ansari | d88692c | 2022-02-01 22:47:43 +0000 | [diff] [blame] | 1 | """ |
Shad Ansari | 7e28dc6 | 2022-06-07 13:43:22 -0700 | [diff] [blame^] | 2 | SPDX-FileCopyrightText: 2020-present Intel Corporation |
Shad Ansari | d88692c | 2022-02-01 22:47:43 +0000 | [diff] [blame] | 3 | SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org> |
| 4 | SPDX-License-Identifier: LicenseRef-ONF-Member-1.01 |
| 5 | """ |
| 6 | |
Shad Ansari | d88692c | 2022-02-01 22:47:43 +0000 | [diff] [blame] | 7 | import subprocess |
Shad Ansari | 0508ddf | 2022-03-24 03:16:51 +0000 | [diff] [blame] | 8 | # import logging as log |
Shad Ansari | d88692c | 2022-02-01 22:47:43 +0000 | [diff] [blame] | 9 | |
| 10 | |
| 11 | def ping(host): |
Shad Ansari | 0508ddf | 2022-03-24 03:16:51 +0000 | [diff] [blame] | 12 | # log.debug("Pinging {}".format(host)) |
| 13 | if host is not None: |
Shad Ansari | ce3c67b | 2022-02-10 21:00:25 +0000 | [diff] [blame] | 14 | return subprocess.call(["ping", "-c", "2", "-W", "2", host], |
Shad Ansari | d88692c | 2022-02-01 22:47:43 +0000 | [diff] [blame] | 15 | stdout=subprocess.DEVNULL, |
| 16 | stderr=subprocess.STDOUT) == 0 |
| 17 | else: |
| 18 | return False |