MongoDB won't create a collection until data is inserted. Therefore, this function just warns if the setup has been run before.
(m_connection)
| 27 | |
| 28 | |
| 29 | def create_collections(m_connection): |
| 30 | """ |
| 31 | MongoDB won't create a collection until data is inserted. |
| 32 | Therefore, this function just warns if the setup has been run before. |
| 33 | """ |
| 34 | collections = [ |
| 35 | "akamai_ips", |
| 36 | "all_dns", |
| 37 | "all_ips", |
| 38 | "aws_ips", |
| 39 | "censys", |
| 40 | "cert_graphs", |
| 41 | "cidr_graphs", |
| 42 | "config", |
| 43 | "ct_certs", |
| 44 | "dead_dns", |
| 45 | "get_route53", |
| 46 | "gcp_ips", |
| 47 | "graphs_data", |
| 48 | "graphs_docs", |
| 49 | "graphs_links", |
| 50 | "groups", |
| 51 | "iblox_a_records", |
| 52 | "iblox_aaaa_records", |
| 53 | "iblox_cname_records", |
| 54 | "iblox_host_records", |
| 55 | "iblox_mx_records", |
| 56 | "iblox_extattr_records", |
| 57 | "iblox_txt_records", |
| 58 | "ip_zones", |
| 59 | "ipv6_zones", |
| 60 | "jobs", |
| 61 | "sessions", |
| 62 | "sonar_rdns", |
| 63 | "tpd_graphs", |
| 64 | "tpds", |
| 65 | "users", |
| 66 | "virustotal", |
| 67 | "whois", |
| 68 | "zgrab_443_data", |
| 69 | "zgrab_80_data", |
| 70 | "zgrab_port_data", |
| 71 | "zones", |
| 72 | ] |
| 73 | |
| 74 | for collection in collections: |
| 75 | if m_connection[collection].count_documents({}) > 0: |
| 76 | print("WARNING: The " + collection + " already exists.") |
| 77 | |
| 78 | |
| 79 | def create_job_collection(mongo_connector): |