def ip_to_cidr(ip, prefix=None):
 net = netaddr.IPNetwork(ip)
 if (prefix is not None):
  net = netaddr.IPNetwork(((str(net.ip) + '/') + str(prefix)))
 return str(net)

def ip_to_cidr ( ip , prefix = None ) : net = netaddr . IPNetwork ( ip ) if ( prefix is not None ) : net = netaddr . IPNetwork ( ( ( str ( net . ip ) + '/' ) + str ( prefix ) ) ) return str ( net )
convert an ip with no prefix to cidr notation .