Merge "Few improvements in Kolla tools. Added Ubuntu support."
This commit is contained in:
commit
b178ed2021
@ -20,6 +20,7 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import Queue
|
import Queue
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
@ -189,11 +190,18 @@ class WorkerThread(Thread):
|
|||||||
LOG.info('{}:Built'.format(image['name']))
|
LOG.info('{}:Built'.format(image['name']))
|
||||||
|
|
||||||
|
|
||||||
|
def find_os_type():
|
||||||
|
return platform.linux_distribution()
|
||||||
|
|
||||||
|
|
||||||
def find_base_dir():
|
def find_base_dir():
|
||||||
script_path = os.path.dirname(os.path.realpath(sys.argv[0]))
|
script_path = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||||
if os.path.basename(script_path) == 'cmd':
|
if os.path.basename(script_path) == 'cmd':
|
||||||
return os.path.realpath(os.path.join(script_path, '..', '..'))
|
return os.path.realpath(os.path.join(script_path, '..', '..'))
|
||||||
if os.path.basename(script_path) == 'bin':
|
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'
|
return '/usr/share/kolla'
|
||||||
if os.path.exists(os.path.join(script_path, 'tests')):
|
if os.path.exists(os.path.join(script_path, 'tests')):
|
||||||
return script_path
|
return script_path
|
||||||
@ -203,13 +211,18 @@ def find_base_dir():
|
|||||||
|
|
||||||
|
|
||||||
def find_config_file(filename):
|
def find_config_file(filename):
|
||||||
filepath = os.path.join('/etc/kolla', filename)
|
global_conf_path = os.path.join('/etc/kolla', filename)
|
||||||
if os.access(filepath, os.R_OK):
|
local_conf_path = os.path.join(find_base_dir(), 'etc', 'kolla', filename)
|
||||||
config_file = filepath
|
|
||||||
|
if os.access(global_conf_path, os.R_OK):
|
||||||
|
return global_conf_path
|
||||||
|
elif os.access(local_conf_path, os.R_OK):
|
||||||
|
return local_conf_path
|
||||||
else:
|
else:
|
||||||
config_file = os.path.join(find_base_dir(),
|
raise KollaDirNotFoundException(
|
||||||
'etc', 'kolla', filename)
|
'Cant find kolla config. Searched at: %s and %s' %
|
||||||
return config_file
|
(global_conf_path, local_conf_path)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def merge_args_and_config(settings_from_config_file):
|
def merge_args_and_config(settings_from_config_file):
|
||||||
|
@ -7,6 +7,8 @@ function find_base_dir {
|
|||||||
local dir_name="$(dirname "$real_path")"
|
local dir_name="$(dirname "$real_path")"
|
||||||
if [[ ${dir_name} == "/usr/bin" ]]; then
|
if [[ ${dir_name} == "/usr/bin" ]]; then
|
||||||
BASEDIR=/usr/share/kolla
|
BASEDIR=/usr/share/kolla
|
||||||
|
elif [[ ${dir_name} == "/usr/local/bin" ]]; then
|
||||||
|
BASEDIR=/usr/local/share/kolla
|
||||||
else
|
else
|
||||||
BASEDIR="${dir_name}/.."
|
BASEDIR="${dir_name}/.."
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user