Skip to content
Snippets Groups Projects
Commit ecfc955a authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review
Browse files

Merge "Fix the kolla to find the docker image folder in virtualenv"

parents ff8ff410 e32f5c52
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,6 @@ import graphviz ...@@ -20,7 +20,6 @@ import graphviz
import json import json
import logging import logging
import os import os
import platform
import re import re
import requests import requests
import shutil import shutil
...@@ -48,6 +47,9 @@ LOG.setLevel(logging.INFO) ...@@ -48,6 +47,9 @@ 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
...@@ -277,34 +279,11 @@ class WorkerThread(Thread): ...@@ -277,34 +279,11 @@ class WorkerThread(Thread):
self.push_queue.put(image) self.push_queue.put(image)
def find_os_type():
return platform.linux_distribution()
def find_base_dir():
script_path = os.path.dirname(os.path.realpath(sys.argv[0]))
if os.path.basename(script_path) == 'cmd':
return os.path.realpath(os.path.join(script_path, '..', '..'))
if os.path.basename(script_path) == 'bin':
if find_os_type()[0] in ['Ubuntu', 'debian']:
return '/usr/local/share/kolla'
else:
return '/usr/share/kolla'
if os.path.exists(os.path.join(script_path, 'tests')):
return script_path
raise KollaDirNotFoundException(
'I do not know where your Kolla directory is'
)
class KollaWorker(object): class KollaWorker(object):
def __init__(self, conf): def __init__(self, conf):
self.conf = conf self.conf = conf
self.base_dir = os.path.abspath(find_base_dir()) self.images_dir = self._get_images_dir()
LOG.debug("Kolla base directory: " + self.base_dir)
self.images_dir = os.path.join(self.base_dir, 'docker')
self.registry = conf.registry self.registry = conf.registry
if self.registry: if self.registry:
self.namespace = self.registry + '/' + conf.namespace self.namespace = self.registry + '/' + conf.namespace
...@@ -343,6 +322,20 @@ class KollaWorker(object): ...@@ -343,6 +322,20 @@ class KollaWorker(object):
self.image_statuses_unmatched = dict() self.image_statuses_unmatched = dict()
self.maintainer = conf.maintainer self.maintainer = conf.maintainer
def _get_images_dir(self):
possible_paths = (
PROJECT_ROOT,
os.path.join(sys.prefix, 'share/kolla'),
os.path.join(sys.prefix, 'local/share/kolla'))
for path in possible_paths:
image_path = os.path.join(path, 'docker')
if os.path.exists(image_path):
LOG.info('Found the docker image folder at %s', image_path)
return image_path
else:
raise KollaDirNotFoundException('Image dir can not be found')
def build_rpm_setup(self, rpm_setup_config): def build_rpm_setup(self, rpm_setup_config):
"""Generates a list of docker commands based on provided configuration. """Generates a list of docker commands based on provided configuration.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment