no_ip() rasies an exception when subnet is used as an argument

Bug #1626508 reported by Ante Karamatić
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Charm Helpers
Fix Released
Undecided
Unassigned

Bug Description

is_ip() in charmhelpers/contrib/network/ip.py returns True if value it an IP, and False if it's not an IP. It does that by returning False when AddrFormatError is raised. This works fine for nonsense and interfaces:

>>> netaddr.IPAddress("[eth0]")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 306, in __init__
    'address from %r' % addr)
netaddr.core.AddrFormatError: failed to detect a valid IP address from '[eth0]'
>>> netaddr.IPAddress("nonsense")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 306, in __init__
    'address from %r' % addr)
netaddr.core.AddrFormatError: failed to detect a valid IP address from 'nonsense'

but it fails for subnets:

>>> netaddr.IPAddress("192.168.0.100/16")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 280, in __init__
    % self.__class__.__name__)
ValueError: IPAddress() does not support netmasks or subnet prefixes! See documentation for details.

This is because subnet, for some reason, raises ValueError.

Tags: 4010

Related branches

Ante Karamatić (ivoks)
tags: added: 4010
Michał Ajduk (majduk)
Changed in charm-helpers:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.