Merge lp:~james-page/charm-helpers/swift-dev-support into lp:charm-helpers

Proposed by James Page on 2016-05-27
Status: Merged
Merged at revision: 578
Proposed branch: lp:~james-page/charm-helpers/swift-dev-support
Merge into: lp:charm-helpers
Diff against target: 44 lines (+16/-0)
2 files modified
charmhelpers/contrib/openstack/utils.py (+11/-0)
tests/contrib/openstack/test_openstack_utils.py (+5/-0)
To merge this branch: bzr merge lp:~james-page/charm-helpers/swift-dev-support
Reviewer Review Type Date Requested Status
Liam Young 2016-05-27 Approve on 2016-05-27
Review via email: mp+295918@code.launchpad.net

Description of the Change

Add support for fallback matching on major.minor version for Swift

This allows trunk package builds to be used with the charms.

To post a comment you must log in.
Liam Young (gnuoy) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/utils.py'
2--- charmhelpers/contrib/openstack/utils.py 2016-05-25 13:04:34 +0000
3+++ charmhelpers/contrib/openstack/utils.py 2016-05-27 09:07:16 +0000
4@@ -279,6 +279,7 @@
5 def get_swift_codename(version):
6 '''Determine OpenStack codename that corresponds to swift version.'''
7 codenames = [k for k, v in six.iteritems(SWIFT_CODENAMES) if version in v]
8+
9 if len(codenames) > 1:
10 # If more than one release codename contains this version we determine
11 # the actual codename based on the highest available install source.
12@@ -290,6 +291,16 @@
13 return codename
14 elif len(codenames) == 1:
15 return codenames[0]
16+
17+ # NOTE: fallback - attempt to match with just major.minor version
18+ match = re.match('^(\d+)\.(\d+)', version)
19+ if match:
20+ major_minor_version = match.group(0)
21+ for codename, versions in six.iteritems(SWIFT_CODENAMES):
22+ for release_version in versions:
23+ if release_version.startswith(major_minor_version):
24+ return codename
25+
26 return None
27
28
29
30=== modified file 'tests/contrib/openstack/test_openstack_utils.py'
31--- tests/contrib/openstack/test_openstack_utils.py 2016-03-08 12:28:33 +0000
32+++ tests/contrib/openstack/test_openstack_utils.py 2016-05-27 09:07:16 +0000
33@@ -71,6 +71,11 @@
34 'os_release': 'havana',
35 'os_version': '1.10.0'
36 },
37+ 'swift-mitaka-dev': {
38+ 'pkg_vers': '2.7.1.dev8.201605111703.trusty-0ubuntu1',
39+ 'os_release': 'mitaka',
40+ 'os_version': '2.7.0'
41+ },
42 # a package thats available in the cache but is not installed
43 'cinder-common': {
44 'os_release': 'havana',

Subscribers

People subscribed via source and target branches