def ipv4_address(addr):
 if (not isinstance(addr, basestring)):
  raise CX('Invalid input, addr must be a string')
 else:
  addr = addr.strip()
 if (addr == ''):
  return addr
 if (not netaddr.valid_ipv4(addr)):
  raise CX(('Invalid IPv4 address format (%s)' % addr))
 if netaddr.IPAddress(addr).is_netmask():
  raise CX(('Invalid IPv4 host address (%s)' % addr))
 return addr

def ipv4_address ( addr ) : if ( not isinstance ( addr , basestring ) ) : raise CX ( 'Invalid input, addr must be a string' ) else : addr = addr . strip ( ) if ( addr == '' ) : return addr if ( not netaddr . valid_ipv4 ( addr ) ) : raise CX ( ( 'Invalid IPv4 address format (%s)' % addr ) ) if netaddr . IPAddress ( addr ) . is_netmask ( ) : raise CX ( ( 'Invalid IPv4 host address (%s)' % addr ) ) return addr
validate an ipv4 address .