~gnuoy/charms/trusty/neutron-openvswitch/ice-meta

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/utils.py

  • Committer: Corey Bryant
  • Date: 2015-08-18 17:34:35 UTC
  • Revision ID: corey.bryant@canonical.com-20150818173435-z1u5oh5gpqizisc3
[corey.bryant,r=trivial] Sync charm-helpers to pick up Liberty support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import json
25
25
import os
26
26
import sys
 
27
import re
27
28
 
28
29
import six
29
30
import yaml
69
70
DISTRO_PROPOSED = ('deb http://archive.ubuntu.com/ubuntu/ %s-proposed '
70
71
                   'restricted main multiverse universe')
71
72
 
72
 
 
73
73
UBUNTU_OPENSTACK_RELEASE = OrderedDict([
74
74
    ('oneiric', 'diablo'),
75
75
    ('precise', 'essex'),
118
118
    ('2.3.0', 'liberty'),
119
119
])
120
120
 
 
121
# >= Liberty version->codename mapping
 
122
PACKAGE_CODENAMES = {
 
123
    'nova-common': OrderedDict([
 
124
        ('12.0.0', 'liberty'),
 
125
    ]),
 
126
    'neutron-common': OrderedDict([
 
127
        ('7.0.0', 'liberty'),
 
128
    ]),
 
129
    'cinder-common': OrderedDict([
 
130
        ('7.0.0', 'liberty'),
 
131
    ]),
 
132
    'keystone': OrderedDict([
 
133
        ('8.0.0', 'liberty'),
 
134
    ]),
 
135
    'horizon-common': OrderedDict([
 
136
        ('8.0.0', 'liberty'),
 
137
    ]),
 
138
    'ceilometer-common': OrderedDict([
 
139
        ('5.0.0', 'liberty'),
 
140
    ]),
 
141
    'heat-common': OrderedDict([
 
142
        ('5.0.0', 'liberty'),
 
143
    ]),
 
144
    'glance-common': OrderedDict([
 
145
        ('11.0.0', 'liberty'),
 
146
    ]),
 
147
}
 
148
 
121
149
DEFAULT_LOOPBACK_SIZE = '5G'
122
150
 
123
151
 
201
229
        error_out(e)
202
230
 
203
231
    vers = apt.upstream_version(pkg.current_ver.ver_str)
 
232
    match = re.match('^(\d)\.(\d)\.(\d)', vers)
 
233
    if match:
 
234
        vers = match.group(0)
204
235
 
205
 
    try:
206
 
        if 'swift' in pkg.name:
207
 
            swift_vers = vers[:5]
208
 
            if swift_vers not in SWIFT_CODENAMES:
209
 
                # Deal with 1.10.0 upward
210
 
                swift_vers = vers[:6]
211
 
            return SWIFT_CODENAMES[swift_vers]
212
 
        else:
213
 
            vers = vers[:6]
214
 
            return OPENSTACK_CODENAMES[vers]
215
 
    except KeyError:
216
 
        e = 'Could not determine OpenStack codename for version %s' % vers
217
 
        error_out(e)
 
236
    # >= Liberty independent project versions
 
237
    if (package in PACKAGE_CODENAMES and
 
238
            vers in PACKAGE_CODENAMES[package]):
 
239
        return PACKAGE_CODENAMES[package][vers]
 
240
    else:
 
241
        # < Liberty co-ordinated project versions
 
242
        try:
 
243
            if 'swift' in pkg.name:
 
244
                swift_vers = vers[:5]
 
245
                if swift_vers not in SWIFT_CODENAMES:
 
246
                    # Deal with 1.10.0 upward
 
247
                    swift_vers = vers[:6]
 
248
                return SWIFT_CODENAMES[swift_vers]
 
249
            else:
 
250
                vers = vers[:6]
 
251
                return OPENSTACK_CODENAMES[vers]
 
252
        except KeyError:
 
253
            e = 'Could not determine OpenStack codename for version %s' % vers
 
254
            error_out(e)
218
255
 
219
256
 
220
257
def get_os_version_package(pkg, fatal=True):