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

Proposed by Adam Gandelman
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
Adam Gandelman (community) Needs Resubmitting
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.
Revision history for this message
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

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

Revision history for this message
Adam Gandelman (gandelman-a) wrote :

Ah! Good call, thanks. Updated.

review: Needs Resubmitting
Revision history for this message
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
=== modified file 'hooks/lib/openstack_common.py'
--- hooks/lib/openstack_common.py 2013-03-06 21:50:30 +0000
+++ hooks/lib/openstack_common.py 2013-03-07 16:58:18 +0000
@@ -2,6 +2,7 @@
22
3# Common python helper functions used for OpenStack charms.3# Common python helper functions used for OpenStack charms.
44
5import apt_pkg as apt
5import subprocess6import subprocess
6import os7import os
78
@@ -12,7 +13,7 @@
12 'oneiric': 'diablo',13 'oneiric': 'diablo',
13 'precise': 'essex',14 'precise': 'essex',
14 'quantal': 'folsom',15 'quantal': 'folsom',
15 'raring' : 'grizzly'16 'raring' : 'grizzly',
16}17}
1718
1819
@@ -20,7 +21,8 @@
20 '2011.2': 'diablo',21 '2011.2': 'diablo',
21 '2012.1': 'essex',22 '2012.1': 'essex',
22 '2012.2': 'folsom',23 '2012.2': 'folsom',
23 '2013.1': 'grizzly'24 '2013.1': 'grizzly',
25 '2013.2': 'havana',
24}26}
2527
26# The ugly duckling28# The ugly duckling
@@ -29,7 +31,7 @@
29 '1.4.8': 'essex',31 '1.4.8': 'essex',
30 '1.7.4': 'folsom',32 '1.7.4': 'folsom',
31 '1.7.6': 'grizzly',33 '1.7.6': 'grizzly',
32 '1.7.7': 'grizzly'34 '1.7.7': 'grizzly',
33}35}
3436
35def juju_log(msg):37def juju_log(msg):
@@ -97,37 +99,18 @@
9799
98def get_os_codename_package(pkg):100def get_os_codename_package(pkg):
99 '''Derive OpenStack release codename from an installed package.'''101 '''Derive OpenStack release codename from an installed package.'''
100 cmd = ['dpkg', '-l', pkg]102 apt.init()
101103 cache = apt.Cache()
102 try:104 try:
103 output = subprocess.check_output(cmd)105 pkg = cache[pkg]
104 except subprocess.CalledProcessError:106 except:
105 e = 'Could not derive OpenStack version from package that is not '\
106 'installed; %s' % pkg
107 error_out(e)
108
109 def _clean(line):
110 line = line.split(' ')
111 clean = []
112 for c in line:
113 if c != '':
114 clean.append(c)
115 return clean
116
117 vers = None
118 for l in output.split('\n'):
119 if l.startswith('ii'):
120 l = _clean(l)
121 if l[1] == pkg:
122 vers = l[2]
123
124 if not vers:
125 e = 'Could not determine version of installed package: %s' % pkg107 e = 'Could not determine version of installed package: %s' % pkg
126 error_out(e)108 error_out(e)
127109
128 vers = vers[:6]110 vers = apt.UpstreamVersion(pkg.current_ver.ver_str)
111
129 try:112 try:
130 if 'swift' in pkg:113 if 'swift' in pkg.name:
131 vers = vers[:5]114 vers = vers[:5]
132 return swift_codenames[vers]115 return swift_codenames[vers]
133 else:116 else:

Subscribers

People subscribed via source and target branches