Add support for deployment from git.
This commit is contained in:
commit
0433af560a
@ -16,9 +16,15 @@ from charmhelpers.contrib.openstack.utils import (
|
||||
git_install_requested,
|
||||
git_clone_and_install,
|
||||
git_src_dir,
|
||||
git_pip_venv_dir,
|
||||
git_yaml_value,
|
||||
configure_installation_source,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.python.packages import (
|
||||
pip_install,
|
||||
)
|
||||
|
||||
from charmhelpers.core.hookenv import (
|
||||
config,
|
||||
log,
|
||||
@ -67,8 +73,12 @@ KILO_PACKAGES = [
|
||||
]
|
||||
|
||||
BASE_GIT_PACKAGES = [
|
||||
'libffi-dev',
|
||||
'libmysqlclient-dev',
|
||||
'libssl-dev',
|
||||
'libxml2-dev',
|
||||
'libxslt1-dev',
|
||||
'libyaml-dev',
|
||||
'python-dev',
|
||||
'python-pip',
|
||||
'python-setuptools',
|
||||
@ -420,6 +430,14 @@ def git_pre_install():
|
||||
|
||||
def git_post_install(projects_yaml):
|
||||
"""Perform post-install setup."""
|
||||
http_proxy = git_yaml_value(projects_yaml, 'http_proxy')
|
||||
if http_proxy:
|
||||
pip_install('mysql-python', proxy=http_proxy,
|
||||
venv=git_pip_venv_dir(projects_yaml))
|
||||
else:
|
||||
pip_install('mysql-python',
|
||||
venv=git_pip_venv_dir(projects_yaml))
|
||||
|
||||
src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
|
||||
configs = [
|
||||
{'src': src_etc,
|
||||
@ -435,13 +453,30 @@ def git_post_install(projects_yaml):
|
||||
shutil.rmtree(c['dest'])
|
||||
shutil.copytree(c['src'], c['dest'])
|
||||
|
||||
# NOTE(coreycb): Need to find better solution than bin symlinks.
|
||||
symlinks = [
|
||||
{'src': os.path.join(git_pip_venv_dir(projects_yaml),
|
||||
'bin/neutron-rootwrap'),
|
||||
'link': '/usr/local/bin/neutron-rootwrap'},
|
||||
{'src': os.path.join(git_pip_venv_dir(projects_yaml),
|
||||
'bin/neutron-db-manage'),
|
||||
'link': '/usr/local/bin/neutron-db-manage'},
|
||||
]
|
||||
|
||||
for s in symlinks:
|
||||
if os.path.lexists(s['link']):
|
||||
os.remove(s['link'])
|
||||
os.symlink(s['src'], s['link'])
|
||||
|
||||
render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
|
||||
perms=0o440)
|
||||
|
||||
bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
|
||||
neutron_api_context = {
|
||||
'service_description': 'Neutron API server',
|
||||
'charm_name': 'neutron-api',
|
||||
'process_name': 'neutron-server',
|
||||
'executable_name': os.path.join(bin_dir, 'neutron-server'),
|
||||
}
|
||||
|
||||
# NOTE(coreycb): Needs systemd support
|
||||
|
@ -16,7 +16,7 @@ end script
|
||||
script
|
||||
[ -r /etc/default/{{ process_name }} ] && . /etc/default/{{ process_name }}
|
||||
[ -r "$NEUTRON_PLUGIN_CONFIG" ] && CONF_ARG="--config-file $NEUTRON_PLUGIN_CONFIG"
|
||||
exec start-stop-daemon --start --chuid neutron --exec /usr/local/bin/neutron-server -- \
|
||||
exec start-stop-daemon --start --chuid neutron --exec {{ executable_name }} -- \
|
||||
--config-file /etc/neutron/neutron.conf \
|
||||
--log-file /var/log/neutron/server.log $CONF_ARG
|
||||
end script
|
||||
|
@ -31,6 +31,7 @@ TO_PATCH = [
|
||||
'log',
|
||||
'neutron_plugin_attribute',
|
||||
'os_release',
|
||||
'pip_install',
|
||||
'subprocess',
|
||||
]
|
||||
|
||||
@ -415,14 +416,19 @@ class TestNeutronAPIUtils(CharmTestCase):
|
||||
@patch.object(nutils, 'git_src_dir')
|
||||
@patch.object(nutils, 'service_restart')
|
||||
@patch.object(nutils, 'render')
|
||||
@patch.object(nutils, 'git_pip_venv_dir')
|
||||
@patch('os.path.join')
|
||||
@patch('os.path.exists')
|
||||
@patch('os.symlink')
|
||||
@patch('shutil.copytree')
|
||||
@patch('shutil.rmtree')
|
||||
def test_git_post_install(self, rmtree, copytree, exists, join, render,
|
||||
service_restart, git_src_dir):
|
||||
@patch('subprocess.check_call')
|
||||
def test_git_post_install(self, check_call, rmtree, copytree, symlink,
|
||||
exists, join, venv, render, service_restart,
|
||||
git_src_dir):
|
||||
projects_yaml = openstack_origin_git
|
||||
join.return_value = 'joined-string'
|
||||
venv.return_value = '/mnt/openstack-git/venv'
|
||||
nutils.git_post_install(projects_yaml)
|
||||
expected = [
|
||||
call('joined-string', '/etc/neutron'),
|
||||
@ -430,10 +436,16 @@ class TestNeutronAPIUtils(CharmTestCase):
|
||||
call('joined-string', '/etc/neutron/rootwrap.d'),
|
||||
]
|
||||
copytree.assert_has_calls(expected)
|
||||
expected = [
|
||||
call('joined-string', '/usr/local/bin/neutron-rootwrap'),
|
||||
call('joined-string', '/usr/local/bin/neutron-db-manage'),
|
||||
]
|
||||
symlink.assert_has_calls(expected, any_order=True)
|
||||
neutron_api_context = {
|
||||
'service_description': 'Neutron API server',
|
||||
'charm_name': 'neutron-api',
|
||||
'process_name': 'neutron-server',
|
||||
'executable_name': 'joined-string',
|
||||
}
|
||||
expected = [
|
||||
call('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {},
|
||||
|
Loading…
Reference in New Issue
Block a user