'Turn an IPv6 ip_str into an integer.
Args:
ip_str: A string, the IPv6 ip_str.
Returns:
A long, the IPv6 ip_str.'

def _ip_int_from_string(self, ip_str=None):

    if (not ip_str):
        ip_str = str(self.ip)
    ip_int = 0
    fields = self._explode_shorthand_ip_string(ip_str).split(':')
    if (fields[(-1)].count('.') == 3):
        ipv4_string = fields.pop()
        ipv4_int = IPv4Network(ipv4_string)._ip
        octets = []
        for _ in xrange(2):
            octets.append(hex((ipv4_int & 65535)).lstrip('0x').rstrip('L'))
            ipv4_int >>= 16
        fields.extend(reversed(octets))
    for field in fields:
        ip_int = ((ip_int << 16) + int(field, 16))
    return ip_int
