def parse_ips(ips, netmask, include_public):
hs = HostSearch()<EOL>rs = RangeSearch()<EOL>ranges = []<EOL>ips = list(set(ips))<EOL>included_ips = []<EOL>print_success("<STR_LIT>".format(len(ips)))<EOL>for ip in ips:<EOL><INDENT>ip_address = ipaddress.ip_address(ip)<EOL>if include_public or ip_address.is_private:<EOL><INDENT>if len(ips) < <NUM_LIT:15>:<EOL><INDENT>print_success("<STR_LIT>".format(ip))<EOL><DEDENT>host = hs.id_to_object(ip)<EOL>host.add_tag('<STR_LIT>')<EOL>host.save()<EOL>r = str(ipaddress.IPv4Network("<STR_LIT>".format(ip, netmask), strict=False))<EOL>ranges.append(r)<EOL>included_ips.append(ip)<EOL><DEDENT>else:<EOL><INDENT>print_notification("<STR_LIT>".format(ip))<EOL><DEDENT><DEDENT>ranges = list(set(ranges))<EOL>print_success("<STR_LIT>".format(len(ranges)))<EOL>for rng in ranges:<EOL><INDENT>if len(ranges) < <NUM_LIT:15>:<EOL><INDENT>print_success("<STR_LIT>".format(rng))<EOL><DEDENT>r = rs.id_to_object(rng)<EOL>r.add_tag('<STR_LIT>')<EOL>r.save()<EOL><DEDENT>stats = {}<EOL>stats['<STR_LIT>'] = included_ips<EOL>stats['<STR_LIT>'] = ranges<EOL>return stats<EOL>
Parses the list of ips, turns these into ranges based on the netmask given.
Set include_public to True to include public IP adresses.