def get_host_ip(ip, shorten=True):
 ip = netaddr.ip.IPAddress(ip)
 cidr = netaddr.ip.IPNetwork(ip)
 if (len(cidr) == 1):
  return pretty_hex(ip)
 else:
  pretty = pretty_hex(cidr[0])
  if ((not shorten) or (len(cidr) <= 8)):
   return pretty
  else:
   cutoff = ((32 - cidr.prefixlen) / 4)
   return pretty[0:(- cutoff)]

def get_host_ip ( ip , shorten = True ) : ip = netaddr . ip . IPAddress ( ip ) cidr = netaddr . ip . IPNetwork ( ip ) if ( len ( cidr ) == 1 ) : return pretty_hex ( ip ) else : pretty = pretty_hex ( cidr [ 0 ] ) if ( ( not shorten ) or ( len ( cidr ) <= 8 ) ) : return pretty else : cutoff = ( ( 32 - cidr . prefixlen ) / 4 ) return pretty [ 0 : ( - cutoff ) ]
return the ip encoding needed for the tftp boot tree .