X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=apex%2Fcommon%2Futils.py;h=b727b11aad5bc058c8302f78e92bd337eec2cfc9;hb=2beef21903d7a36bdac19b3170003043693562dd;hp=0328a3b5cc494d8f6b94083c52c9187df232ebec;hpb=2111e5a85f8d0a894e1a7684c2e1a6d897091c9d;p=apex.git diff --git a/apex/common/utils.py b/apex/common/utils.py index 0328a3b5..b727b11a 100644 --- a/apex/common/utils.py +++ b/apex/common/utils.py @@ -13,6 +13,7 @@ import json import logging import os import pprint +import socket import subprocess import tarfile import time @@ -210,3 +211,12 @@ def install_ansible(): subprocess.check_call([pkg_mgr, '-y', 'install', 'ansible']) except subprocess.CalledProcessError: logging.warning('Unable to install Ansible') + + +def internet_connectivity(): + try: + urllib.request.urlopen('http://opnfv.org', timeout=3) + return True + except (urllib.request.URLError, socket.timeout): + logging.debug('No internet connectivity detected') + return False