Merge lp:~adam-collard/charm-helpers/openstack-upgrade-available-swift into lp:charm-helpers

Proposed by Adam Collard
Status: Merged
Merged at revision: 436
Proposed branch: lp:~adam-collard/charm-helpers/openstack-upgrade-available-swift
Merge into: lp:charm-helpers
Diff against target: 58 lines (+13/-5)
2 files modified
charmhelpers/contrib/openstack/utils.py (+7/-5)
tests/contrib/openstack/test_openstack_utils.py (+6/-0)
To merge this branch: bzr merge lp:~adam-collard/charm-helpers/openstack-upgrade-available-swift
Reviewer Review Type Date Requested Status
Chris Glass (community) Approve
Review via email: mp+269481@code.launchpad.net

Description of the change

Special case swift packages for version comparison purposes in openstack_upgrade_available.

Without this change, the swift charms will think that OpenStack upgrades are constantly available because the code ended up comparing numbers from two different version schemes and it turns out that '2014.1' > '1.13.1'

To post a comment you must log in.
Revision history for this message
Chris Glass (tribaal) wrote :

Thanks for your branch!

Looks good, thanks for knocking this one out! +1

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 2015-08-12 09:54:10 +0000
3+++ charmhelpers/contrib/openstack/utils.py 2015-08-28 09:23:27 +0000
4@@ -1,5 +1,3 @@
5-#!/usr/bin/python
6-
7 # Copyright 2014-2015 Canonical Limited.
8 #
9 # This file is part of charm-helpers.
10@@ -195,9 +193,9 @@
11 error_out(e)
12
13
14-def get_os_version_codename(codename):
15+def get_os_version_codename(codename, version_map=OPENSTACK_CODENAMES):
16 '''Determine OpenStack version number from codename.'''
17- for k, v in six.iteritems(OPENSTACK_CODENAMES):
18+ for k, v in six.iteritems(version_map):
19 if v == codename:
20 return k
21 e = 'Could not derive OpenStack version for '\
22@@ -429,7 +427,11 @@
23 import apt_pkg as apt
24 src = config('openstack-origin')
25 cur_vers = get_os_version_package(package)
26- available_vers = get_os_version_install_source(src)
27+ if "swift" in package:
28+ codename = get_os_codename_install_source(src)
29+ available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)
30+ else:
31+ available_vers = get_os_version_install_source(src)
32 apt.init()
33 return apt.version_compare(available_vers, cur_vers) == 1
34
35
36=== modified file 'tests/contrib/openstack/test_openstack_utils.py'
37--- tests/contrib/openstack/test_openstack_utils.py 2015-08-12 09:54:10 +0000
38+++ tests/contrib/openstack/test_openstack_utils.py 2015-08-28 09:23:27 +0000
39@@ -514,6 +514,8 @@
40 # milestone to major release detection
41 vers_pkg.return_value = '2013.2~b1'
42 self.assertTrue(openstack.openstack_upgrade_available('nova-common'))
43+ vers_pkg.return_value = '1.9.0'
44+ self.assertTrue(openstack.openstack_upgrade_available('swift-proxy'))
45
46 @patch.object(openstack, 'lsb_release')
47 @patch.object(openstack, 'get_os_version_package')
48@@ -527,6 +529,10 @@
49 # milestone to majro release detection
50 vers_pkg.return_value = '2013.1~b1'
51 self.assertFalse(openstack.openstack_upgrade_available('nova-common'))
52+ # ugly duckling testing
53+ config.return_value = 'cloud:precise-havana'
54+ vers_pkg.return_value = '1.10.0'
55+ self.assertFalse(openstack.openstack_upgrade_available('swift-proxy'))
56
57 @patch.object(openstack, 'is_block_device')
58 @patch.object(openstack, 'error_out')

Subscribers

People subscribed via source and target branches