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

Function main

python3_cron_scripts/create_netaddr_graphs.py:356–498  ·  view source on GitHub ↗

Begin Main

(logger=None)

Source from the content-addressed store, hash-verified

354
355
356def main(logger=None):
357 """
358 Begin Main
359 """
360 if logger is None:
361 logger = LoggingUtil.create_log(__name__)
362
363 now = datetime.now()
364 print("Starting: " + str(now))
365 logger.info("Starting...")
366
367 # Set up all the database connections
368 mongo_connector = MongoConnector.MongoConnector()
369 dns_manager = DNSManager.DNSManager(mongo_connector)
370 jobs_manager = JobsManager.JobsManager(mongo_connector, "create_netaddr_graphs")
371 jobs_manager.record_job_start()
372
373 # Get the list of the all Class C's in Marinus
374 groups = []
375 create_list_of_cidrs(groups, mongo_connector, dns_manager)
376
377 # Create a separate copy of the class C list since groups will be modified later
378 cidr_list = groups + []
379
380 # Create the stats on the network data
381 group_data = create_network_data_sets(groups, mongo_connector)
382
383 logger.info("Number of Tracked Class C's: " + str(group_data["tracked_count"]))
384 logger.info("Number of AWS Class C's: " + str(group_data["aws_count"]))
385 logger.info("Number of Azure Class C's: " + str(group_data["azure_count"]))
386 logger.info("Number of Akamai Class C's: " + str(group_data["akamai_count"]))
387 logger.info("Number of Class C's: " + str(len(groups)))
388
389 # Get the current list of zones
390 zones = ZoneManager.get_distinct_zones(mongo_connector)
391
392 # For each Class C that was identified in Marinus...
393 for tcidr in cidr_list:
394 cidr = tcidr.replace(REPLACE_CHAR, ".")
395 groups = []
396 graph = nx.Graph()
397 add_to_list(cidr, groups)
398 graph.add_node(
399 cidr,
400 data_type="class_c",
401 type=0,
402 depends=[],
403 dependedOnBy=[],
404 docs="<h1>Parent</h1>",
405 )
406 find_all_dns_by_zone(graph, cidr, groups, dns_manager)
407 find_srdns_by_zone(graph, cidr, groups, mongo_connector)
408
409 data = json_graph.node_link_data(graph)
410
411 reformat_data(data, cidr, groups)
412
413 new_data = {}

Callers 1

Calls 12

record_job_startMethod · 0.95
record_job_completeMethod · 0.95
create_list_of_cidrsFunction · 0.85
create_network_data_setsFunction · 0.85
create_logMethod · 0.80
get_distinct_zonesMethod · 0.80
perform_insertMethod · 0.80
add_to_listFunction · 0.70
find_all_dns_by_zoneFunction · 0.70
find_srdns_by_zoneFunction · 0.70
reformat_dataFunction · 0.70

Tested by

no test coverage detected