~ubuntu-branches/ubuntu/saucy/cloud-init/saucy

« back to all changes in this revision

Viewing changes to cloudinit/util.py

  • Committer: Scott Moser
  • Date: 2013-09-11 21:04:19 UTC
  • mfrom: (1.4.5)
  • Revision ID: smoser@ubuntu.com-20130911210419-3vt5ze6ph3hu8dz1
* New upstream snapshot.
  * Add OpenNebula datasource.
  * Support reading 'random_seed' from metadata and writing to /dev/urandom
  * fix for bug in log_time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
955
955
    return hostname
956
956
 
957
957
 
 
958
def gethostbyaddr(ip):
 
959
    try:
 
960
        return socket.gethostbyaddr(ip)[0]
 
961
    except socket.herror:
 
962
        return None
 
963
 
 
964
 
958
965
def is_resolvable_url(url):
959
966
    """determine if this url is resolvable (existing or ip)."""
960
967
    return (is_resolvable(urlparse.urlparse(url).hostname))
1791
1798
        ret = func(*args, **kwargs)
1792
1799
    finally:
1793
1800
        delta = time.time() - start
 
1801
        udelta = None
1794
1802
        if ustart is not None:
1795
1803
            try:
1796
1804
                udelta = float(uptime()) - ustart
1797
1805
            except ValueError:
1798
 
                udelta = "N/A"
 
1806
                pass
1799
1807
 
1800
1808
        tmsg = " took %0.3f seconds" % delta
1801
1809
        if get_uptime:
1802
 
            tmsg += "(%0.2f)" % udelta
 
1810
            if isinstance(udelta, (float)):
 
1811
                tmsg += " (%0.2f)" % udelta
 
1812
            else:
 
1813
                tmsg += " (N/A)"
1803
1814
        try:
1804
1815
            logfunc(msg + tmsg)
1805
1816
        except: