Merge lp:~corey.bryant/charm-helpers/systemd-fixup-and-upper-constraints into lp:charm-helpers

Proposed by Corey Bryant
Status: Merged
Merged at revision: 595
Proposed branch: lp:~corey.bryant/charm-helpers/systemd-fixup-and-upper-constraints
Merge into: lp:charm-helpers
Diff against target: 227 lines (+74/-15)
3 files modified
charmhelpers/contrib/openstack/utils.py (+58/-8)
charmhelpers/contrib/python/packages.py (+5/-1)
tests/contrib/openstack/test_openstack_utils.py (+11/-6)
To merge this branch: bzr merge lp:~corey.bryant/charm-helpers/systemd-fixup-and-upper-constraints
Reviewer Review Type Date Requested Status
James Page Pending
charmers Pending
Review via email: mp+298768@code.launchpad.net

Description of the change

This mp has a number of updates for openstack deploy from source that are explained in the commit messages.

To post a comment you must log in.
599. By Corey Bryant

Merge lp:charm-helpers

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/openstack/utils.py'
--- charmhelpers/contrib/openstack/utils.py 2016-06-15 20:59:51 +0000
+++ charmhelpers/contrib/openstack/utils.py 2016-06-30 12:59:15 +0000
@@ -222,7 +222,6 @@
222}222}
223223
224GIT_DEFAULT_BRANCHES = {224GIT_DEFAULT_BRANCHES = {
225 'icehouse': 'icehouse-eol',
226 'kilo': 'stable/kilo',225 'kilo': 'stable/kilo',
227 'liberty': 'stable/liberty',226 'liberty': 'stable/liberty',
228 'mitaka': 'stable/mitaka',227 'mitaka': 'stable/mitaka',
@@ -743,12 +742,18 @@
743 }742 }
744 repos = [repo]743 repos = [repo]
745744
745 # NOTE(coreycb): This is a temp work-around until the requirements
746 # repo moves from stable/kilo branch to kilo-eol tag. The core
747 # repos have already done this.
748 if default == 'kilo':
749 branch = 'kilo-eol'
750
746 # neutron-* and nova-* charms require some additional repos751 # neutron-* and nova-* charms require some additional repos
747 if service in ['neutron-api', 'neutron-gateway',752 if service in ['neutron-api', 'neutron-gateway',
748 'neutron-openvswitch']:753 'neutron-openvswitch']:
749 core_project = 'neutron'754 core_project = 'neutron'
750 for project in ['neutron-fwaas', 'neutron-lbaas',755 for project in ['neutron-fwaas', 'neutron-lbaas',
751 'neutron-vpnaas']:756 'neutron-vpnaas', 'nova']:
752 repo = {757 repo = {
753 'name': project,758 'name': project,
754 'repository': GIT_DEFAULT_REPOS[project],759 'repository': GIT_DEFAULT_REPOS[project],
@@ -837,6 +842,7 @@
837 pip_install(p, upgrade=True, proxy=http_proxy,842 pip_install(p, upgrade=True, proxy=http_proxy,
838 venv=os.path.join(parent_dir, 'venv'))843 venv=os.path.join(parent_dir, 'venv'))
839844
845 constraints = None
840 for p in projects['repositories']:846 for p in projects['repositories']:
841 repo = p['repository']847 repo = p['repository']
842 branch = p['branch']848 branch = p['branch']
@@ -848,10 +854,15 @@
848 parent_dir, http_proxy,854 parent_dir, http_proxy,
849 update_requirements=False)855 update_requirements=False)
850 requirements_dir = repo_dir856 requirements_dir = repo_dir
857 constraints = os.path.join(repo_dir, "upper-constraints.txt")
858 # upper-constraints didn't exist until after icehouse
859 if not os.path.isfile(constraints):
860 constraints = None
851 else:861 else:
852 repo_dir = _git_clone_and_install_single(repo, branch, depth,862 repo_dir = _git_clone_and_install_single(repo, branch, depth,
853 parent_dir, http_proxy,863 parent_dir, http_proxy,
854 update_requirements=True)864 update_requirements=True,
865 constraints=constraints)
855866
856 os.environ = old_environ867 os.environ = old_environ
857868
@@ -883,7 +894,7 @@
883894
884895
885def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,896def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,
886 update_requirements):897 update_requirements, constraints=None):
887 """898 """
888 Clone and install a single git repository.899 Clone and install a single git repository.
889 """900 """
@@ -906,9 +917,10 @@
906917
907 juju_log('Installing git repo from dir: {}'.format(repo_dir))918 juju_log('Installing git repo from dir: {}'.format(repo_dir))
908 if http_proxy:919 if http_proxy:
909 pip_install(repo_dir, proxy=http_proxy, venv=venv)920 pip_install(repo_dir, proxy=http_proxy, venv=venv,
921 constraints=constraints)
910 else:922 else:
911 pip_install(repo_dir, venv=venv)923 pip_install(repo_dir, venv=venv, constraints=constraints)
912924
913 return repo_dir925 return repo_dir
914926
@@ -988,6 +1000,7 @@
988 script generation, which is used by the OpenStack packages.1000 script generation, which is used by the OpenStack packages.
989 """1001 """
990 for f in os.listdir(templates_dir):1002 for f in os.listdir(templates_dir):
1003 # Create the init script and systemd unit file from the template
991 if f.endswith(".init.in"):1004 if f.endswith(".init.in"):
992 init_in_file = f1005 init_in_file = f
993 init_file = f[:-8]1006 init_file = f[:-8]
@@ -1013,10 +1026,47 @@
1013 os.remove(init_dest)1026 os.remove(init_dest)
1014 if os.path.exists(service_dest):1027 if os.path.exists(service_dest):
1015 os.remove(service_dest)1028 os.remove(service_dest)
1016 shutil.move(init_source, init_dest)1029 shutil.copyfile(init_source, init_dest)
1017 shutil.move(service_source, service_dest)1030 shutil.copyfile(service_source, service_dest)
1018 os.chmod(init_dest, 0o755)1031 os.chmod(init_dest, 0o755)
10191032
1033 for f in os.listdir(templates_dir):
1034 # If there's a service.in file, use it instead of the generated one
1035 if f.endswith(".service.in"):
1036 service_in_file = f
1037 service_file = f[:-3]
1038
1039 service_in_source = os.path.join(templates_dir, service_in_file)
1040 service_source = os.path.join(templates_dir, service_file)
1041 service_dest = os.path.join('/lib/systemd/system', service_file)
1042
1043 shutil.copyfile(service_in_source, service_source)
1044
1045 if os.path.exists(service_dest):
1046 os.remove(service_dest)
1047 shutil.copyfile(service_source, service_dest)
1048
1049 for f in os.listdir(templates_dir):
1050 # Generate the systemd unit if there's no existing .service.in
1051 if f.endswith(".init.in"):
1052 init_in_file = f
1053 init_file = f[:-8]
1054 service_in_file = "{}.service.in".format(init_file)
1055 service_file = "{}.service".format(init_file)
1056
1057 init_in_source = os.path.join(templates_dir, init_in_file)
1058 service_in_source = os.path.join(templates_dir, service_in_file)
1059 service_source = os.path.join(templates_dir, service_file)
1060 service_dest = os.path.join('/lib/systemd/system', service_file)
1061
1062 if not os.path.exists(service_in_source):
1063 cmd = ['pkgos-gen-systemd-unit', init_in_source]
1064 subprocess.check_call(cmd)
1065
1066 if os.path.exists(service_dest):
1067 os.remove(service_dest)
1068 shutil.copyfile(service_source, service_dest)
1069
10201070
1021def os_workload_status(configs, required_interfaces, charm_func=None):1071def os_workload_status(configs, required_interfaces, charm_func=None):
1022 """1072 """
10231073
=== modified file 'charmhelpers/contrib/python/packages.py'
--- charmhelpers/contrib/python/packages.py 2016-02-02 10:46:04 +0000
+++ charmhelpers/contrib/python/packages.py 2016-06-30 12:59:15 +0000
@@ -80,7 +80,8 @@
80 pip_execute(command)80 pip_execute(command)
8181
8282
83def pip_install(package, fatal=False, upgrade=False, venv=None, **options):83def pip_install(package, fatal=False, upgrade=False, venv=None,
84 constraints=None, **options):
84 """Install a python package"""85 """Install a python package"""
85 if venv:86 if venv:
86 venv_python = os.path.join(venv, 'bin/pip')87 venv_python = os.path.join(venv, 'bin/pip')
@@ -95,6 +96,9 @@
95 if upgrade:96 if upgrade:
96 command.append('--upgrade')97 command.append('--upgrade')
9798
99 if constraints:
100 command.extend(['-c', constraints])
101
98 if isinstance(package, list):102 if isinstance(package, list):
99 command.extend(package)103 command.extend(package)
100 else:104 else:
101105
=== modified file 'tests/contrib/openstack/test_openstack_utils.py'
--- tests/contrib/openstack/test_openstack_utils.py 2016-05-27 09:05:48 +0000
+++ tests/contrib/openstack/test_openstack_utils.py 2016-06-30 12:59:15 +0000
@@ -730,13 +730,16 @@
730 error_out.assert_called_with(730 error_out.assert_called_with(
731 'openstack-origin-git key \'%s\' is missing' % key)731 'openstack-origin-git key \'%s\' is missing' % key)
732732
733 @patch('os.path.isfile')
733 @patch('os.path.join')734 @patch('os.path.join')
734 @patch.object(openstack, 'error_out')735 @patch.object(openstack, 'error_out')
735 @patch.object(openstack, '_git_clone_and_install_single')736 @patch.object(openstack, '_git_clone_and_install_single')
736 @patch.object(openstack, 'pip_install')737 @patch.object(openstack, 'pip_install')
737 @patch.object(openstack, 'pip_create_virtualenv')738 @patch.object(openstack, 'pip_create_virtualenv')
738 def test_git_clone_and_install_errors(self, pip_venv, pip_install,739 def test_git_clone_and_install_errors(self, pip_venv, pip_install,
739 git_install_single, error_out, join):740 git_install_single, error_out, join,
741 isfile):
742 isfile.return_value = True
740 git_missing_repos = """743 git_missing_repos = """
741 repostories:744 repostories:
742 - {name: requirements,745 - {name: requirements,
@@ -809,13 +812,13 @@
809 charm_dir.return_value = '/var/lib/juju/units/testing-foo-0/charm'812 charm_dir.return_value = '/var/lib/juju/units/testing-foo-0/charm'
810 # the following sets the global requirements_dir813 # the following sets the global requirements_dir
811 _git_install_single.return_value = '/mnt/openstack-git/requirements'814 _git_install_single.return_value = '/mnt/openstack-git/requirements'
812 join.return_value = '/mnt/openstack-git/venv'815 join.return_value = 'joined-path'
813816
814 openstack.git_clone_and_install(openstack_origin_git, proj)817 openstack.git_clone_and_install(openstack_origin_git, proj)
815 self.assertTrue(pip_venv.called)818 self.assertTrue(pip_venv.called)
816 pip_install.assert_called_with('setuptools', upgrade=True,819 pip_install.assert_called_with('setuptools', upgrade=True,
817 proxy=None,820 proxy=None,
818 venv='/mnt/openstack-git/venv')821 venv='joined-path')
819 self.assertTrue(_git_install_single.call_count == 2)822 self.assertTrue(_git_install_single.call_count == 2)
820 expected = [823 expected = [
821 call('git://git.openstack.org/openstack/requirements',824 call('git://git.openstack.org/openstack/requirements',
@@ -823,7 +826,7 @@
823 update_requirements=False),826 update_requirements=False),
824 call('git://git.openstack.org/openstack/keystone',827 call('git://git.openstack.org/openstack/keystone',
825 'stable/juno', '1', '/mnt/openstack-git', None,828 'stable/juno', '1', '/mnt/openstack-git', None,
826 update_requirements=True)829 update_requirements=True, constraints=None)
827 ]830 ]
828 self.assertEquals(expected, _git_install_single.call_args_list)831 self.assertEquals(expected, _git_install_single.call_args_list)
829 assert not error_out.called832 assert not error_out.called
@@ -855,7 +858,8 @@
855 branch=branch)858 branch=branch)
856 assert not _git_update_reqs.called859 assert not _git_update_reqs.called
857 pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git',860 pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git',
858 proxy='http://squid-proxy-url')861 proxy='http://squid-proxy-url',
862 constraints=None)
859863
860 @patch('os.path.join')864 @patch('os.path.join')
861 @patch('os.mkdir')865 @patch('os.mkdir')
@@ -887,7 +891,8 @@
887 branch=branch)891 branch=branch)
888 _git_update_reqs.assert_called_with(venv_dir, dest_dir, reqs_dir)892 _git_update_reqs.assert_called_with(venv_dir, dest_dir, reqs_dir)
889 pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git',893 pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git',
890 proxy='http://squid-proxy-url')894 proxy='http://squid-proxy-url',
895 constraints=None)
891896
892 @patch('os.path.join')897 @patch('os.path.join')
893 @patch('os.getcwd')898 @patch('os.getcwd')

Subscribers

People subscribed via source and target branches