Merge lp:~corey.bryant/charms/trusty/swift-storage/mitaka-ch-sync into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next

Proposed by Corey Bryant on 2016-01-13
Status: Merged
Merged at revision: 101
Proposed branch: lp:~corey.bryant/charms/trusty/swift-storage/mitaka-ch-sync
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
Diff against target: 141 lines (+55/-32)
2 files modified
charmhelpers/contrib/openstack/utils.py (+53/-30)
charmhelpers/fetch/giturl.py (+2/-2)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/swift-storage/mitaka-ch-sync
Reviewer Review Type Date Requested Status
OpenStack Charmers 2016-01-13 Pending
Review via email: mp+282494@code.launchpad.net
To post a comment you must log in.
Corey Bryant (corey.bryant) wrote :

I have some notes in the charm-helper mp that may be of interest: https://code.launchpad.net/~corey.bryant/charm-helpers/swift-mitaka/+merge/282337

charm_lint_check #17253 swift-storage-next for corey.bryant mp282494
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/17253/

charm_unit_test #16118 swift-storage-next for corey.bryant mp282494
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/16118/

charm_amulet_test #8760 swift-storage-next for corey.bryant mp282494
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8760/

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-01-08 02:38:26 +0000
3+++ charmhelpers/contrib/openstack/utils.py 2016-01-13 19:15:29 +0000
4@@ -103,29 +103,18 @@
5 ('2016.1', 'mitaka'),
6 ])
7
8-# The ugly duckling
9+# The ugly duckling - must list releases oldest to newest
10 SWIFT_CODENAMES = OrderedDict([
11- ('1.4.3', 'diablo'),
12- ('1.4.8', 'essex'),
13- ('1.7.4', 'folsom'),
14- ('1.8.0', 'grizzly'),
15- ('1.7.7', 'grizzly'),
16- ('1.7.6', 'grizzly'),
17- ('1.10.0', 'havana'),
18- ('1.9.1', 'havana'),
19- ('1.9.0', 'havana'),
20- ('1.13.1', 'icehouse'),
21- ('1.13.0', 'icehouse'),
22- ('1.12.0', 'icehouse'),
23- ('1.11.0', 'icehouse'),
24- ('2.0.0', 'juno'),
25- ('2.1.0', 'juno'),
26- ('2.2.0', 'juno'),
27- ('2.2.1', 'kilo'),
28- ('2.2.2', 'kilo'),
29- ('2.3.0', 'liberty'),
30- ('2.4.0', 'liberty'),
31- ('2.5.0', 'liberty'),
32+ ('diablo', ['1.4.3']),
33+ ('essex', ['1.4.8']),
34+ ('folsom', ['1.7.4']),
35+ ('grizzly', ['1.7.6', '1.7.7', '1.8.0']),
36+ ('havana', ['1.9.0', '1.9.1', '1.10.0']),
37+ ('icehouse', ['1.11.0', '1.12.0', '1.13.0', '1.13.1']),
38+ ('juno', ['2.0.0', '2.1.0', '2.2.0']),
39+ ('kilo', ['2.2.1', '2.2.2']),
40+ ('liberty', ['2.3.0', '2.4.0', '2.5.0']),
41+ ('mitaka', ['2.5.0']),
42 ])
43
44 # >= Liberty version->codename mapping
45@@ -227,6 +216,33 @@
46 error_out(e)
47
48
49+def get_os_version_codename_swift(codename):
50+ '''Determine OpenStack version number of swift from codename.'''
51+ for k, v in six.iteritems(SWIFT_CODENAMES):
52+ if k == codename:
53+ return v[-1]
54+ e = 'Could not derive swift version for '\
55+ 'codename: %s' % codename
56+ error_out(e)
57+
58+
59+def get_swift_codename(version):
60+ '''Determine OpenStack codename that corresponds to swift version.'''
61+ codenames = [k for k, v in six.iteritems(SWIFT_CODENAMES) if version in v]
62+ if len(codenames) > 1:
63+ # If more than one release codename contains this version we determine
64+ # the actual codename based on the highest available install source.
65+ for codename in reversed(codenames):
66+ releases = UBUNTU_OPENSTACK_RELEASE
67+ release = [k for k, v in six.iteritems(releases) if codename in v]
68+ ret = subprocess.check_output(['apt-cache', 'policy', 'swift'])
69+ if codename in ret or release[0] in ret:
70+ return codename
71+ elif len(codenames) == 1:
72+ return codenames[0]
73+ return None
74+
75+
76 def get_os_codename_package(package, fatal=True):
77 '''Derive OpenStack release codename from an installed package.'''
78 import apt_pkg as apt
79@@ -270,7 +286,7 @@
80 # < Liberty co-ordinated project versions
81 try:
82 if 'swift' in pkg.name:
83- return SWIFT_CODENAMES[vers]
84+ return get_swift_codename(vers)
85 else:
86 return OPENSTACK_CODENAMES[vers]
87 except KeyError:
88@@ -289,12 +305,14 @@
89
90 if 'swift' in pkg:
91 vers_map = SWIFT_CODENAMES
92+ for cname, version in six.iteritems(vers_map):
93+ if cname == codename:
94+ return version[-1]
95 else:
96 vers_map = OPENSTACK_CODENAMES
97-
98- for version, cname in six.iteritems(vers_map):
99- if cname == codename:
100- return version
101+ for version, cname in six.iteritems(vers_map):
102+ if cname == codename:
103+ return version
104 # e = "Could not determine OpenStack version for package: %s" % pkg
105 # error_out(e)
106
107@@ -460,11 +478,16 @@
108 cur_vers = get_os_version_package(package)
109 if "swift" in package:
110 codename = get_os_codename_install_source(src)
111- available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)
112+ avail_vers = get_os_version_codename_swift(codename)
113 else:
114- available_vers = get_os_version_install_source(src)
115+ avail_vers = get_os_version_install_source(src)
116 apt.init()
117- return apt.version_compare(available_vers, cur_vers) == 1
118+ if "swift" in package:
119+ major_cur_vers = cur_vers.split('.', 1)[0]
120+ major_avail_vers = avail_vers.split('.', 1)[0]
121+ major_diff = apt.version_compare(major_avail_vers, major_cur_vers)
122+ return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0)
123+ return apt.version_compare(avail_vers, cur_vers) == 1
124
125
126 def ensure_block_device(block_device):
127
128=== modified file 'charmhelpers/fetch/giturl.py'
129--- charmhelpers/fetch/giturl.py 2016-01-08 02:38:26 +0000
130+++ charmhelpers/fetch/giturl.py 2016-01-13 19:15:29 +0000
131@@ -49,8 +49,8 @@
132 cmd = ['git', '-C', dest, 'pull', source, branch]
133 else:
134 cmd = ['git', 'clone', source, dest, '--branch', branch]
135- if depth:
136- cmd.extend(['--depth', depth])
137+ if depth:
138+ cmd.extend(['--depth', depth])
139 check_call(cmd)
140
141 def install(self, source, branch="master", dest=None, depth=None):

Subscribers

People subscribed via source and target branches