Merge lp:~corey.bryant/charms/trusty/keystone/systemd into lp:~openstack-charmers-archive/charms/trusty/keystone/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
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+287112@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/
Build: http://10.245.162.36:8080/job/charm_unit_test/1165/

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

Build: http://10.245.162.36:8080/job/charm_lint_check/1408/

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

Build: http://10.245.162.36:8080/job/charm_amulet_test/518/

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 plugins['midonet']['driver'] = (
6 'neutron.plugins.midonet.plugin.MidonetPluginV2')
7 if release >= 'liberty':
8- midonet_origin = config('midonet-origin')
9- if midonet_origin is not None and midonet_origin[4:5] == '1':
10- plugins['midonet']['driver'] = (
11- 'midonet.neutron.plugin_v1.MidonetPluginV2')
12- plugins['midonet']['server_packages'].remove(
13- 'python-neutron-plugin-midonet')
14- plugins['midonet']['server_packages'].append(
15- 'python-networking-midonet')
16+ plugins['midonet']['driver'] = (
17+ 'midonet.neutron.plugin_v1.MidonetPluginV2')
18+ plugins['midonet']['server_packages'].remove(
19+ 'python-neutron-plugin-midonet')
20+ plugins['midonet']['server_packages'].append(
21+ 'python-networking-midonet')
22 return plugins
23
24
25
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 import sys
31 import re
32 import itertools
33+import shutil
34
35 import six
36 import tempfile
37@@ -846,6 +847,43 @@
38 return None
39
40
41+def git_generate_systemd_init_files(templates_dir):
42+ """
43+ Generate systemd init files.
44+
45+ Generates and installs systemd init units and script files based on the
46+ *.init.in files contained in the templates_dir directory.
47+ """
48+ for f in os.listdir(templates_dir):
49+ if f.endswith(".init.in"):
50+ init_in_f = f
51+ init_f = f[:-8]
52+ service_f = init_f + '.service'
53+
54+ init_in = os.path.join(templates_dir, init_in_f)
55+ init = os.path.join(templates_dir, init_f)
56+ service = os.path.join(templates_dir, service_f)
57+
58+ init_dest = os.path.join('/etc/init.d', init_f)
59+ service_dest = os.path.join('/lib/systemd/system', service_f)
60+
61+ shutil.copyfile(init_in, init)
62+ with open(init, 'a') as outfile:
63+ with open('/usr/share/openstack-pkg-tools/init-script-template') as infile:
64+ outfile.write(infile.read())
65+
66+ cmd = ['pkgos-gen-systemd-unit', init_in]
67+ subprocess.check_call(cmd)
68+
69+ if os.path.exists(init_dest):
70+ os.remove(init_dest)
71+ if os.path.exists(service_dest):
72+ os.remove(service_dest)
73+ shutil.move(init, init_dest)
74+ shutil.move(service, service_dest)
75+ os.chmod(init_dest, 0o755)
76+
77+
78 def os_workload_status(configs, required_interfaces, charm_func=None):
79 """
80 Decorator to set workload status based on complete contexts
81
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 """
87 A custom error to inform the caller that a pool creation failed. Provides an error message
88 """
89+
90 def __init__(self, message):
91 super(PoolCreationError, self).__init__(message)
92
93@@ -129,6 +130,7 @@
94 An object oriented approach to Ceph pool creation. This base class is inherited by ReplicatedPool and ErasurePool.
95 Do not call create() on this base class as it will not do anything. Instantiate a child class and call create().
96 """
97+
98 def __init__(self, service, name):
99 self.service = service
100 self.name = name
101@@ -180,36 +182,41 @@
102 :return: int. The number of pgs to use.
103 """
104 validator(value=pool_size, valid_type=int)
105- osds = get_osds(self.service)
106- if not osds:
107+ osd_list = get_osds(self.service)
108+ if not osd_list:
109 # NOTE(james-page): Default to 200 for older ceph versions
110 # which don't support OSD query from cli
111 return 200
112
113+ osd_list_length = len(osd_list)
114 # Calculate based on Ceph best practices
115- if osds < 5:
116+ if osd_list_length < 5:
117 return 128
118- elif 5 < osds < 10:
119+ elif 5 < osd_list_length < 10:
120 return 512
121- elif 10 < osds < 50:
122+ elif 10 < osd_list_length < 50:
123 return 4096
124 else:
125- estimate = (osds * 100) / pool_size
126+ estimate = (osd_list_length * 100) / pool_size
127 # Return the next nearest power of 2
128 index = bisect.bisect_right(powers_of_two, estimate)
129 return powers_of_two[index]
130
131
132 class ReplicatedPool(Pool):
133- def __init__(self, service, name, replicas=2):
134+ def __init__(self, service, name, pg_num=None, replicas=2):
135 super(ReplicatedPool, self).__init__(service=service, name=name)
136 self.replicas = replicas
137+ if pg_num is None:
138+ self.pg_num = self.get_pgs(self.replicas)
139+ else:
140+ self.pg_num = pg_num
141
142 def create(self):
143 if not pool_exists(self.service, self.name):
144 # Create it
145- pgs = self.get_pgs(self.replicas)
146- cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', self.name, str(pgs)]
147+ cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create',
148+ self.name, str(self.pg_num)]
149 try:
150 check_call(cmd)
151 except CalledProcessError:
152@@ -241,7 +248,7 @@
153
154 pgs = self.get_pgs(int(erasure_profile['k']) + int(erasure_profile['m']))
155 # Create it
156- cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', self.name, str(pgs),
157+ cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', self.name, str(pgs), str(pgs),
158 'erasure', self.erasure_code_profile]
159 try:
160 check_call(cmd)
161@@ -322,7 +329,8 @@
162 :return: None. Can raise CalledProcessError
163 """
164 # Set a byte quota on a RADOS pool in ceph.
165- cmd = ['ceph', '--id', service, 'osd', 'pool', 'set-quota', pool_name, 'max_bytes', max_bytes]
166+ cmd = ['ceph', '--id', service, 'osd', 'pool', 'set-quota', pool_name,
167+ 'max_bytes', str(max_bytes)]
168 try:
169 check_call(cmd)
170 except CalledProcessError:
171@@ -343,7 +351,25 @@
172 raise
173
174
175-def create_erasure_profile(service, profile_name, erasure_plugin_name='jerasure', failure_domain='host',
176+def remove_erasure_profile(service, profile_name):
177+ """
178+ Create a new erasure code profile if one does not already exist for it. Updates
179+ the profile if it exists. Please see http://docs.ceph.com/docs/master/rados/operations/erasure-code-profile/
180+ for more details
181+ :param service: six.string_types. The Ceph user name to run the command under
182+ :param profile_name: six.string_types
183+ :return: None. Can raise CalledProcessError
184+ """
185+ cmd = ['ceph', '--id', service, 'osd', 'erasure-code-profile', 'rm',
186+ profile_name]
187+ try:
188+ check_call(cmd)
189+ except CalledProcessError:
190+ raise
191+
192+
193+def create_erasure_profile(service, profile_name, erasure_plugin_name='jerasure',
194+ failure_domain='host',
195 data_chunks=2, coding_chunks=1,
196 locality=None, durability_estimator=None):
197 """
198
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 configure_installation_source,
204 error_out,
205 get_os_codename_install_source,
206+ git_generate_systemd_init_files,
207 git_install_requested,
208 git_clone_and_install,
209 git_src_dir,
210@@ -97,12 +98,12 @@
211 adduser,
212 add_group,
213 add_user_to_group,
214+ lsb_release,
215 mkdir,
216 service_stop,
217 service_start,
218 service_restart,
219 pwgen,
220- lsb_release,
221 write_file,
222 )
223
224@@ -146,6 +147,7 @@
225 'libxml2-dev',
226 'libxslt1-dev',
227 'libyaml-dev',
228+ 'openstack-pkg-tools',
229 'python-dev',
230 'python-pip',
231 'python-setuptools',
232@@ -1811,22 +1813,32 @@
233 render('git/logging.conf', '/etc/keystone/logging.conf', {}, perms=0o644)
234
235 bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin')
236- keystone_context = {
237- 'service_description': 'Keystone API server',
238- 'service_name': 'Keystone',
239- 'user_name': 'keystone',
240- 'start_dir': '/var/lib/keystone',
241- 'process_name': 'keystone',
242- 'executable_name': os.path.join(bin_dir, 'keystone-all'),
243- 'config_files': ['/etc/keystone/keystone.conf'],
244- 'log_file': '/var/log/keystone/keystone.log',
245- }
246
247- # NOTE(coreycb): Needs systemd support
248- templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
249- templates_dir = os.path.join(charm_dir(), templates_dir)
250- render('git.upstart', '/etc/init/keystone.conf', keystone_context,
251- perms=0o644, templates_dir=templates_dir)
252+ # Use systemd init units/scripts from ubuntu wily onward
253+ if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
254+ keystone_context = {
255+ 'daemon_path': os.path.join(bin_dir, 'keystone-all'),
256+ }
257+ templates_dir = os.path.join(charm_dir(), 'templates/git')
258+ render('git/keystone.init.in.template',
259+ os.path.join(templates_dir, 'keystone.init.in'),
260+ keystone_context, perms=0o644)
261+ git_generate_systemd_init_files(templates_dir)
262+ else:
263+ keystone_context = {
264+ 'service_description': 'Keystone API server',
265+ 'service_name': 'Keystone',
266+ 'user_name': 'keystone',
267+ 'start_dir': '/var/lib/keystone',
268+ 'process_name': 'keystone',
269+ 'executable_name': os.path.join(bin_dir, 'keystone-all'),
270+ 'config_files': ['/etc/keystone/keystone.conf'],
271+ 'log_file': '/var/log/keystone/keystone.log',
272+ }
273+ templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
274+ templates_dir = os.path.join(charm_dir(), templates_dir)
275+ render('git.upstart', '/etc/init/keystone.conf', keystone_context,
276+ perms=0o644, templates_dir=templates_dir)
277
278 service_restart('keystone')
279
280
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+#!/bin/sh
286+### BEGIN INIT INFO
287+# Provides: keystone
288+# Required-Start: $network $local_fs $remote_fs
289+# Required-Stop: $remote_fs
290+# Should-Start: mysql postgresql slapd rabbitmq-server ntp
291+# Should-Stop: mysql postgresql slapd rabbitmq-server ntp
292+# Default-Start: 2 3 4 5
293+# Default-Stop: 0 1 6
294+# Short-Description: OpenStack cloud identity service
295+# Description: This is the identity service used by OpenStack for
296+# authentication (authN) and high-level authorization (authZ).
297+### END INIT INFO
298+
299+DESC="OpenStack Identity service"
300+PROJECT_NAME=keystone
301+NAME=keystone
302+DAEMON={{ daemon_path }}
303+

Subscribers

People subscribed via source and target branches