diff options
Diffstat (limited to 'apex/common/utils.py')
-rw-r--r-- | apex/common/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
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 |