~jorge/charms/precise/cinder/fix-README

« back to all changes in this revision

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

  • Committer: james.page at ubuntu
  • Date: 2014-05-21 09:57:23 UTC
  • mfrom: (35.1.2 cinder)
  • Revision ID: james.page@ubuntu.com-20140521095723-qiulw0yz0q0k1jcd
[tribaal,r=james-page,t=james-page]

Resync helpers to pickup fixes for apt lock races and better block device detection and handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
def get_os_codename_package(package, fatal=True):
132
132
    '''Derive OpenStack release codename from an installed package.'''
133
133
    apt.init()
 
134
 
 
135
    # Tell apt to build an in-memory cache to prevent race conditions (if
 
136
    # another process is already building the cache).
 
137
    apt.config.set("Dir::Cache::pkgcache", "")
 
138
 
134
139
    cache = apt.Cache()
135
140
 
136
141
    try:
183
188
        if cname == codename:
184
189
            return version
185
190
    #e = "Could not determine OpenStack version for package: %s" % pkg
186
 
    #error_out(e)
 
191
    # error_out(e)
187
192
 
188
193
 
189
194
os_rel = None
401
406
        rtype = 'PTR'
402
407
    elif isinstance(address, basestring):
403
408
        rtype = 'A'
 
409
    else:
 
410
        return None
404
411
 
405
412
    answers = dns.resolver.query(address, rtype)
406
413
    if answers: