From 2beef21903d7a36bdac19b3170003043693562dd Mon Sep 17 00:00:00 2001 From: Tim Rozet Date: Fri, 16 Feb 2018 10:45:55 -0500 Subject: Fixes stale undercloud delorean repos When we build artifacts for release, we try to freeze the disk images and artifacts we use for deployment. This includes the delorean repo which provides OpenStack packages. This repo however expires after a couple months and then if any packages were missing in the Undercloud released artifact, they will attempt to be downloaded during install and fail. This patch adds some logic to detect if there is internet connectivity, and if so then download and update the delorean repo on the undercloud. JIRA: APEX-565 Change-Id: I58c28437fb5c5b179033c939377fd97aefbf427c Signed-off-by: Tim Rozet --- apex/common/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apex/common/utils.py') 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 -- cgit 1.2.3-korg