From 6e36349d849c7509ff52e96bae2fa5ec6f6d5110 Mon Sep 17 00:00:00 2001 From: Vladimir Kuklin Date: Tue, 13 Dec 2016 17:20:51 +0300 Subject: [PATCH] Fix local repo matching for bootstrap image checker Use urlparse to fetch location part and match it against a simple localhost regexp Change-Id: I09ade41fc644545526dbd082ef3ca4967a7bf57c Closes-bug: #1628880 --- fuelmenu/modules/bootstrapimg.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fuelmenu/modules/bootstrapimg.py b/fuelmenu/modules/bootstrapimg.py index 6694970..a48362c 100644 --- a/fuelmenu/modules/bootstrapimg.py +++ b/fuelmenu/modules/bootstrapimg.py @@ -17,6 +17,7 @@ import logging import re import requests import types +import urlparse import six import urwid @@ -29,7 +30,7 @@ from fuelmenu.common import utils log = logging.getLogger('fuelmenu.mirrors') blank = urwid.Divider() -local_repo_pattern = re.compile(r'^http[s]?://(127.0.0.1|localhost)([:/].*)?$') +localhost_pattern = re.compile(r'(127.0.0.1|localhost)') BOOTSTRAP_HTTP_PROXY_KEY = "BOOTSTRAP/http_proxy" @@ -354,7 +355,8 @@ class BootstrapImage(urwid.WidgetWrap): def _check_repo(self, base_url, suite, proxies): release_url = '{base_url}/dists/{suite}/Release'.format( base_url=base_url, suite=suite) - if (local_repo_pattern.search(release_url) and + host = urlparse.urlparse(release_url).netloc.split(':')[0] + if (localhost_pattern.search(host) and utils.is_pre_deployment()): # Due to pre-deployment stage we can't check accessibility of local # repository since it is not created at that moment. Although we