~openstack-charmers-next/charms/trusty/cinder/trunk

« back to all changes in this revision

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

  • Committer: James Page
  • Date: 2016-05-27 11:25:30 UTC
  • Revision ID: james.page@ubuntu.com-20160527112530-znvvbn1p03itnvuu
Resync charm helpers

Add support for OpenStack Newton and Ocata.

Rework version detection code to just match on major version for
OpenStack projects using semantic versioning.

Provide fallback version detection based on major.minor versions
for swift packages.

Rework config-flags support helpers.

Fix is_ip function to correctly detect both IPv4 and IPv6 addresses.

Change-Id: Ifed0c7a742291bbc6380143be0f8b743c5b918f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
405
405
    Returns True if address is a valid IP address.
406
406
    """
407
407
    try:
408
 
        # Test to see if already an IPv4 address
409
 
        socket.inet_aton(address)
 
408
        # Test to see if already an IPv4/IPv6 address
 
409
        address = netaddr.IPAddress(address)
410
410
        return True
411
 
    except socket.error:
 
411
    except netaddr.AddrFormatError:
412
412
        return False
413
413
 
414
414