Merge lp:~gandelman-a/charms/precise/keystone/version_fixes into lp:~openstack-charmers/charms/precise/keystone/ha-support

Proposed by Adam Gandelman on 2013-03-05
Status: Merged
Merged at revision: 56
Proposed branch: lp:~gandelman-a/charms/precise/keystone/version_fixes
Merge into: lp:~openstack-charmers/charms/precise/keystone/ha-support
Diff against target: 84 lines (+12/-29)
1 file modified
hooks/lib/openstack_common.py (+12/-29)
To merge this branch: bzr merge lp:~gandelman-a/charms/precise/keystone/version_fixes
Reviewer Review Type Date Requested Status
James Page Approve on 2013-03-08
Adam Gandelman (community) Resubmit on 2013-03-07
Review via email: mp+151670@code.launchpad.net

Description of the change

Various fixes to version handling, also adds havana.

Once approved here, I will merge changes into lp:~openstack-charmers/openstack-charm-helpers/ha-helpers and sync across all current branches that pull from there.

To post a comment you must log in.
James Page (james-page) wrote :

Adam

The apt package has a upstream_version helper that might be useful in this case - might be a bit neater than splitting the epoch off manually.

56. By Adam Gandelman on 2013-03-07

Use apt_pkg's UpstreamVersion() instead of parsing out epochs manually.

Adam Gandelman (gandelman-a) wrote :

Ah! Good call, thanks. Updated.

review: Resubmit
James Page (james-page) wrote :

Tested fine - merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/lib/openstack_common.py'
2--- hooks/lib/openstack_common.py 2013-03-06 21:50:30 +0000
3+++ hooks/lib/openstack_common.py 2013-03-07 16:58:18 +0000
4@@ -2,6 +2,7 @@
5
6 # Common python helper functions used for OpenStack charms.
7
8+import apt_pkg as apt
9 import subprocess
10 import os
11
12@@ -12,7 +13,7 @@
13 'oneiric': 'diablo',
14 'precise': 'essex',
15 'quantal': 'folsom',
16- 'raring' : 'grizzly'
17+ 'raring' : 'grizzly',
18 }
19
20
21@@ -20,7 +21,8 @@
22 '2011.2': 'diablo',
23 '2012.1': 'essex',
24 '2012.2': 'folsom',
25- '2013.1': 'grizzly'
26+ '2013.1': 'grizzly',
27+ '2013.2': 'havana',
28 }
29
30 # The ugly duckling
31@@ -29,7 +31,7 @@
32 '1.4.8': 'essex',
33 '1.7.4': 'folsom',
34 '1.7.6': 'grizzly',
35- '1.7.7': 'grizzly'
36+ '1.7.7': 'grizzly',
37 }
38
39 def juju_log(msg):
40@@ -97,37 +99,18 @@
41
42 def get_os_codename_package(pkg):
43 '''Derive OpenStack release codename from an installed package.'''
44- cmd = ['dpkg', '-l', pkg]
45-
46+ apt.init()
47+ cache = apt.Cache()
48 try:
49- output = subprocess.check_output(cmd)
50- except subprocess.CalledProcessError:
51- e = 'Could not derive OpenStack version from package that is not '\
52- 'installed; %s' % pkg
53- error_out(e)
54-
55- def _clean(line):
56- line = line.split(' ')
57- clean = []
58- for c in line:
59- if c != '':
60- clean.append(c)
61- return clean
62-
63- vers = None
64- for l in output.split('\n'):
65- if l.startswith('ii'):
66- l = _clean(l)
67- if l[1] == pkg:
68- vers = l[2]
69-
70- if not vers:
71+ pkg = cache[pkg]
72+ except:
73 e = 'Could not determine version of installed package: %s' % pkg
74 error_out(e)
75
76- vers = vers[:6]
77+ vers = apt.UpstreamVersion(pkg.current_ver.ver_str)
78+
79 try:
80- if 'swift' in pkg:
81+ if 'swift' in pkg.name:
82 vers = vers[:5]
83 return swift_codenames[vers]
84 else:

Subscribers

People subscribed via source and target branches