diff options
author | Feng Pan <fpan@redhat.com> | 2018-02-16 21:27:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-02-16 21:27:59 +0000 |
commit | a4f70cb1db40eac845c2df17158e77163c887ff1 (patch) | |
tree | 829fe4ddf906d429695cb5a5b5cd6d2e0ed595c0 /apex/common/utils.py | |
parent | 5443898e7a1927d8e3cd35e70e3872ed5d9a6d97 (diff) | |
parent | 2beef21903d7a36bdac19b3170003043693562dd (diff) |
Merge "Fixes stale undercloud delorean repos"
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 |