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
=== modified file 'charmhelpers/contrib/openstack/utils.py'
--- charmhelpers/contrib/openstack/utils.py 2016-01-08 02:38:26 +0000
+++ charmhelpers/contrib/openstack/utils.py 2016-01-13 19:15:29 +0000
@@ -103,29 +103,18 @@
103 ('2016.1', 'mitaka'),103 ('2016.1', 'mitaka'),
104])104])
105105
106# The ugly duckling106# The ugly duckling - must list releases oldest to newest
107SWIFT_CODENAMES = OrderedDict([107SWIFT_CODENAMES = OrderedDict([
108 ('1.4.3', 'diablo'),108 ('diablo', ['1.4.3']),
109 ('1.4.8', 'essex'),109 ('essex', ['1.4.8']),
110 ('1.7.4', 'folsom'),110 ('folsom', ['1.7.4']),
111 ('1.8.0', 'grizzly'),111 ('grizzly', ['1.7.6', '1.7.7', '1.8.0']),
112 ('1.7.7', 'grizzly'),112 ('havana', ['1.9.0', '1.9.1', '1.10.0']),
113 ('1.7.6', 'grizzly'),113 ('icehouse', ['1.11.0', '1.12.0', '1.13.0', '1.13.1']),
114 ('1.10.0', 'havana'),114 ('juno', ['2.0.0', '2.1.0', '2.2.0']),
115 ('1.9.1', 'havana'),115 ('kilo', ['2.2.1', '2.2.2']),
116 ('1.9.0', 'havana'),116 ('liberty', ['2.3.0', '2.4.0', '2.5.0']),
117 ('1.13.1', 'icehouse'),117 ('mitaka', ['2.5.0']),
118 ('1.13.0', 'icehouse'),
119 ('1.12.0', 'icehouse'),
120 ('1.11.0', 'icehouse'),
121 ('2.0.0', 'juno'),
122 ('2.1.0', 'juno'),
123 ('2.2.0', 'juno'),
124 ('2.2.1', 'kilo'),
125 ('2.2.2', 'kilo'),
126 ('2.3.0', 'liberty'),
127 ('2.4.0', 'liberty'),
128 ('2.5.0', 'liberty'),
129])118])
130119
131# >= Liberty version->codename mapping120# >= Liberty version->codename mapping
@@ -227,6 +216,33 @@
227 error_out(e)216 error_out(e)
228217
229218
219def get_os_version_codename_swift(codename):
220 '''Determine OpenStack version number of swift from codename.'''
221 for k, v in six.iteritems(SWIFT_CODENAMES):
222 if k == codename:
223 return v[-1]
224 e = 'Could not derive swift version for '\
225 'codename: %s' % codename
226 error_out(e)
227
228
229def get_swift_codename(version):
230 '''Determine OpenStack codename that corresponds to swift version.'''
231 codenames = [k for k, v in six.iteritems(SWIFT_CODENAMES) if version in v]
232 if len(codenames) > 1:
233 # If more than one release codename contains this version we determine
234 # the actual codename based on the highest available install source.
235 for codename in reversed(codenames):
236 releases = UBUNTU_OPENSTACK_RELEASE
237 release = [k for k, v in six.iteritems(releases) if codename in v]
238 ret = subprocess.check_output(['apt-cache', 'policy', 'swift'])
239 if codename in ret or release[0] in ret:
240 return codename
241 elif len(codenames) == 1:
242 return codenames[0]
243 return None
244
245
230def get_os_codename_package(package, fatal=True):246def get_os_codename_package(package, fatal=True):
231 '''Derive OpenStack release codename from an installed package.'''247 '''Derive OpenStack release codename from an installed package.'''
232 import apt_pkg as apt248 import apt_pkg as apt
@@ -270,7 +286,7 @@
270 # < Liberty co-ordinated project versions286 # < Liberty co-ordinated project versions
271 try:287 try:
272 if 'swift' in pkg.name:288 if 'swift' in pkg.name:
273 return SWIFT_CODENAMES[vers]289 return get_swift_codename(vers)
274 else:290 else:
275 return OPENSTACK_CODENAMES[vers]291 return OPENSTACK_CODENAMES[vers]
276 except KeyError:292 except KeyError:
@@ -289,12 +305,14 @@
289305
290 if 'swift' in pkg:306 if 'swift' in pkg:
291 vers_map = SWIFT_CODENAMES307 vers_map = SWIFT_CODENAMES
308 for cname, version in six.iteritems(vers_map):
309 if cname == codename:
310 return version[-1]
292 else:311 else:
293 vers_map = OPENSTACK_CODENAMES312 vers_map = OPENSTACK_CODENAMES
294313 for version, cname in six.iteritems(vers_map):
295 for version, cname in six.iteritems(vers_map):314 if cname == codename:
296 if cname == codename:315 return version
297 return version
298 # e = "Could not determine OpenStack version for package: %s" % pkg316 # e = "Could not determine OpenStack version for package: %s" % pkg
299 # error_out(e)317 # error_out(e)
300318
@@ -460,11 +478,16 @@
460 cur_vers = get_os_version_package(package)478 cur_vers = get_os_version_package(package)
461 if "swift" in package:479 if "swift" in package:
462 codename = get_os_codename_install_source(src)480 codename = get_os_codename_install_source(src)
463 available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)481 avail_vers = get_os_version_codename_swift(codename)
464 else:482 else:
465 available_vers = get_os_version_install_source(src)483 avail_vers = get_os_version_install_source(src)
466 apt.init()484 apt.init()
467 return apt.version_compare(available_vers, cur_vers) == 1485 if "swift" in package:
486 major_cur_vers = cur_vers.split('.', 1)[0]
487 major_avail_vers = avail_vers.split('.', 1)[0]
488 major_diff = apt.version_compare(major_avail_vers, major_cur_vers)
489 return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0)
490 return apt.version_compare(avail_vers, cur_vers) == 1
468491
469492
470def ensure_block_device(block_device):493def ensure_block_device(block_device):
471494
=== modified file 'charmhelpers/fetch/giturl.py'
--- charmhelpers/fetch/giturl.py 2016-01-08 02:38:26 +0000
+++ charmhelpers/fetch/giturl.py 2016-01-13 19:15:29 +0000
@@ -49,8 +49,8 @@
49 cmd = ['git', '-C', dest, 'pull', source, branch]49 cmd = ['git', '-C', dest, 'pull', source, branch]
50 else:50 else:
51 cmd = ['git', 'clone', source, dest, '--branch', branch]51 cmd = ['git', 'clone', source, dest, '--branch', branch]
52 if depth:52 if depth:
53 cmd.extend(['--depth', depth])53 cmd.extend(['--depth', depth])
54 check_call(cmd)54 check_call(cmd)
5555
56 def install(self, source, branch="master", dest=None, depth=None):56 def install(self, source, branch="master", dest=None, depth=None):

Subscribers

People subscribed via source and target branches