Add support for deployment from git.
This commit is contained in:
@@ -45,8 +45,15 @@ from charmhelpers.contrib.openstack.utils import (
|
||||
git_install_requested,
|
||||
git_clone_and_install,
|
||||
git_src_dir,
|
||||
git_yaml_value,
|
||||
git_pip_venv_dir,
|
||||
os_release,
|
||||
save_script_rc as _save_script_rc)
|
||||
save_script_rc as _save_script_rc
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.python.packages import (
|
||||
pip_install,
|
||||
)
|
||||
|
||||
from charmhelpers.core.strutils import (
|
||||
bool_from_string,
|
||||
@@ -123,9 +130,11 @@ BASE_PACKAGES = [
|
||||
|
||||
BASE_GIT_PACKAGES = [
|
||||
'libffi-dev',
|
||||
'libmysqlclient-dev',
|
||||
'libssl-dev',
|
||||
'libxml2-dev',
|
||||
'libxslt1-dev',
|
||||
'libyaml-dev',
|
||||
'python-dev',
|
||||
'python-pip',
|
||||
'python-setuptools',
|
||||
@@ -139,7 +148,6 @@ BASE_SERVICES = [
|
||||
# ubuntu packages that should not be installed when deploying from git
|
||||
GIT_PACKAGE_BLACKLIST = [
|
||||
'keystone',
|
||||
'python-keystoneclient',
|
||||
]
|
||||
|
||||
API_PORTS = {
|
||||
@@ -1723,6 +1731,14 @@ def git_pre_install():
|
||||
|
||||
def git_post_install(projects_yaml):
|
||||
"""Perform keystone 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, 'keystone'), 'etc')
|
||||
configs = {
|
||||
'src': src_etc,
|
||||
@@ -1733,15 +1749,28 @@ def git_post_install(projects_yaml):
|
||||
shutil.rmtree(configs['dest'])
|
||||
shutil.copytree(configs['src'], configs['dest'])
|
||||
|
||||
# NOTE(coreycb): Need to find better solution than bin symlinks.
|
||||
symlinks = [
|
||||
{'src': os.path.join(git_pip_venv_dir(projects_yaml),
|
||||
'bin/keystone-manage'),
|
||||
'link': '/usr/local/bin/keystone-manage'},
|
||||
]
|
||||
|
||||
for s in symlinks:
|
||||
if os.path.lexists(s['link']):
|
||||
os.remove(s['link'])
|
||||
os.symlink(s['src'], s['link'])
|
||||
|
||||
render('git/logging.conf', '/etc/keystone/logging.conf', {}, perms=0o644)
|
||||
|
||||
bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
|
||||
keystone_context = {
|
||||
'service_description': 'Keystone API server',
|
||||
'service_name': 'Keystone',
|
||||
'user_name': 'keystone',
|
||||
'start_dir': '/var/lib/keystone',
|
||||
'process_name': 'keystone',
|
||||
'executable_name': '/usr/local/bin/keystone-all',
|
||||
'executable_name': os.path.join(bin_dir, 'keystone-all'),
|
||||
'config_files': ['/etc/keystone/keystone.conf'],
|
||||
'log_file': '/var/log/keystone/keystone.log',
|
||||
}
|
||||
|
@@ -59,10 +59,10 @@ class KeystoneBasicDeployment(OpenStackAmuletDeployment):
|
||||
openstack_origin_git = {
|
||||
'repositories': [
|
||||
{'name': 'requirements',
|
||||
'repository': 'git://git.openstack.org/openstack/requirements',
|
||||
'repository': 'git://github.com/openstack/requirements',
|
||||
'branch': branch},
|
||||
{'name': 'keystone',
|
||||
'repository': 'git://git.openstack.org/openstack/keystone',
|
||||
'repository': 'git://github.com/openstack/keystone',
|
||||
'branch': branch},
|
||||
],
|
||||
'directory': '/mnt/openstack-git',
|
||||
|
@@ -120,10 +120,11 @@ class KeystoneRelationTests(CharmTestCase):
|
||||
self.configure_installation_source.assert_called_with(repo)
|
||||
self.assertTrue(self.apt_update.called)
|
||||
self.apt_install.assert_called_with(
|
||||
['haproxy', 'unison', 'python-setuptools', 'python-six', 'uuid',
|
||||
'python-mysqldb', 'python-pip', 'libssl-dev', 'openssl',
|
||||
'libffi-dev', 'apache2', 'pwgen', 'libxslt1-dev',
|
||||
'python-psycopg2', 'zlib1g-dev', 'python-dev', 'libxml2-dev'],
|
||||
['haproxy', 'unison', 'python-setuptools', 'python-keystoneclient',
|
||||
'uuid', 'python-mysqldb', 'libmysqlclient-dev', 'libssl-dev',
|
||||
'openssl', 'libffi-dev', 'apache2', 'python-pip', 'pwgen',
|
||||
'python-six', 'libxslt1-dev', 'python-psycopg2', 'libyaml-dev',
|
||||
'zlib1g-dev', 'python-dev', 'libxml2-dev'],
|
||||
fatal=True)
|
||||
self.git_install.assert_called_with(projects_yaml)
|
||||
|
||||
|
@@ -42,6 +42,7 @@ TO_PATCH = [
|
||||
'https',
|
||||
'is_relation_made',
|
||||
'peer_store',
|
||||
'pip_install',
|
||||
# generic
|
||||
'apt_update',
|
||||
'apt_upgrade',
|
||||
@@ -656,26 +657,35 @@ class TestKeystoneUtils(CharmTestCase):
|
||||
@patch.object(utils, 'git_src_dir')
|
||||
@patch.object(utils, 'service_restart')
|
||||
@patch.object(utils, 'render')
|
||||
@patch.object(utils, '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'
|
||||
utils.git_post_install(projects_yaml)
|
||||
expected = [
|
||||
call('joined-string', '/etc/keystone'),
|
||||
]
|
||||
copytree.assert_has_calls(expected)
|
||||
expected = [
|
||||
call('joined-string', '/usr/local/bin/keystone-manage'),
|
||||
]
|
||||
symlink.assert_has_calls(expected, any_order=True)
|
||||
keystone_context = {
|
||||
'service_description': 'Keystone API server',
|
||||
'service_name': 'Keystone',
|
||||
'user_name': 'keystone',
|
||||
'start_dir': '/var/lib/keystone',
|
||||
'process_name': 'keystone',
|
||||
'executable_name': '/usr/local/bin/keystone-all',
|
||||
'executable_name': 'joined-string',
|
||||
'config_files': ['/etc/keystone/keystone.conf'],
|
||||
'log_file': '/var/log/keystone/keystone.log',
|
||||
}
|
||||
|
Reference in New Issue
Block a user