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
(cherry picked from commit 6e36349d84)
This commit is contained in:
Vladimir Kuklin 2016-12-13 17:20:51 +03:00 committed by Alexey Shtokolov
parent 392b70480b
commit 3f817851d8
1 changed files with 4 additions and 2 deletions

View File

@ -17,6 +17,7 @@ import logging
import re
import requests
import types
import urlparse
import six
import urwid
@ -31,7 +32,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"
@ -351,7 +352,8 @@ class bootstrapimg(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