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