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
=== modified file 'charmhelpers/contrib/openstack/neutron.py'
--- charmhelpers/contrib/openstack/neutron.py 2016-02-19 14:49:59 +0000
+++ charmhelpers/contrib/openstack/neutron.py 2016-02-24 22:53:43 +0000
@@ -237,14 +237,12 @@
237 plugins['midonet']['driver'] = (237 plugins['midonet']['driver'] = (
238 'neutron.plugins.midonet.plugin.MidonetPluginV2')238 'neutron.plugins.midonet.plugin.MidonetPluginV2')
239 if release >= 'liberty':239 if release >= 'liberty':
240 midonet_origin = config('midonet-origin')240 plugins['midonet']['driver'] = (
241 if midonet_origin is not None and midonet_origin[4:5] == '1':241 'midonet.neutron.plugin_v1.MidonetPluginV2')
242 plugins['midonet']['driver'] = (242 plugins['midonet']['server_packages'].remove(
243 'midonet.neutron.plugin_v1.MidonetPluginV2')243 'python-neutron-plugin-midonet')
244 plugins['midonet']['server_packages'].remove(244 plugins['midonet']['server_packages'].append(
245 'python-neutron-plugin-midonet')245 'python-networking-midonet')
246 plugins['midonet']['server_packages'].append(
247 'python-networking-midonet')
248 return plugins246 return plugins
249247
250248
251249
=== modified file 'charmhelpers/contrib/openstack/utils.py'
--- charmhelpers/contrib/openstack/utils.py 2016-02-19 14:49:59 +0000
+++ charmhelpers/contrib/openstack/utils.py 2016-02-24 22:53:43 +0000
@@ -24,6 +24,7 @@
24import sys24import sys
25import re25import re
26import itertools26import itertools
27import shutil
2728
28import six29import six
29import tempfile30import tempfile
@@ -846,6 +847,43 @@
846 return None847 return None
847848
848849
850def git_generate_systemd_init_files(templates_dir):
851 """
852 Generate systemd init files.
853
854 Generates and installs systemd init units and script files based on the
855 *.init.in files contained in the templates_dir directory.
856 """
857 for f in os.listdir(templates_dir):
858 if f.endswith(".init.in"):
859 init_in_f = f
860 init_f = f[:-8]
861 service_f = init_f + '.service'
862
863 init_in = os.path.join(templates_dir, init_in_f)
864 init = os.path.join(templates_dir, init_f)
865 service = os.path.join(templates_dir, service_f)
866
867 init_dest = os.path.join('/etc/init.d', init_f)
868 service_dest = os.path.join('/lib/systemd/system', service_f)
869
870 shutil.copyfile(init_in, init)
871 with open(init, 'a') as outfile:
872 with open('/usr/share/openstack-pkg-tools/init-script-template') as infile:
873 outfile.write(infile.read())
874
875 cmd = ['pkgos-gen-systemd-unit', init_in]
876 subprocess.check_call(cmd)
877
878 if os.path.exists(init_dest):
879 os.remove(init_dest)
880 if os.path.exists(service_dest):
881 os.remove(service_dest)
882 shutil.move(init, init_dest)
883 shutil.move(service, service_dest)
884 os.chmod(init_dest, 0o755)
885
886
849def os_workload_status(configs, required_interfaces, charm_func=None):887def os_workload_status(configs, required_interfaces, charm_func=None):
850 """888 """
851 Decorator to set workload status based on complete contexts889 Decorator to set workload status based on complete contexts
852890
=== modified file 'charmhelpers/contrib/storage/linux/ceph.py'
--- charmhelpers/contrib/storage/linux/ceph.py 2016-01-04 21:27:51 +0000
+++ charmhelpers/contrib/storage/linux/ceph.py 2016-02-24 22:53:43 +0000
@@ -120,6 +120,7 @@
120 """120 """
121 A custom error to inform the caller that a pool creation failed. Provides an error message121 A custom error to inform the caller that a pool creation failed. Provides an error message
122 """122 """
123
123 def __init__(self, message):124 def __init__(self, message):
124 super(PoolCreationError, self).__init__(message)125 super(PoolCreationError, self).__init__(message)
125126
@@ -129,6 +130,7 @@
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.
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().
131 """132 """
133
132 def __init__(self, service, name):134 def __init__(self, service, name):
133 self.service = service135 self.service = service
134 self.name = name136 self.name = name
@@ -180,36 +182,41 @@
180 :return: int. The number of pgs to use.182 :return: int. The number of pgs to use.
181 """183 """
182 validator(value=pool_size, valid_type=int)184 validator(value=pool_size, valid_type=int)
183 osds = get_osds(self.service)185 osd_list = get_osds(self.service)
184 if not osds:186 if not osd_list:
185 # NOTE(james-page): Default to 200 for older ceph versions187 # NOTE(james-page): Default to 200 for older ceph versions
186 # which don't support OSD query from cli188 # which don't support OSD query from cli
187 return 200189 return 200
188190
191 osd_list_length = len(osd_list)
189 # Calculate based on Ceph best practices192 # Calculate based on Ceph best practices
190 if osds < 5:193 if osd_list_length < 5:
191 return 128194 return 128
192 elif 5 < osds < 10:195 elif 5 < osd_list_length < 10:
193 return 512196 return 512
194 elif 10 < osds < 50:197 elif 10 < osd_list_length < 50:
195 return 4096198 return 4096
196 else:199 else:
197 estimate = (osds * 100) / pool_size200 estimate = (osd_list_length * 100) / pool_size
198 # Return the next nearest power of 2201 # Return the next nearest power of 2
199 index = bisect.bisect_right(powers_of_two, estimate)202 index = bisect.bisect_right(powers_of_two, estimate)
200 return powers_of_two[index]203 return powers_of_two[index]
201204
202205
203class ReplicatedPool(Pool):206class ReplicatedPool(Pool):
204 def __init__(self, service, name, replicas=2):207 def __init__(self, service, name, pg_num=None, replicas=2):
205 super(ReplicatedPool, self).__init__(service=service, name=name)208 super(ReplicatedPool, self).__init__(service=service, name=name)
206 self.replicas = replicas209 self.replicas = replicas
210 if pg_num is None:
211 self.pg_num = self.get_pgs(self.replicas)
212 else:
213 self.pg_num = pg_num
207214
208 def create(self):215 def create(self):
209 if not pool_exists(self.service, self.name):216 if not pool_exists(self.service, self.name):
210 # Create it217 # Create it
211 pgs = self.get_pgs(self.replicas)218 cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create',
212 cmd = ['ceph', '--id', self.service, 'osd', 'pool', 'create', self.name, str(pgs)]219 self.name, str(self.pg_num)]
213 try:220 try:
214 check_call(cmd)221 check_call(cmd)
215 except CalledProcessError:222 except CalledProcessError:
@@ -241,7 +248,7 @@
241248
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']))
243 # Create it250 # Create it
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),
245 'erasure', self.erasure_code_profile]252 'erasure', self.erasure_code_profile]
246 try:253 try:
247 check_call(cmd)254 check_call(cmd)
@@ -322,7 +329,8 @@
322 :return: None. Can raise CalledProcessError329 :return: None. Can raise CalledProcessError
323 """330 """
324 # Set a byte quota on a RADOS pool in ceph.331 # Set a byte quota on a RADOS pool in ceph.
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,
333 'max_bytes', str(max_bytes)]
326 try:334 try:
327 check_call(cmd)335 check_call(cmd)
328 except CalledProcessError:336 except CalledProcessError:
@@ -343,7 +351,25 @@
343 raise351 raise
344352
345353
346def create_erasure_profile(service, profile_name, erasure_plugin_name='jerasure', failure_domain='host',354def remove_erasure_profile(service, profile_name):
355 """
356 Create a new erasure code profile if one does not already exist for it. Updates
357 the profile if it exists. Please see http://docs.ceph.com/docs/master/rados/operations/erasure-code-profile/
358 for more details
359 :param service: six.string_types. The Ceph user name to run the command under
360 :param profile_name: six.string_types
361 :return: None. Can raise CalledProcessError
362 """
363 cmd = ['ceph', '--id', service, 'osd', 'erasure-code-profile', 'rm',
364 profile_name]
365 try:
366 check_call(cmd)
367 except CalledProcessError:
368 raise
369
370
371def create_erasure_profile(service, profile_name, erasure_plugin_name='jerasure',
372 failure_domain='host',
347 data_chunks=2, coding_chunks=1,373 data_chunks=2, coding_chunks=1,
348 locality=None, durability_estimator=None):374 locality=None, durability_estimator=None):
349 """375 """
350376
=== modified file 'hooks/keystone_utils.py'
--- hooks/keystone_utils.py 2016-02-19 14:49:59 +0000
+++ hooks/keystone_utils.py 2016-02-24 22:53:43 +0000
@@ -44,6 +44,7 @@
44 configure_installation_source,44 configure_installation_source,
45 error_out,45 error_out,
46 get_os_codename_install_source,46 get_os_codename_install_source,
47 git_generate_systemd_init_files,
47 git_install_requested,48 git_install_requested,
48 git_clone_and_install,49 git_clone_and_install,
49 git_src_dir,50 git_src_dir,
@@ -97,12 +98,12 @@
97 adduser,98 adduser,
98 add_group,99 add_group,
99 add_user_to_group,100 add_user_to_group,
101 lsb_release,
100 mkdir,102 mkdir,
101 service_stop,103 service_stop,
102 service_start,104 service_start,
103 service_restart,105 service_restart,
104 pwgen,106 pwgen,
105 lsb_release,
106 write_file,107 write_file,
107)108)
108109
@@ -146,6 +147,7 @@
146 'libxml2-dev',147 'libxml2-dev',
147 'libxslt1-dev',148 'libxslt1-dev',
148 'libyaml-dev',149 'libyaml-dev',
150 'openstack-pkg-tools',
149 'python-dev',151 'python-dev',
150 'python-pip',152 'python-pip',
151 'python-setuptools',153 'python-setuptools',
@@ -1811,22 +1813,32 @@
1811 render('git/logging.conf', '/etc/keystone/logging.conf', {}, perms=0o644)1813 render('git/logging.conf', '/etc/keystone/logging.conf', {}, perms=0o644)
18121814
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')
1814 keystone_context = {
1815 'service_description': 'Keystone API server',
1816 'service_name': 'Keystone',
1817 'user_name': 'keystone',
1818 'start_dir': '/var/lib/keystone',
1819 'process_name': 'keystone',
1820 'executable_name': os.path.join(bin_dir, 'keystone-all'),
1821 'config_files': ['/etc/keystone/keystone.conf'],
1822 'log_file': '/var/log/keystone/keystone.log',
1823 }
18241816
1825 # NOTE(coreycb): Needs systemd support1817 # Use systemd init units/scripts from ubuntu wily onward
1826 templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'1818 if lsb_release()['DISTRIB_RELEASE'] >= '15.10':
1827 templates_dir = os.path.join(charm_dir(), templates_dir)1819 keystone_context = {
1828 render('git.upstart', '/etc/init/keystone.conf', keystone_context,1820 'daemon_path': os.path.join(bin_dir, 'keystone-all'),
1829 perms=0o644, templates_dir=templates_dir)1821 }
1822 templates_dir = os.path.join(charm_dir(), 'templates/git')
1823 render('git/keystone.init.in.template',
1824 os.path.join(templates_dir, 'keystone.init.in'),
1825 keystone_context, perms=0o644)
1826 git_generate_systemd_init_files(templates_dir)
1827 else:
1828 keystone_context = {
1829 'service_description': 'Keystone API server',
1830 'service_name': 'Keystone',
1831 'user_name': 'keystone',
1832 'start_dir': '/var/lib/keystone',
1833 'process_name': 'keystone',
1834 'executable_name': os.path.join(bin_dir, 'keystone-all'),
1835 'config_files': ['/etc/keystone/keystone.conf'],
1836 'log_file': '/var/log/keystone/keystone.log',
1837 }
1838 templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
1839 templates_dir = os.path.join(charm_dir(), templates_dir)
1840 render('git.upstart', '/etc/init/keystone.conf', keystone_context,
1841 perms=0o644, templates_dir=templates_dir)
18301842
1831 service_restart('keystone')1843 service_restart('keystone')
18321844
18331845
=== added file 'templates/git/keystone.init.in.template'
--- templates/git/keystone.init.in.template 1970-01-01 00:00:00 +0000
+++ templates/git/keystone.init.in.template 2016-02-24 22:53:43 +0000
@@ -0,0 +1,19 @@
1#!/bin/sh
2### BEGIN INIT INFO
3# Provides: keystone
4# Required-Start: $network $local_fs $remote_fs
5# Required-Stop: $remote_fs
6# Should-Start: mysql postgresql slapd rabbitmq-server ntp
7# Should-Stop: mysql postgresql slapd rabbitmq-server ntp
8# Default-Start: 2 3 4 5
9# Default-Stop: 0 1 6
10# Short-Description: OpenStack cloud identity service
11# Description: This is the identity service used by OpenStack for
12# authentication (authN) and high-level authorization (authZ).
13### END INIT INFO
14
15DESC="OpenStack Identity service"
16PROJECT_NAME=keystone
17NAME=keystone
18DAEMON={{ daemon_path }}
19

Subscribers

People subscribed via source and target branches