def parse_domain_computers(filename):
with open(filename) as f:<EOL><INDENT>data = json.loads(f.read())<EOL><DEDENT>hs = HostSearch()<EOL>count = <NUM_LIT:0><EOL>entry_count = <NUM_LIT:0><EOL>print_notification("<STR_LIT>".format(len(data)))<EOL>for system in data:<EOL><INDENT>entry_count += <NUM_LIT:1><EOL>parsed = parse_single_computer(system)<EOL>if parsed.ip:<EOL><INDENT>try:<EOL><INDENT>host = hs.id_to_object(parsed.ip)<EOL>host.description.append(parsed.description)<EOL>host.hostname.append(parsed.dns_hostname)<EOL>if parsed.os:<EOL><INDENT>host.os = parsed.os<EOL><DEDENT>host.domain_controller = parsed.dc<EOL>host.add_tag('<STR_LIT>')<EOL>host.save()<EOL>count += <NUM_LIT:1><EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>sys.stdout.write('<STR_LIT:\r>')<EOL>sys.stdout.write(<EOL>"<STR_LIT>".format(entry_count, len(data), count))<EOL>sys.stdout.flush()<EOL><DEDENT>sys.stdout.write('<STR_LIT:\r>')<EOL>return count<EOL>
Parse the file and extract the computers, import the computers that resolve into jackal.