Merge lp:~corey.bryant/charm-helpers/systemd-fixup-and-upper-constraints into lp:charm-helpers
- systemd-fixup-and-upper-constraints
- Merge into devel
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Page | Pending | ||
charmers | Pending | ||
Review via email: mp+298768@code.launchpad.net |
Commit message
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.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'charmhelpers/contrib/openstack/utils.py' | |||
2 | --- charmhelpers/contrib/openstack/utils.py 2016-06-15 20:59:51 +0000 | |||
3 | +++ charmhelpers/contrib/openstack/utils.py 2016-06-30 12:59:15 +0000 | |||
4 | @@ -222,7 +222,6 @@ | |||
5 | 222 | } | 222 | } |
6 | 223 | 223 | ||
7 | 224 | GIT_DEFAULT_BRANCHES = { | 224 | GIT_DEFAULT_BRANCHES = { |
8 | 225 | 'icehouse': 'icehouse-eol', | ||
9 | 226 | 'kilo': 'stable/kilo', | 225 | 'kilo': 'stable/kilo', |
10 | 227 | 'liberty': 'stable/liberty', | 226 | 'liberty': 'stable/liberty', |
11 | 228 | 'mitaka': 'stable/mitaka', | 227 | 'mitaka': 'stable/mitaka', |
12 | @@ -743,12 +742,18 @@ | |||
13 | 743 | } | 742 | } |
14 | 744 | repos = [repo] | 743 | repos = [repo] |
15 | 745 | 744 | ||
16 | 745 | # NOTE(coreycb): This is a temp work-around until the requirements | ||
17 | 746 | # repo moves from stable/kilo branch to kilo-eol tag. The core | ||
18 | 747 | # repos have already done this. | ||
19 | 748 | if default == 'kilo': | ||
20 | 749 | branch = 'kilo-eol' | ||
21 | 750 | |||
22 | 746 | # neutron-* and nova-* charms require some additional repos | 751 | # neutron-* and nova-* charms require some additional repos |
23 | 747 | if service in ['neutron-api', 'neutron-gateway', | 752 | if service in ['neutron-api', 'neutron-gateway', |
24 | 748 | 'neutron-openvswitch']: | 753 | 'neutron-openvswitch']: |
25 | 749 | core_project = 'neutron' | 754 | core_project = 'neutron' |
26 | 750 | for project in ['neutron-fwaas', 'neutron-lbaas', | 755 | for project in ['neutron-fwaas', 'neutron-lbaas', |
28 | 751 | 'neutron-vpnaas']: | 756 | 'neutron-vpnaas', 'nova']: |
29 | 752 | repo = { | 757 | repo = { |
30 | 753 | 'name': project, | 758 | 'name': project, |
31 | 754 | 'repository': GIT_DEFAULT_REPOS[project], | 759 | 'repository': GIT_DEFAULT_REPOS[project], |
32 | @@ -837,6 +842,7 @@ | |||
33 | 837 | pip_install(p, upgrade=True, proxy=http_proxy, | 842 | pip_install(p, upgrade=True, proxy=http_proxy, |
34 | 838 | venv=os.path.join(parent_dir, 'venv')) | 843 | venv=os.path.join(parent_dir, 'venv')) |
35 | 839 | 844 | ||
36 | 845 | constraints = None | ||
37 | 840 | for p in projects['repositories']: | 846 | for p in projects['repositories']: |
38 | 841 | repo = p['repository'] | 847 | repo = p['repository'] |
39 | 842 | branch = p['branch'] | 848 | branch = p['branch'] |
40 | @@ -848,10 +854,15 @@ | |||
41 | 848 | parent_dir, http_proxy, | 854 | parent_dir, http_proxy, |
42 | 849 | update_requirements=False) | 855 | update_requirements=False) |
43 | 850 | requirements_dir = repo_dir | 856 | requirements_dir = repo_dir |
44 | 857 | constraints = os.path.join(repo_dir, "upper-constraints.txt") | ||
45 | 858 | # upper-constraints didn't exist until after icehouse | ||
46 | 859 | if not os.path.isfile(constraints): | ||
47 | 860 | constraints = None | ||
48 | 851 | else: | 861 | else: |
49 | 852 | repo_dir = _git_clone_and_install_single(repo, branch, depth, | 862 | repo_dir = _git_clone_and_install_single(repo, branch, depth, |
50 | 853 | parent_dir, http_proxy, | 863 | parent_dir, http_proxy, |
52 | 854 | update_requirements=True) | 864 | update_requirements=True, |
53 | 865 | constraints=constraints) | ||
54 | 855 | 866 | ||
55 | 856 | os.environ = old_environ | 867 | os.environ = old_environ |
56 | 857 | 868 | ||
57 | @@ -883,7 +894,7 @@ | |||
58 | 883 | 894 | ||
59 | 884 | 895 | ||
60 | 885 | def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy, | 896 | def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy, |
62 | 886 | update_requirements): | 897 | update_requirements, constraints=None): |
63 | 887 | """ | 898 | """ |
64 | 888 | Clone and install a single git repository. | 899 | Clone and install a single git repository. |
65 | 889 | """ | 900 | """ |
66 | @@ -906,9 +917,10 @@ | |||
67 | 906 | 917 | ||
68 | 907 | juju_log('Installing git repo from dir: {}'.format(repo_dir)) | 918 | juju_log('Installing git repo from dir: {}'.format(repo_dir)) |
69 | 908 | if http_proxy: | 919 | if http_proxy: |
71 | 909 | pip_install(repo_dir, proxy=http_proxy, venv=venv) | 920 | pip_install(repo_dir, proxy=http_proxy, venv=venv, |
72 | 921 | constraints=constraints) | ||
73 | 910 | else: | 922 | else: |
75 | 911 | pip_install(repo_dir, venv=venv) | 923 | pip_install(repo_dir, venv=venv, constraints=constraints) |
76 | 912 | 924 | ||
77 | 913 | return repo_dir | 925 | return repo_dir |
78 | 914 | 926 | ||
79 | @@ -988,6 +1000,7 @@ | |||
80 | 988 | script generation, which is used by the OpenStack packages. | 1000 | script generation, which is used by the OpenStack packages. |
81 | 989 | """ | 1001 | """ |
82 | 990 | for f in os.listdir(templates_dir): | 1002 | for f in os.listdir(templates_dir): |
83 | 1003 | # Create the init script and systemd unit file from the template | ||
84 | 991 | if f.endswith(".init.in"): | 1004 | if f.endswith(".init.in"): |
85 | 992 | init_in_file = f | 1005 | init_in_file = f |
86 | 993 | init_file = f[:-8] | 1006 | init_file = f[:-8] |
87 | @@ -1013,10 +1026,47 @@ | |||
88 | 1013 | os.remove(init_dest) | 1026 | os.remove(init_dest) |
89 | 1014 | if os.path.exists(service_dest): | 1027 | if os.path.exists(service_dest): |
90 | 1015 | os.remove(service_dest) | 1028 | os.remove(service_dest) |
93 | 1016 | shutil.move(init_source, init_dest) | 1029 | shutil.copyfile(init_source, init_dest) |
94 | 1017 | shutil.move(service_source, service_dest) | 1030 | shutil.copyfile(service_source, service_dest) |
95 | 1018 | os.chmod(init_dest, 0o755) | 1031 | os.chmod(init_dest, 0o755) |
96 | 1019 | 1032 | ||
97 | 1033 | for f in os.listdir(templates_dir): | ||
98 | 1034 | # If there's a service.in file, use it instead of the generated one | ||
99 | 1035 | if f.endswith(".service.in"): | ||
100 | 1036 | service_in_file = f | ||
101 | 1037 | service_file = f[:-3] | ||
102 | 1038 | |||
103 | 1039 | service_in_source = os.path.join(templates_dir, service_in_file) | ||
104 | 1040 | service_source = os.path.join(templates_dir, service_file) | ||
105 | 1041 | service_dest = os.path.join('/lib/systemd/system', service_file) | ||
106 | 1042 | |||
107 | 1043 | shutil.copyfile(service_in_source, service_source) | ||
108 | 1044 | |||
109 | 1045 | if os.path.exists(service_dest): | ||
110 | 1046 | os.remove(service_dest) | ||
111 | 1047 | shutil.copyfile(service_source, service_dest) | ||
112 | 1048 | |||
113 | 1049 | for f in os.listdir(templates_dir): | ||
114 | 1050 | # Generate the systemd unit if there's no existing .service.in | ||
115 | 1051 | if f.endswith(".init.in"): | ||
116 | 1052 | init_in_file = f | ||
117 | 1053 | init_file = f[:-8] | ||
118 | 1054 | service_in_file = "{}.service.in".format(init_file) | ||
119 | 1055 | service_file = "{}.service".format(init_file) | ||
120 | 1056 | |||
121 | 1057 | init_in_source = os.path.join(templates_dir, init_in_file) | ||
122 | 1058 | service_in_source = os.path.join(templates_dir, service_in_file) | ||
123 | 1059 | service_source = os.path.join(templates_dir, service_file) | ||
124 | 1060 | service_dest = os.path.join('/lib/systemd/system', service_file) | ||
125 | 1061 | |||
126 | 1062 | if not os.path.exists(service_in_source): | ||
127 | 1063 | cmd = ['pkgos-gen-systemd-unit', init_in_source] | ||
128 | 1064 | subprocess.check_call(cmd) | ||
129 | 1065 | |||
130 | 1066 | if os.path.exists(service_dest): | ||
131 | 1067 | os.remove(service_dest) | ||
132 | 1068 | shutil.copyfile(service_source, service_dest) | ||
133 | 1069 | |||
134 | 1020 | 1070 | ||
135 | 1021 | def os_workload_status(configs, required_interfaces, charm_func=None): | 1071 | def os_workload_status(configs, required_interfaces, charm_func=None): |
136 | 1022 | """ | 1072 | """ |
137 | 1023 | 1073 | ||
138 | === modified file 'charmhelpers/contrib/python/packages.py' | |||
139 | --- charmhelpers/contrib/python/packages.py 2016-02-02 10:46:04 +0000 | |||
140 | +++ charmhelpers/contrib/python/packages.py 2016-06-30 12:59:15 +0000 | |||
141 | @@ -80,7 +80,8 @@ | |||
142 | 80 | pip_execute(command) | 80 | pip_execute(command) |
143 | 81 | 81 | ||
144 | 82 | 82 | ||
146 | 83 | def pip_install(package, fatal=False, upgrade=False, venv=None, **options): | 83 | def pip_install(package, fatal=False, upgrade=False, venv=None, |
147 | 84 | constraints=None, **options): | ||
148 | 84 | """Install a python package""" | 85 | """Install a python package""" |
149 | 85 | if venv: | 86 | if venv: |
150 | 86 | venv_python = os.path.join(venv, 'bin/pip') | 87 | venv_python = os.path.join(venv, 'bin/pip') |
151 | @@ -95,6 +96,9 @@ | |||
152 | 95 | if upgrade: | 96 | if upgrade: |
153 | 96 | command.append('--upgrade') | 97 | command.append('--upgrade') |
154 | 97 | 98 | ||
155 | 99 | if constraints: | ||
156 | 100 | command.extend(['-c', constraints]) | ||
157 | 101 | |||
158 | 98 | if isinstance(package, list): | 102 | if isinstance(package, list): |
159 | 99 | command.extend(package) | 103 | command.extend(package) |
160 | 100 | else: | 104 | else: |
161 | 101 | 105 | ||
162 | === modified file 'tests/contrib/openstack/test_openstack_utils.py' | |||
163 | --- tests/contrib/openstack/test_openstack_utils.py 2016-05-27 09:05:48 +0000 | |||
164 | +++ tests/contrib/openstack/test_openstack_utils.py 2016-06-30 12:59:15 +0000 | |||
165 | @@ -730,13 +730,16 @@ | |||
166 | 730 | error_out.assert_called_with( | 730 | error_out.assert_called_with( |
167 | 731 | 'openstack-origin-git key \'%s\' is missing' % key) | 731 | 'openstack-origin-git key \'%s\' is missing' % key) |
168 | 732 | 732 | ||
169 | 733 | @patch('os.path.isfile') | ||
170 | 733 | @patch('os.path.join') | 734 | @patch('os.path.join') |
171 | 734 | @patch.object(openstack, 'error_out') | 735 | @patch.object(openstack, 'error_out') |
172 | 735 | @patch.object(openstack, '_git_clone_and_install_single') | 736 | @patch.object(openstack, '_git_clone_and_install_single') |
173 | 736 | @patch.object(openstack, 'pip_install') | 737 | @patch.object(openstack, 'pip_install') |
174 | 737 | @patch.object(openstack, 'pip_create_virtualenv') | 738 | @patch.object(openstack, 'pip_create_virtualenv') |
175 | 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, |
177 | 739 | git_install_single, error_out, join): | 740 | git_install_single, error_out, join, |
178 | 741 | isfile): | ||
179 | 742 | isfile.return_value = True | ||
180 | 740 | git_missing_repos = """ | 743 | git_missing_repos = """ |
181 | 741 | repostories: | 744 | repostories: |
182 | 742 | - {name: requirements, | 745 | - {name: requirements, |
183 | @@ -809,13 +812,13 @@ | |||
184 | 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' |
185 | 810 | # the following sets the global requirements_dir | 813 | # the following sets the global requirements_dir |
186 | 811 | _git_install_single.return_value = '/mnt/openstack-git/requirements' | 814 | _git_install_single.return_value = '/mnt/openstack-git/requirements' |
188 | 812 | join.return_value = '/mnt/openstack-git/venv' | 815 | join.return_value = 'joined-path' |
189 | 813 | 816 | ||
190 | 814 | openstack.git_clone_and_install(openstack_origin_git, proj) | 817 | openstack.git_clone_and_install(openstack_origin_git, proj) |
191 | 815 | self.assertTrue(pip_venv.called) | 818 | self.assertTrue(pip_venv.called) |
192 | 816 | pip_install.assert_called_with('setuptools', upgrade=True, | 819 | pip_install.assert_called_with('setuptools', upgrade=True, |
193 | 817 | proxy=None, | 820 | proxy=None, |
195 | 818 | venv='/mnt/openstack-git/venv') | 821 | venv='joined-path') |
196 | 819 | self.assertTrue(_git_install_single.call_count == 2) | 822 | self.assertTrue(_git_install_single.call_count == 2) |
197 | 820 | expected = [ | 823 | expected = [ |
198 | 821 | call('git://git.openstack.org/openstack/requirements', | 824 | call('git://git.openstack.org/openstack/requirements', |
199 | @@ -823,7 +826,7 @@ | |||
200 | 823 | update_requirements=False), | 826 | update_requirements=False), |
201 | 824 | call('git://git.openstack.org/openstack/keystone', | 827 | call('git://git.openstack.org/openstack/keystone', |
202 | 825 | 'stable/juno', '1', '/mnt/openstack-git', None, | 828 | 'stable/juno', '1', '/mnt/openstack-git', None, |
204 | 826 | update_requirements=True) | 829 | update_requirements=True, constraints=None) |
205 | 827 | ] | 830 | ] |
206 | 828 | self.assertEquals(expected, _git_install_single.call_args_list) | 831 | self.assertEquals(expected, _git_install_single.call_args_list) |
207 | 829 | assert not error_out.called | 832 | assert not error_out.called |
208 | @@ -855,7 +858,8 @@ | |||
209 | 855 | branch=branch) | 858 | branch=branch) |
210 | 856 | assert not _git_update_reqs.called | 859 | assert not _git_update_reqs.called |
211 | 857 | pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git', | 860 | pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git', |
213 | 858 | proxy='http://squid-proxy-url') | 861 | proxy='http://squid-proxy-url', |
214 | 862 | constraints=None) | ||
215 | 859 | 863 | ||
216 | 860 | @patch('os.path.join') | 864 | @patch('os.path.join') |
217 | 861 | @patch('os.mkdir') | 865 | @patch('os.mkdir') |
218 | @@ -887,7 +891,8 @@ | |||
219 | 887 | branch=branch) | 891 | branch=branch) |
220 | 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) |
221 | 889 | pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git', | 893 | pip_install.assert_called_with(dest_dir, venv='/mnt/openstack-git', |
223 | 890 | proxy='http://squid-proxy-url') | 894 | proxy='http://squid-proxy-url', |
224 | 895 | constraints=None) | ||
225 | 891 | 896 | ||
226 | 892 | @patch('os.path.join') | 897 | @patch('os.path.join') |
227 | 893 | @patch('os.getcwd') | 898 | @patch('os.getcwd') |