~gnuoy/charms/trusty/ceph-radosgw/workloadstatus

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/network/ip.py

  • Committer: Corey Bryant
  • Date: 2015-10-02 21:58:25 UTC
  • mfrom: (44.1.1 ceph-radosgw)
  • Revision ID: corey.bryant@canonical.com-20151002215825-e6i3k2lr4aeqafua
[corey.bryant,trivial] Sync charm-helpers to pick up Liberty support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from functools import partial
24
24
 
25
25
from charmhelpers.core.hookenv import unit_get
26
 
from charmhelpers.fetch import apt_install
 
26
from charmhelpers.fetch import apt_install, apt_update
27
27
from charmhelpers.core.hookenv import (
28
28
    log,
29
29
    WARNING,
32
32
try:
33
33
    import netifaces
34
34
except ImportError:
35
 
    apt_install('python-netifaces')
 
35
    apt_update(fatal=True)
 
36
    apt_install('python-netifaces', fatal=True)
36
37
    import netifaces
37
38
 
38
39
try:
39
40
    import netaddr
40
41
except ImportError:
41
 
    apt_install('python-netaddr')
 
42
    apt_update(fatal=True)
 
43
    apt_install('python-netaddr', fatal=True)
42
44
    import netaddr
43
45
 
44
46
 
435
437
 
436
438
        rev = dns.reversename.from_address(address)
437
439
        result = ns_query(rev)
 
440
 
438
441
        if not result:
439
 
            return None
 
442
            try:
 
443
                result = socket.gethostbyaddr(address)[0]
 
444
            except:
 
445
                return None
440
446
    else:
441
447
        result = address
442
448