Merge lp:~corey.bryant/charms/trusty/keystone/systemd into lp:~openstack-charmers-archive/charms/trusty/keystone/next
- Trusty Tahr (14.04)
- systemd
- Merge into next
Proposed by
Corey Bryant
Status: | Needs review |
---|---|
Proposed branch: | lp:~corey.bryant/charms/trusty/keystone/systemd |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/keystone/next |
Diff against target: |
303 lines (+129/-36) 5 files modified
charmhelpers/contrib/openstack/neutron.py (+6/-8) charmhelpers/contrib/openstack/utils.py (+38/-0) charmhelpers/contrib/storage/linux/ceph.py (+38/-12) hooks/keystone_utils.py (+28/-16) templates/git/keystone.init.in.template (+19/-0) |
To merge this branch: | bzr merge lp:~corey.bryant/charms/trusty/keystone/systemd |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+287112@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #1408 keystone-next for corey.bryant mp287112
LINT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #518 keystone-next for corey.bryant mp287112
AMULET OK: passed
Unmerged revisions
- 212. By Corey Bryant
-
Add systemd init support for deploy from source
- 211. By Corey Bryant
-
Sync charm-helpers
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'charmhelpers/contrib/openstack/neutron.py' | |||
2 | --- charmhelpers/contrib/openstack/neutron.py 2016-02-19 14:49:59 +0000 | |||
3 | +++ charmhelpers/contrib/openstack/neutron.py 2016-02-24 22:53:43 +0000 | |||
4 | @@ -237,14 +237,12 @@ | |||
5 | 237 | plugins['midonet']['driver'] = ( | 237 | plugins['midonet']['driver'] = ( |
6 | 238 | 'neutron.plugins.midonet.plugin.MidonetPluginV2') | 238 | 'neutron.plugins.midonet.plugin.MidonetPluginV2') |
7 | 239 | if release >= 'liberty': | 239 | if release >= 'liberty': |
16 | 240 | midonet_origin = config('midonet-origin') | 240 | plugins['midonet']['driver'] = ( |
17 | 241 | if midonet_origin is not None and midonet_origin[4:5] == '1': | 241 | 'midonet.neutron.plugin_v1.MidonetPluginV2') |
18 | 242 | plugins['midonet']['driver'] = ( | 242 | plugins['midonet']['server_packages'].remove( |
19 | 243 | 'midonet.neutron.plugin_v1.MidonetPluginV2') | 243 | 'python-neutron-plugin-midonet') |
20 | 244 | plugins['midonet']['server_packages'].remove( | 244 | plugins['midonet']['server_packages'].append( |
21 | 245 | 'python-neutron-plugin-midonet') | 245 | 'python-networking-midonet') |
14 | 246 | plugins['midonet']['server_packages'].append( | ||
15 | 247 | 'python-networking-midonet') | ||
22 | 248 | return plugins | 246 | return plugins |
23 | 249 | 247 | ||
24 | 250 | 248 | ||
25 | 251 | 249 | ||
26 | === modified file 'charmhelpers/contrib/openstack/utils.py' | |||
27 | --- charmhelpers/contrib/openstack/utils.py 2016-02-19 14:49:59 +0000 | |||
28 | +++ charmhelpers/contrib/openstack/utils.py 2016-02-24 22:53:43 +0000 | |||
29 | @@ -24,6 +24,7 @@ | |||
30 | 24 | import sys | 24 | import sys |
31 | 25 | import re | 25 | import re |
32 | 26 | import itertools | 26 | import itertools |
33 | 27 | import shutil | ||
34 | 27 | 28 | ||
35 | 28 | import six | 29 | import six |
36 | 29 | import tempfile | 30 | import tempfile |
37 | @@ -846,6 +847,43 @@ | |||
38 | 846 | return None | 847 | return None |
39 | 847 | 848 | ||
40 | 848 | 849 | ||
41 | 850 | def git_generate_systemd_init_files(templates_dir): | ||
42 | 851 | """ | ||
43 | 852 | Generate systemd init files. | ||
44 | 853 | |||
45 | 854 | Generates and installs systemd init units and script files based on the | ||
46 | 855 | *.init.in files contained in the templates_dir directory. | ||
47 | 856 | """ | ||
48 | 857 | for f in os.listdir(templates_dir): | ||
49 | 858 | if f.endswith(".init.in"): | ||
50 | 859 | init_in_f = f | ||
51 | 860 | init_f = f[:-8] | ||
52 | 861 | service_f = init_f + '.service' | ||
53 | 862 | |||
54 | 863 | init_in = os.path.join(templates_dir, init_in_f) | ||
55 | 864 | init = os.path.join(templates_dir, init_f) | ||
56 | 865 | service = os.path.join(templates_dir, service_f) | ||
57 | 866 | |||
58 | 867 | init_dest = os.path.join('/etc/init.d', init_f) | ||
59 | 868 | service_dest = os.path.join('/lib/systemd/system', service_f) | ||
60 | 869 | |||
61 | 870 | shutil.copyfile(init_in, init) | ||
62 | 871 | with open(init, 'a') as outfile: | ||
63 | 872 | with open('/usr/share/openstack-pkg-tools/init-script-template') as infile: | ||
64 | 873 | outfile.write(infile.read()) | ||
65 | 874 | |||
66 | 875 | cmd = ['pkgos-gen-systemd-unit', init_in] | ||
67 | 876 | subprocess.check_call(cmd) | ||
68 | 877 | |||
69 | 878 | if os.path.exists(init_dest): | ||
70 | 879 | os.remove(init_dest) | ||
71 | 880 | if os.path.exists(service_dest): | ||
72 | 881 | os.remove(service_dest) | ||
73 | 882 | shutil.move(init, init_dest) | ||
74 | 883 | shutil.move(service, service_dest) | ||
75 | 884 | os.chmod(init_dest, 0o755) | ||
76 | 885 | |||
77 | 886 | |||
78 | 849 | def os_workload_status(configs, required_interfaces, charm_func=None): | 887 | def os_workload_status(configs, required_interfaces, charm_func=None): |
79 | 850 | """ | 888 | """ |
80 | 851 | Decorator to set workload status based on complete contexts | 889 | Decorator to set workload status based on complete contexts |
81 | 852 | 890 | ||
82 | === modified file 'charmhelpers/contrib/storage/linux/ceph.py' | |||
83 | --- charmhelpers/contrib/storage/linux/ceph.py 2016-01-04 21:27:51 +0000 | |||
84 | +++ charmhelpers/contrib/storage/linux/ceph.py 2016-02-24 22:53:43 +0000 | |||
85 | @@ -120,6 +120,7 @@ | |||
86 | 120 | """ | 120 | """ |
87 | 121 | A custom error to inform the caller that a pool creation failed. Provides an error message | 121 | A custom error to inform the caller that a pool creation failed. Provides an error message |
88 | 122 | """ | 122 | """ |
89 | 123 | |||
90 | 123 | def __init__(self, message): | 124 | def __init__(self, message): |
91 | 124 | super(PoolCreationError, self).__init__(message) | 125 | super(PoolCreationError, self).__init__(message) |
92 | 125 | 126 | ||
93 | @@ -129,6 +130,7 @@ | |||
94 | 129 | An object oriented approach to Ceph pool creation. This base class is inherited by ReplicatedPool and ErasurePool. | 130 | An object oriented approach to Ceph pool creation. This base class is inherited by ReplicatedPool and ErasurePool. |
95 | 130 | Do not call create() on this base class as it will not do anything. Instantiate a child class and call create(). | 131 | Do not call create() on this base class as it will not do anything. Instantiate a child class and call create(). |
96 | 131 | """ | 132 | """ |
97 | 133 | |||
98 | 132 | def __init__(self, service, name): | 134 | def __init__(self, service, name): |
99 | 133 | self.service = service | 135 | self.service = service |
100 | 134 | self.name = name | 136 | self.name = name |
101 | @@ -180,36 +182,41 @@ | |||
102 | 180 | :return: int. The number of pgs to use. | 182 | :return: int. The number of pgs to use. |
103 | 181 | """ | 183 | """ |
104 | 182 | validator(value=pool_size, valid_type=int) | 184 | validator(value=pool_size, valid_type=int) |
107 | 183 | osds = get_osds(self.service) | 185 | osd_list = get_osds(self.service) |
108 | 184 | if not osds: | 186 | if not osd_list: |
109 | 185 | # NOTE(james-page): Default to 200 for older ceph versions | 187 | # NOTE(james-page): Default to 200 for older ceph versions |
110 | 186 | # which don't support OSD query from cli | 188 | # which don't support OSD query from cli |
111 | 187 | return 200 | 189 | return 200 |
112 | 188 | 190 | ||
113 | 191 | osd_list_length = len(osd_list) | ||
114 | 189 | # Calculate based on Ceph best practices | 192 | # Calculate based on Ceph best practices |
116 | 190 | if osds < 5: | 193 | if osd_list_length < 5: |
117 | 191 | return 128 | 194 | return 128 |
119 | 192 | elif 5 < osds < 10: | 195 | elif 5 < osd_list_length < 10: |
120 | 193 | return 512 | 196 | return 512 |
122 | 194 | elif 10 < osds < 50: | 197 | elif 10 < osd_list_length < 50: |
123 | 195 | return 4096 | 198 | return 4096 |
124 | 196 | else: | 199 | else: |
126 | 197 | estimate = (osds * 100) / pool_size | 200 | estimate = (osd_list_length * 100) / pool_size |
127 | 198 | # Return the next nearest power of 2 | 201 | # Return the next nearest power of 2 |
128 | 199 | index = bisect.bisect_right(powers_of_two, estimate) | 202 | index = bisect.bisect_right(powers_of_two, estimate) |
129 | 200 | return powers_of_two[index] | 203 | return powers_of_two[index] |
130 | 201 | 204 | ||
131 | 202 | 205 | ||
132 | 203 | class ReplicatedPool(Pool): | 206 | class ReplicatedPool(Pool): |
134 | 204 | def __init__(self, service, name, replicas=2): | 207 | def __init__(self, service, name, pg_num=None, replicas=2): |
135 | 205 | super(ReplicatedPool, self).__init__(service=service, name=name) | 208 | super(ReplicatedPool, self).__init__(service=service, name=name) |
136 | 206 | self.replicas = replicas | 209 | self.replicas = replicas |
137 | 210 | if pg_num is None: | ||
138 | 211 | self.pg_num = self.get_pgs(self.replicas) | ||
139 | 212 | else: | ||
140 | 213 | self.pg_num = pg_num | ||
141 | 207 | 214 | ||
142 | 208 | def create(self): | 215 | def create(self): |
143 | 209 | if not pool_exists(self.service, self.name): | 216 | if not pool_exists(self.service, self.name): |
144 | 210 | # Create it | 217 | # Create it |
147 | 211 | pgs = self.get_pgs(self.replicas) | 218 | cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', |
148 | 212 | cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', self.name, str(pgs)] | 219 | self.name, str(self.pg_num)] |
149 | 213 | try: | 220 | try: |
150 | 214 | check_call(cmd) | 221 | check_call(cmd) |
151 | 215 | except CalledProcessError: | 222 | except CalledProcessError: |
152 | @@ -241,7 +248,7 @@ | |||
153 | 241 | 248 | ||
154 | 242 | pgs = self.get_pgs(int(erasure_profile['k']) + int(erasure_profile['m'])) | 249 | pgs = self.get_pgs(int(erasure_profile['k']) + int(erasure_profile['m'])) |
155 | 243 | # Create it | 250 | # Create it |
157 | 244 | cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', self.name, str(pgs), | 251 | cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', self.name, str(pgs), str(pgs), |
158 | 245 | 'erasure', self.erasure_code_profile] | 252 | 'erasure', self.erasure_code_profile] |
159 | 246 | try: | 253 | try: |
160 | 247 | check_call(cmd) | 254 | check_call(cmd) |
161 | @@ -322,7 +329,8 @@ | |||
162 | 322 | :return: None. Can raise CalledProcessError | 329 | :return: None. Can raise CalledProcessError |
163 | 323 | """ | 330 | """ |
164 | 324 | # Set a byte quota on a RADOS pool in ceph. | 331 | # Set a byte quota on a RADOS pool in ceph. |
166 | 325 | cmd = ['ceph', '--id', service, 'osd', 'pool', 'set-quota', pool_name, 'max_bytes', max_bytes] | 332 | cmd = ['ceph', '--id', service, 'osd', 'pool', 'set-quota', pool_name, |
167 | 333 | 'max_bytes', str(max_bytes)] | ||
168 | 326 | try: | 334 | try: |
169 | 327 | check_call(cmd) | 335 | check_call(cmd) |
170 | 328 | except CalledProcessError: | 336 | except CalledProcessError: |
171 | @@ -343,7 +351,25 @@ | |||
172 | 343 | raise | 351 | raise |
173 | 344 | 352 | ||
174 | 345 | 353 | ||
176 | 346 | def create_erasure_profile(service, profile_name, erasure_plugin_name='jerasure', failure_domain='host', | 354 | def remove_erasure_profile(service, profile_name): |
177 | 355 | """ | ||
178 | 356 | Create a new erasure code profile if one does not already exist for it. Updates | ||
179 | 357 | the profile if it exists. Please see http://docs.ceph.com/docs/master/rados/operations/erasure-code-profile/ | ||
180 | 358 | for more details | ||
181 | 359 | :param service: six.string_types. The Ceph user name to run the command under | ||
182 | 360 | :param profile_name: six.string_types | ||
183 | 361 | :return: None. Can raise CalledProcessError | ||
184 | 362 | """ | ||
185 | 363 | cmd = ['ceph', '--id', service, 'osd', 'erasure-code-profile', 'rm', | ||
186 | 364 | profile_name] | ||
187 | 365 | try: | ||
188 | 366 | check_call(cmd) | ||
189 | 367 | except CalledProcessError: | ||
190 | 368 | raise | ||
191 | 369 | |||
192 | 370 | |||
193 | 371 | def create_erasure_profile(service, profile_name, erasure_plugin_name='jerasure', | ||
194 | 372 | failure_domain='host', | ||
195 | 347 | data_chunks=2, coding_chunks=1, | 373 | data_chunks=2, coding_chunks=1, |
196 | 348 | locality=None, durability_estimator=None): | 374 | locality=None, durability_estimator=None): |
197 | 349 | """ | 375 | """ |
198 | 350 | 376 | ||
199 | === modified file 'hooks/keystone_utils.py' | |||
200 | --- hooks/keystone_utils.py 2016-02-19 14:49:59 +0000 | |||
201 | +++ hooks/keystone_utils.py 2016-02-24 22:53:43 +0000 | |||
202 | @@ -44,6 +44,7 @@ | |||
203 | 44 | configure_installation_source, | 44 | configure_installation_source, |
204 | 45 | error_out, | 45 | error_out, |
205 | 46 | get_os_codename_install_source, | 46 | get_os_codename_install_source, |
206 | 47 | git_generate_systemd_init_files, | ||
207 | 47 | git_install_requested, | 48 | git_install_requested, |
208 | 48 | git_clone_and_install, | 49 | git_clone_and_install, |
209 | 49 | git_src_dir, | 50 | git_src_dir, |
210 | @@ -97,12 +98,12 @@ | |||
211 | 97 | adduser, | 98 | adduser, |
212 | 98 | add_group, | 99 | add_group, |
213 | 99 | add_user_to_group, | 100 | add_user_to_group, |
214 | 101 | lsb_release, | ||
215 | 100 | mkdir, | 102 | mkdir, |
216 | 101 | service_stop, | 103 | service_stop, |
217 | 102 | service_start, | 104 | service_start, |
218 | 103 | service_restart, | 105 | service_restart, |
219 | 104 | pwgen, | 106 | pwgen, |
220 | 105 | lsb_release, | ||
221 | 106 | write_file, | 107 | write_file, |
222 | 107 | ) | 108 | ) |
223 | 108 | 109 | ||
224 | @@ -146,6 +147,7 @@ | |||
225 | 146 | 'libxml2-dev', | 147 | 'libxml2-dev', |
226 | 147 | 'libxslt1-dev', | 148 | 'libxslt1-dev', |
227 | 148 | 'libyaml-dev', | 149 | 'libyaml-dev', |
228 | 150 | 'openstack-pkg-tools', | ||
229 | 149 | 'python-dev', | 151 | 'python-dev', |
230 | 150 | 'python-pip', | 152 | 'python-pip', |
231 | 151 | 'python-setuptools', | 153 | 'python-setuptools', |
232 | @@ -1811,22 +1813,32 @@ | |||
233 | 1811 | render('git/logging.conf', '/etc/keystone/logging.conf', {}, perms=0o644) | 1813 | render('git/logging.conf', '/etc/keystone/logging.conf', {}, perms=0o644) |
234 | 1812 | 1814 | ||
235 | 1813 | bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin') | 1815 | bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin') |
236 | 1814 | keystone_context = { | ||
237 | 1815 | 'service_description': 'Keystone API server', | ||
238 | 1816 | 'service_name': 'Keystone', | ||
239 | 1817 | 'user_name': 'keystone', | ||
240 | 1818 | 'start_dir': '/var/lib/keystone', | ||
241 | 1819 | 'process_name': 'keystone', | ||
242 | 1820 | 'executable_name': os.path.join(bin_dir, 'keystone-all'), | ||
243 | 1821 | 'config_files': ['/etc/keystone/keystone.conf'], | ||
244 | 1822 | 'log_file': '/var/log/keystone/keystone.log', | ||
245 | 1823 | } | ||
246 | 1824 | 1816 | ||
252 | 1825 | # NOTE(coreycb): Needs systemd support | 1817 | # Use systemd init units/scripts from ubuntu wily onward |
253 | 1826 | templates_dir = 'hooks/charmhelpers/contrib/openstack/templates' | 1818 | if lsb_release()['DISTRIB_RELEASE'] >= '15.10': |
254 | 1827 | templates_dir = os.path.join(charm_dir(), templates_dir) | 1819 | keystone_context = { |
255 | 1828 | render('git.upstart', '/etc/init/keystone.conf', keystone_context, | 1820 | 'daemon_path': os.path.join(bin_dir, 'keystone-all'), |
256 | 1829 | perms=0o644, templates_dir=templates_dir) | 1821 | } |
257 | 1822 | templates_dir = os.path.join(charm_dir(), 'templates/git') | ||
258 | 1823 | render('git/keystone.init.in.template', | ||
259 | 1824 | os.path.join(templates_dir, 'keystone.init.in'), | ||
260 | 1825 | keystone_context, perms=0o644) | ||
261 | 1826 | git_generate_systemd_init_files(templates_dir) | ||
262 | 1827 | else: | ||
263 | 1828 | keystone_context = { | ||
264 | 1829 | 'service_description': 'Keystone API server', | ||
265 | 1830 | 'service_name': 'Keystone', | ||
266 | 1831 | 'user_name': 'keystone', | ||
267 | 1832 | 'start_dir': '/var/lib/keystone', | ||
268 | 1833 | 'process_name': 'keystone', | ||
269 | 1834 | 'executable_name': os.path.join(bin_dir, 'keystone-all'), | ||
270 | 1835 | 'config_files': ['/etc/keystone/keystone.conf'], | ||
271 | 1836 | 'log_file': '/var/log/keystone/keystone.log', | ||
272 | 1837 | } | ||
273 | 1838 | templates_dir = 'hooks/charmhelpers/contrib/openstack/templates' | ||
274 | 1839 | templates_dir = os.path.join(charm_dir(), templates_dir) | ||
275 | 1840 | render('git.upstart', '/etc/init/keystone.conf', keystone_context, | ||
276 | 1841 | perms=0o644, templates_dir=templates_dir) | ||
277 | 1830 | 1842 | ||
278 | 1831 | service_restart('keystone') | 1843 | service_restart('keystone') |
279 | 1832 | 1844 | ||
280 | 1833 | 1845 | ||
281 | === added file 'templates/git/keystone.init.in.template' | |||
282 | --- templates/git/keystone.init.in.template 1970-01-01 00:00:00 +0000 | |||
283 | +++ templates/git/keystone.init.in.template 2016-02-24 22:53:43 +0000 | |||
284 | @@ -0,0 +1,19 @@ | |||
285 | 1 | #!/bin/sh | ||
286 | 2 | ### BEGIN INIT INFO | ||
287 | 3 | # Provides: keystone | ||
288 | 4 | # Required-Start: $network $local_fs $remote_fs | ||
289 | 5 | # Required-Stop: $remote_fs | ||
290 | 6 | # Should-Start: mysql postgresql slapd rabbitmq-server ntp | ||
291 | 7 | # Should-Stop: mysql postgresql slapd rabbitmq-server ntp | ||
292 | 8 | # Default-Start: 2 3 4 5 | ||
293 | 9 | # Default-Stop: 0 1 6 | ||
294 | 10 | # Short-Description: OpenStack cloud identity service | ||
295 | 11 | # Description: This is the identity service used by OpenStack for | ||
296 | 12 | # authentication (authN) and high-level authorization (authZ). | ||
297 | 13 | ### END INIT INFO | ||
298 | 14 | |||
299 | 15 | DESC="OpenStack Identity service" | ||
300 | 16 | PROJECT_NAME=keystone | ||
301 | 17 | NAME=keystone | ||
302 | 18 | DAEMON={{ daemon_path }} | ||
303 | 19 |
charm_unit_test #1165 keystone-next for corey.bryant mp287112
UNIT FAIL: unit-test failed
UNIT Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full unit test output: http:// paste.ubuntu. com/15191779/ 10.245. 162.36: 8080/job/ charm_unit_ test/1165/
Build: http://