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

Proposed by Liam Young
Status: Merged
Merged at revision: 23
Proposed branch: lp:~gnuoy/charms/trusty/ceph-osd/stable-charmhelper-sync
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph-osd/trunk
Diff against target: 213 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-osd/stable-charmhelper-sync
Reviewer Review Type Date Requested Status
David Britton (community) Approve
Chris Glass (community) Approve
Review via email: mp+236090@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Chris Glass (tribaal) wrote :

Looks good! +1 (would merge)

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

Tested on MAAS, installed great, +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-10-08 14:07:16 +0000
3+++ .bzrignore 2014-09-26 09:09:07 +0000
4@@ -1,1 +1,2 @@
5 .project
6+bin
7
8=== modified file 'Makefile'
9--- Makefile 2014-05-21 11:55:52 +0000
10+++ Makefile 2014-09-26 09:09:07 +0000
11@@ -1,11 +1,17 @@
12 #!/usr/bin/make
13+PYTHON := /usr/bin/env python
14
15 lint:
16 @flake8 --exclude hooks/charmhelpers hooks
17 @charm proof || true
18
19-sync:
20- @charm-helper-sync -c charm-helpers-sync.yaml
21+bin/charm_helpers_sync.py:
22+ @mkdir -p bin
23+ @bzr cat lp:charm-helpers/tools/charm_helpers_sync/charm_helpers_sync.py \
24+ > bin/charm_helpers_sync.py
25+
26+sync: bin/charm_helpers_sync.py
27+ $(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-sync.yaml
28
29 publish: lint
30 bzr push lp:charms/ceph-osd
31
32=== modified file 'hooks/ceph.py'
33--- hooks/ceph.py 2014-05-19 12:16:15 +0000
34+++ hooks/ceph.py 2014-09-26 09:09:07 +0000
35@@ -11,10 +11,10 @@
36 import subprocess
37 import time
38 import os
39-import apt_pkg as apt
40 from charmhelpers.core.host import (
41 mkdir,
42 service_restart,
43+ cmp_pkgrevno
44 )
45 from charmhelpers.core.hookenv import (
46 log,
47@@ -126,7 +126,7 @@
48 def start_osds(devices):
49 # Scan for ceph block devices
50 rescan_osd_devices()
51- if get_ceph_version() >= "0.56.6":
52+ if cmp_pkgrevno('ceph', '0.56.6') >= 0:
53 # Use ceph-disk-activate for directory based OSD's
54 for dev_or_path in devices:
55 if os.path.exists(dev_or_path) and os.path.isdir(dev_or_path):
56@@ -296,20 +296,6 @@
57 os.unlink(keyring)
58
59
60-def get_ceph_version():
61- apt.init()
62- cache = apt.Cache()
63- pkg = cache['ceph']
64- if pkg.current_ver:
65- return apt.upstream_version(pkg.current_ver.ver_str)
66- else:
67- return None
68-
69-
70-def version_compare(a, b):
71- return apt.version_compare(a, b)
72-
73-
74 def update_monfs():
75 hostname = get_unit_hostname()
76 monfs = '/var/lib/ceph/mon/ceph-{}'.format(hostname)
77@@ -347,7 +333,7 @@
78
79 cmd = ['ceph-disk-prepare']
80 # Later versions of ceph support more options
81- if get_ceph_version() >= "0.48.3":
82+ if cmp_pkgrevno('ceph', '0.48.3') >= 0:
83 if osd_format:
84 cmd.append('--fs-type')
85 cmd.append(osd_format)
86@@ -370,7 +356,7 @@
87 log('Path {} is already configured as an OSD - bailing'.format(path))
88 return
89
90- if get_ceph_version() < "0.56.6":
91+ if cmp_pkgrevno('ceph', '0.56.6.') < 0:
92 log('Unable to use directories for OSDs with ceph < 0.56.6',
93 level=ERROR)
94 raise
95
96=== modified file 'hooks/charmhelpers/contrib/storage/linux/utils.py'
97--- hooks/charmhelpers/contrib/storage/linux/utils.py 2014-05-19 11:39:52 +0000
98+++ hooks/charmhelpers/contrib/storage/linux/utils.py 2014-09-26 09:09:07 +0000
99@@ -37,6 +37,7 @@
100 check_call(['dd', 'if=/dev/zero', 'of=%s' % (block_device),
101 'bs=512', 'count=100', 'seek=%s' % (gpt_end)])
102
103+
104 def is_device_mounted(device):
105 '''Given a device path, return True if that device is mounted, and False
106 if it isn't.
107@@ -45,5 +46,8 @@
108 :returns: boolean: True if the path represents a mounted device, False if
109 it doesn't.
110 '''
111+ is_partition = bool(re.search(r".*[0-9]+\b", device))
112 out = check_output(['mount'])
113+ if is_partition:
114+ return bool(re.search(device + r"\b", out))
115 return bool(re.search(device + r"[0-9]+\b", out))
116
117=== modified file 'hooks/charmhelpers/core/host.py'
118--- hooks/charmhelpers/core/host.py 2014-07-24 10:00:02 +0000
119+++ hooks/charmhelpers/core/host.py 2014-09-26 09:09:07 +0000
120@@ -318,12 +318,8 @@
121 0 => Installed revno is the same as supplied arg
122 -1 => Installed revno is less than supplied arg
123 '''
124+ from charmhelpers.fetch import apt_cache
125 if not pkgcache:
126- apt_pkg.init()
127- # Force Apt to build its cache in memory. That way we avoid race
128- # conditions with other applications building the cache in the same
129- # place.
130- apt_pkg.config.set("Dir::Cache::pkgcache", "")
131- pkgcache = apt_pkg.Cache()
132+ pkgcache = apt_cache()
133 pkg = pkgcache[package]
134 return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)
135
136=== modified file 'hooks/charmhelpers/fetch/__init__.py'
137--- hooks/charmhelpers/fetch/__init__.py 2014-05-19 11:39:52 +0000
138+++ hooks/charmhelpers/fetch/__init__.py 2014-09-26 09:09:07 +0000
139@@ -108,13 +108,8 @@
140
141 def filter_installed_packages(packages):
142 """Returns a list of packages that require installation"""
143- apt_pkg.init()
144-
145- # Tell apt to build an in-memory cache to prevent race conditions (if
146- # another process is already building the cache).
147- apt_pkg.config.set("Dir::Cache::pkgcache", "")
148-
149- cache = apt_pkg.Cache()
150+
151+ cache = apt_cache()
152 _pkgs = []
153 for package in packages:
154 try:
155@@ -127,6 +122,15 @@
156 return _pkgs
157
158
159+def apt_cache(in_memory=True):
160+ """Build and return an apt cache"""
161+ apt_pkg.init()
162+ if in_memory:
163+ apt_pkg.config.set("Dir::Cache::pkgcache", "")
164+ apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
165+ return apt_pkg.Cache()
166+
167+
168 def apt_install(packages, options=None, fatal=False):
169 """Install one or more packages"""
170 if options is None:
171
172=== modified file 'hooks/hooks.py'
173--- hooks/hooks.py 2014-03-25 18:44:23 +0000
174+++ hooks/hooks.py 2014-09-26 09:09:07 +0000
175@@ -26,7 +26,8 @@
176 )
177 from charmhelpers.core.host import (
178 umount,
179- mkdir
180+ mkdir,
181+ cmp_pkgrevno
182 )
183 from charmhelpers.fetch import (
184 add_source,
185@@ -47,7 +48,7 @@
186
187 def install_upstart_scripts():
188 # Only install upstart configurations for older versions
189- if ceph.get_ceph_version() < "0.55.1":
190+ if cmp_pkgrevno('ceph', "0.55.1") < 0:
191 for x in glob.glob('files/upstart/*.conf'):
192 shutil.copy(x, '/etc/init/')
193
194@@ -70,7 +71,7 @@
195 'auth_supported': get_auth(),
196 'mon_hosts': ' '.join(mon_hosts),
197 'fsid': get_fsid(),
198- 'version': ceph.get_ceph_version(),
199+ 'old_auth': cmp_pkgrevno('ceph', "0.51") < 0,
200 'osd_journal_size': config('osd-journal-size'),
201 'use_syslog': str(config('use-syslog')).lower()
202 }
203
204=== modified file 'templates/ceph.conf'
205--- templates/ceph.conf 2014-03-25 18:44:23 +0000
206+++ templates/ceph.conf 2014-09-26 09:09:07 +0000
207@@ -1,5 +1,5 @@
208 [global]
209-{% if version < "0.51" %}
210+{% if old_auth %}
211 auth supported = {{ auth_supported }}
212 {% else %}
213 auth cluster required = {{ auth_supported }}

Subscribers

People subscribed via source and target branches