MCPcopy Create free account
hub / github.com/adobe/Marinus / download_sonar_dns

Function download_sonar_dns

python3_cron_scripts/download_from_remote_database.py:220–250  ·  view source on GitHub ↗

The remote sonar_dns_colllection is temporary storage for the remote Sonar scripts

(logger, dns_manager, remote_mongo_connector)

Source from the content-addressed store, hash-verified

218
219
220def download_sonar_dns(logger, dns_manager, remote_mongo_connector):
221 """
222 The remote sonar_dns_colllection is temporary storage for the remote Sonar scripts
223 """
224 logger.info("Beginning Sonar DNS Download")
225
226 # Calculate jobs
227 scrub_date = datetime.now() - timedelta(days=2, hours=9)
228
229 remote_sonar_dns_collection = remote_mongo_connector.get_sonar_data_dns()
230
231 # Get all dns records where
232 results = remote_sonar_dns_collection.find(
233 {"updated": {"$gt": scrub_date}}, {"_id": 0, "sources": 0}
234 ).batch_size(10)
235
236 for result in results:
237 new_record = {}
238 new_record["zone"] = result["zone"]
239 new_record["fqdn"] = result["fqdn"]
240 new_record["status"] = result["status"]
241 new_record["type"] = result["type"]
242 new_record["value"] = result["value"]
243 new_record["sonar_timestamp"] = result["sonar_timestamp"]
244 new_record["created"] = result["created"]
245 new_record["updated"] = result["updated"]
246 dns_manager.insert_record(new_record, "sonar_dns")
247
248 # Delete all DNS records not updated within 60 days?
249 scrub_date = datetime.now() - timedelta(days=60, hours=9)
250 remote_sonar_dns_collection.delete_many({"updated": {"$lt": scrub_date}})
251
252
253def download_sonar_rdns(logger, mongo_connector, remote_mongo_connector):

Callers

nothing calls this directly

Calls 2

get_sonar_data_dnsMethod · 0.80
insert_recordMethod · 0.45

Tested by

no test coverage detected