~ionutbalutoiu/charms/trusty/neutron-api/next

« back to all changes in this revision

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

  • Committer: James Page
  • Date: 2014-06-24 11:05:17 UTC
  • Revision ID: james.page@ubuntu.com-20140624110517-7chb3mwca2mtnmlp
Resync helpers, add standard targets to Makefile

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# Common python helper functions used for OpenStack charms.
4
4
from collections import OrderedDict
5
5
 
6
 
import apt_pkg as apt
7
6
import subprocess
8
7
import os
9
8
import socket
41
40
    ('quantal', 'folsom'),
42
41
    ('raring', 'grizzly'),
43
42
    ('saucy', 'havana'),
44
 
    ('trusty', 'icehouse')
 
43
    ('trusty', 'icehouse'),
 
44
    ('utopic', 'juno'),
45
45
])
46
46
 
47
47
 
52
52
    ('2013.1', 'grizzly'),
53
53
    ('2013.2', 'havana'),
54
54
    ('2014.1', 'icehouse'),
 
55
    ('2014.2', 'juno'),
55
56
])
56
57
 
57
58
# The ugly duckling
130
131
 
131
132
def get_os_codename_package(package, fatal=True):
132
133
    '''Derive OpenStack release codename from an installed package.'''
 
134
    import apt_pkg as apt
133
135
    apt.init()
 
136
 
 
137
    # Tell apt to build an in-memory cache to prevent race conditions (if
 
138
    # another process is already building the cache).
 
139
    apt.config.set("Dir::Cache::pkgcache", "")
 
140
 
134
141
    cache = apt.Cache()
135
142
 
136
143
    try:
182
189
    for version, cname in vers_map.iteritems():
183
190
        if cname == codename:
184
191
            return version
185
 
    #e = "Could not determine OpenStack version for package: %s" % pkg
186
 
    #error_out(e)
 
192
    # e = "Could not determine OpenStack version for package: %s" % pkg
 
193
    # error_out(e)
187
194
 
188
195
 
189
196
os_rel = None
268
275
            'icehouse': 'precise-updates/icehouse',
269
276
            'icehouse/updates': 'precise-updates/icehouse',
270
277
            'icehouse/proposed': 'precise-proposed/icehouse',
 
278
            'juno': 'trusty-updates/juno',
 
279
            'juno/updates': 'trusty-updates/juno',
 
280
            'juno/proposed': 'trusty-proposed/juno',
271
281
        }
272
282
 
273
283
        try:
315
325
 
316
326
    """
317
327
 
 
328
    import apt_pkg as apt
318
329
    src = config('openstack-origin')
319
330
    cur_vers = get_os_version_package(package)
320
331
    available_vers = get_os_version_install_source(src)
401
412
        rtype = 'PTR'
402
413
    elif isinstance(address, basestring):
403
414
        rtype = 'A'
 
415
    else:
 
416
        return None
404
417
 
405
418
    answers = dns.resolver.query(address, rtype)
406
419
    if answers: