~james-page/charms/precise/nova-cloud-controller/pre-check

« back to all changes in this revision

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

  • Committer: James Page
  • Date: 2014-02-19 11:02:03 UTC
  • mfrom: (62.1.6 tls-ha)
  • Revision ID: james.page@canonical.com-20140219110203-5z78s29rp3cl55vq
[ivoks] Re-order port-pipeline to ensure end-to-end SSL

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    ('quantal', 'folsom'),
42
42
    ('raring', 'grizzly'),
43
43
    ('saucy', 'havana'),
 
44
    ('trusty', 'icehouse')
44
45
])
45
46
 
46
47
 
201
202
 
202
203
 
203
204
def import_key(keyid):
204
 
    cmd = "apt-key adv --keyserver keyserver.ubuntu.com " \
 
205
    cmd = "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 " \
205
206
          "--recv-keys %s" % keyid
206
207
    try:
207
208
        subprocess.check_call(cmd.split(' '))
260
261
            'havana': 'precise-updates/havana',
261
262
            'havana/updates': 'precise-updates/havana',
262
263
            'havana/proposed': 'precise-proposed/havana',
 
264
            'icehouse': 'precise-updates/icehouse',
 
265
            'icehouse/updates': 'precise-updates/icehouse',
 
266
            'icehouse/proposed': 'precise-proposed/icehouse',
263
267
        }
264
268
 
265
269
        try:
411
415
    return ns_query(hostname)
412
416
 
413
417
 
414
 
def get_hostname(address):
 
418
def get_hostname(address, fqdn=True):
415
419
    """
416
420
    Resolves hostname for given IP, or returns the input
417
421
    if it is already a hostname.
430
434
    if not result:
431
435
        return None
432
436
 
433
 
    # strip trailing .
434
 
    if result.endswith('.'):
435
 
        return result[:-1]
436
 
    return result
 
437
    if fqdn:
 
438
        # strip trailing .
 
439
        if result.endswith('.'):
 
440
            return result[:-1]
 
441
        else:
 
442
            return result
 
443
    else:
 
444
        return result.split('.')[0]