Merge lp:~gnuoy/charms/trusty/ceph/stable-charmhelper-sync into lp:~openstack-charmers-archive/charms/trusty/ceph/trunk

Proposed by Liam Young
Status: Merged
Merged at revision: 76
Proposed branch: lp:~gnuoy/charms/trusty/ceph/stable-charmhelper-sync
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph/trunk
Diff against target: 212 lines (+35/-37)
8 files modified
.bzrignore (+1/-0)
Makefile (+8/-2)
hooks/ceph.py (+4/-18)
hooks/charmhelpers/contrib/storage/linux/utils.py (+4/-0)
hooks/charmhelpers/core/host.py (+2/-6)
hooks/charmhelpers/fetch/__init__.py (+11/-7)
hooks/hooks.py (+4/-3)
templates/ceph.conf (+1/-1)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/ceph/stable-charmhelper-sync
Reviewer Review Type Date Requested Status
David Britton (community) Approve
Chris Glass (community) Approve
Review via email: mp+236089@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Chris Glass (tribaal) wrote :

This can be tested from cs:~tribaal/charms/trusty/ceph-0

Revision history for this message
Chris Glass (tribaal) wrote :

This looks good! +1 provided Fernando adds a comment when his test run succeeds :)

review: Approve
Revision history for this message
David Britton (dpb) wrote :

I tested this on MAAS, all is well.

review: Approve
Revision history for this message
Fernando Correa Neto (fcorrea) wrote :

Test run succeeded.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.bzrignore'
--- .bzrignore 1970-01-01 00:00:00 +0000
+++ .bzrignore 2014-09-26 09:09:03 +0000
@@ -0,0 +1,1 @@
1bin
02
=== modified file 'Makefile'
--- Makefile 2014-05-21 10:09:21 +0000
+++ Makefile 2014-09-26 09:09:03 +0000
@@ -1,11 +1,17 @@
1#!/usr/bin/make1#!/usr/bin/make
2PYTHON := /usr/bin/env python
23
3lint:4lint:
4 @flake8 --exclude hooks/charmhelpers hooks5 @flake8 --exclude hooks/charmhelpers hooks
5 @charm proof6 @charm proof
67
7sync:8bin/charm_helpers_sync.py:
8 @charm-helper-sync -c charm-helpers-sync.yaml9 @mkdir -p bin
10 @bzr cat lp:charm-helpers/tools/charm_helpers_sync/charm_helpers_sync.py \
11 > bin/charm_helpers_sync.py
12
13sync: bin/charm_helpers_sync.py
14 $(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-sync.yaml
915
10publish: lint16publish: lint
11 bzr push lp:charms/ceph17 bzr push lp:charms/ceph
1218
=== modified file 'hooks/ceph.py'
--- hooks/ceph.py 2014-05-19 12:15:38 +0000
+++ hooks/ceph.py 2014-09-26 09:09:03 +0000
@@ -11,10 +11,10 @@
11import subprocess11import subprocess
12import time12import time
13import os13import os
14import apt_pkg as apt
15from charmhelpers.core.host import (14from charmhelpers.core.host import (
16 mkdir,15 mkdir,
17 service_restart,16 service_restart,
17 cmp_pkgrevno,
18)18)
19from charmhelpers.core.hookenv import (19from charmhelpers.core.hookenv import (
20 log,20 log,
@@ -126,7 +126,7 @@
126def start_osds(devices):126def start_osds(devices):
127 # Scan for ceph block devices127 # Scan for ceph block devices
128 rescan_osd_devices()128 rescan_osd_devices()
129 if get_ceph_version() >= "0.56.6":129 if cmp_pkgrevno('ceph', "0.56.6") >= 0:
130 # Use ceph-disk-activate for directory based OSD's130 # Use ceph-disk-activate for directory based OSD's
131 for dev_or_path in devices:131 for dev_or_path in devices:
132 if os.path.exists(dev_or_path) and os.path.isdir(dev_or_path):132 if os.path.exists(dev_or_path) and os.path.isdir(dev_or_path):
@@ -309,20 +309,6 @@
309 os.unlink(keyring)309 os.unlink(keyring)
310310
311311
312def get_ceph_version():
313 apt.init()
314 cache = apt.Cache()
315 pkg = cache['ceph']
316 if pkg.current_ver:
317 return apt.upstream_version(pkg.current_ver.ver_str)
318 else:
319 return None
320
321
322def version_compare(a, b):
323 return apt.version_compare(a, b)
324
325
326def update_monfs():312def update_monfs():
327 hostname = get_unit_hostname()313 hostname = get_unit_hostname()
328 monfs = '/var/lib/ceph/mon/ceph-{}'.format(hostname)314 monfs = '/var/lib/ceph/mon/ceph-{}'.format(hostname)
@@ -360,7 +346,7 @@
360346
361 cmd = ['ceph-disk-prepare']347 cmd = ['ceph-disk-prepare']
362 # Later versions of ceph support more options348 # Later versions of ceph support more options
363 if get_ceph_version() >= "0.48.3":349 if cmp_pkgrevno('ceph', "0.48.3") >= 0:
364 if osd_format:350 if osd_format:
365 cmd.append('--fs-type')351 cmd.append('--fs-type')
366 cmd.append(osd_format)352 cmd.append(osd_format)
@@ -383,7 +369,7 @@
383 log('Path {} is already configured as an OSD - bailing'.format(path))369 log('Path {} is already configured as an OSD - bailing'.format(path))
384 return370 return
385371
386 if get_ceph_version() < "0.56.6":372 if cmp_pkgrevno('ceph', "0.56.6") < 0:
387 log('Unable to use directories for OSDs with ceph < 0.56.6',373 log('Unable to use directories for OSDs with ceph < 0.56.6',
388 level=ERROR)374 level=ERROR)
389 raise375 raise
390376
=== modified file 'hooks/charmhelpers/contrib/storage/linux/utils.py'
--- hooks/charmhelpers/contrib/storage/linux/utils.py 2014-05-19 11:38:45 +0000
+++ hooks/charmhelpers/contrib/storage/linux/utils.py 2014-09-26 09:09:03 +0000
@@ -37,6 +37,7 @@
37 check_call(['dd', 'if=/dev/zero', 'of=%s' % (block_device),37 check_call(['dd', 'if=/dev/zero', 'of=%s' % (block_device),
38 'bs=512', 'count=100', 'seek=%s' % (gpt_end)])38 'bs=512', 'count=100', 'seek=%s' % (gpt_end)])
3939
40
40def is_device_mounted(device):41def is_device_mounted(device):
41 '''Given a device path, return True if that device is mounted, and False42 '''Given a device path, return True if that device is mounted, and False
42 if it isn't.43 if it isn't.
@@ -45,5 +46,8 @@
45 :returns: boolean: True if the path represents a mounted device, False if46 :returns: boolean: True if the path represents a mounted device, False if
46 it doesn't.47 it doesn't.
47 '''48 '''
49 is_partition = bool(re.search(r".*[0-9]+\b", device))
48 out = check_output(['mount'])50 out = check_output(['mount'])
51 if is_partition:
52 return bool(re.search(device + r"\b", out))
49 return bool(re.search(device + r"[0-9]+\b", out))53 return bool(re.search(device + r"[0-9]+\b", out))
5054
=== modified file 'hooks/charmhelpers/core/host.py'
--- hooks/charmhelpers/core/host.py 2014-07-24 09:59:35 +0000
+++ hooks/charmhelpers/core/host.py 2014-09-26 09:09:03 +0000
@@ -318,12 +318,8 @@
318 0 => Installed revno is the same as supplied arg318 0 => Installed revno is the same as supplied arg
319 -1 => Installed revno is less than supplied arg319 -1 => Installed revno is less than supplied arg
320 '''320 '''
321 from charmhelpers.fetch import apt_cache
321 if not pkgcache:322 if not pkgcache:
322 apt_pkg.init()323 pkgcache = apt_cache()
323 # Force Apt to build its cache in memory. That way we avoid race
324 # conditions with other applications building the cache in the same
325 # place.
326 apt_pkg.config.set("Dir::Cache::pkgcache", "")
327 pkgcache = apt_pkg.Cache()
328 pkg = pkgcache[package]324 pkg = pkgcache[package]
329 return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)325 return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)
330326
=== modified file 'hooks/charmhelpers/fetch/__init__.py'
--- hooks/charmhelpers/fetch/__init__.py 2014-05-19 11:38:45 +0000
+++ hooks/charmhelpers/fetch/__init__.py 2014-09-26 09:09:03 +0000
@@ -108,13 +108,8 @@
108108
109def filter_installed_packages(packages):109def filter_installed_packages(packages):
110 """Returns a list of packages that require installation"""110 """Returns a list of packages that require installation"""
111 apt_pkg.init()111
112112 cache = apt_cache()
113 # Tell apt to build an in-memory cache to prevent race conditions (if
114 # another process is already building the cache).
115 apt_pkg.config.set("Dir::Cache::pkgcache", "")
116
117 cache = apt_pkg.Cache()
118 _pkgs = []113 _pkgs = []
119 for package in packages:114 for package in packages:
120 try:115 try:
@@ -127,6 +122,15 @@
127 return _pkgs122 return _pkgs
128123
129124
125def apt_cache(in_memory=True):
126 """Build and return an apt cache"""
127 apt_pkg.init()
128 if in_memory:
129 apt_pkg.config.set("Dir::Cache::pkgcache", "")
130 apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
131 return apt_pkg.Cache()
132
133
130def apt_install(packages, options=None, fatal=False):134def apt_install(packages, options=None, fatal=False):
131 """Install one or more packages"""135 """Install one or more packages"""
132 if options is None:136 if options is None:
133137
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2014-03-25 18:44:22 +0000
+++ hooks/hooks.py 2014-09-26 09:09:03 +0000
@@ -29,7 +29,8 @@
29from charmhelpers.core.host import (29from charmhelpers.core.host import (
30 service_restart,30 service_restart,
31 umount,31 umount,
32 mkdir32 mkdir,
33 cmp_pkgrevno
33)34)
34from charmhelpers.fetch import (35from charmhelpers.fetch import (
35 apt_install,36 apt_install,
@@ -50,7 +51,7 @@
5051
51def install_upstart_scripts():52def install_upstart_scripts():
52 # Only install upstart configurations for older versions53 # Only install upstart configurations for older versions
53 if ceph.get_ceph_version() < "0.55.1":54 if cmp_pkgrevno('ceph', "0.55.1") < 0:
54 for x in glob.glob('files/upstart/*.conf'):55 for x in glob.glob('files/upstart/*.conf'):
55 shutil.copy(x, '/etc/init/')56 shutil.copy(x, '/etc/init/')
5657
@@ -71,7 +72,7 @@
71 'auth_supported': config('auth-supported'),72 'auth_supported': config('auth-supported'),
72 'mon_hosts': ' '.join(get_mon_hosts()),73 'mon_hosts': ' '.join(get_mon_hosts()),
73 'fsid': config('fsid'),74 'fsid': config('fsid'),
74 'version': ceph.get_ceph_version(),75 'old_auth': cmp_pkgrevno('ceph', "0.51") < 0,
75 'osd_journal_size': config('osd-journal-size'),76 'osd_journal_size': config('osd-journal-size'),
76 'use_syslog': str(config('use-syslog')).lower()77 'use_syslog': str(config('use-syslog')).lower()
77 }78 }
7879
=== modified file 'templates/ceph.conf'
--- templates/ceph.conf 2014-03-25 18:44:22 +0000
+++ templates/ceph.conf 2014-09-26 09:09:03 +0000
@@ -1,5 +1,5 @@
1[global]1[global]
2{% if version < "0.51" %}2{% if old_auth %}
3 auth supported = {{ auth_supported }}3 auth supported = {{ auth_supported }}
4{% else %}4{% else %}
5 auth cluster required = {{ auth_supported }}5 auth cluster required = {{ auth_supported }}

Subscribers

People subscribed via source and target branches