Fix broken local and global building

Two things broke in the related patches. This patch aims to fix that.

1) tools/build.py was no longer usable as it imported kolla from the
global pip install source. If that didnt exist (because kolla wasn't
installed with pip) then it breaks on import.

2) When kolla was installed globally it looked up the path that
matched the installation of docker-py instead of looking up a path
that had the stuff we wanted (kolla images directory)

Change-Id: I94f1856547ce54d506de72926b08c966a36ac608
Related-Id: I05f10d13e7ba1e2b985c2944aec71ce55630442b
Related-Bug: #1530256
Closes-Bug: #1531569
This commit is contained in:
SamYaple 2016-01-06 19:28:45 +00:00
parent ecfc955a7e
commit ea5fa4e248

View File

@ -38,6 +38,15 @@ from requests.exceptions import ConnectionError
import six import six
from six.moves import range from six.moves import range
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), '../..'))
# NOTE(SamYaple): Update the search patch to prefer PROJECT_ROOT as the source
# of packages to import if we are using local tools/build.py
# instead of pip installed kolla-build tool
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
from kolla.common import config as common_config from kolla.common import config as common_config
from kolla import version from kolla import version
@ -47,9 +56,6 @@ LOG.setLevel(logging.INFO)
signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGINT, signal.SIG_DFL)
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), '../..'))
class KollaDirNotFoundException(Exception): class KollaDirNotFoundException(Exception):
pass pass
@ -330,7 +336,10 @@ class KollaWorker(object):
for path in possible_paths: for path in possible_paths:
image_path = os.path.join(path, 'docker') image_path = os.path.join(path, 'docker')
if os.path.exists(image_path): # NOTE(SamYaple): We explicty check for the base folder to ensure
# this is the correct path
# TODO(SamYaple): Improve this to make this safer
if os.path.exists(os.path.join(image_path, 'base')):
LOG.info('Found the docker image folder at %s', image_path) LOG.info('Found the docker image folder at %s', image_path)
return image_path return image_path
else: else: