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

Subscribers

People subscribed via source and target branches