Fix the kolla to find the docker image folder in virtualenv
Closes-Bug:#1530256 Change-Id: I05f10d13e7ba1e2b985c2944aec71ce55630442b
This commit is contained in:
parent
620d610eaa
commit
e32f5c52a4
@ -19,7 +19,6 @@ import errno
|
|||||||
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
|
||||||
@ -47,6 +46,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
|
||||||
@ -276,34 +278,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
|
||||||
@ -342,6 +321,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.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user