Update the entire collection by deleting all previous records before inserting new records. Performing a zone by zone upload to minimize the chances of the zgrab script pulling a zone at the same time it is being deleted.
(logger, mongo_connector, rm_connector, zone_list)
| 155 | |
| 156 | |
| 157 | def update_all_dns(logger, mongo_connector, rm_connector, zone_list): |
| 158 | """ |
| 159 | Update the entire collection by deleting all previous records before |
| 160 | inserting new records. |
| 161 | |
| 162 | Performing a zone by zone upload to minimize the chances of the zgrab script |
| 163 | pulling a zone at the same time it is being deleted. |
| 164 | """ |
| 165 | logger.info("Starting All DNS..") |
| 166 | all_dns_collection = mongo_connector.get_all_dns_connection() |
| 167 | remote_all_dns_collection = rm_connector.get_all_dns_connection() |
| 168 | |
| 169 | for zone in zone_list: |
| 170 | all_dns = all_dns_collection.find({"zone": zone}, {"_id": 0}).batch_size(50) |
| 171 | |
| 172 | remote_all_dns_collection.delete_many({"zone": zone}) |
| 173 | for ip_addr in all_dns: |
| 174 | remote_all_dns_collection.insert_one(ip_addr) |
| 175 | |
| 176 | |
| 177 | def update_all_dns_diff_mode( |
no test coverage detected