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

Method insert_record

python3_cron_scripts/libs3/IPManager.py:569–770  ·  view source on GitHub ↗

Insert an IP into the tracking table This function completely rebuilds the record because it is simpler and cleaner than tracking which data came from which location and whether to expire specific sections.

(
        self,
        ip,
        source=None,
        account_id=None,
        cloud_env=None,
        account_info=None,
        fqdn=None,
    )

Source from the content-addressed store, hash-verified

567 return rnds_value, rdns_zone
568
569 def insert_record(
570 self,
571 ip,
572 source=None,
573 account_id=None,
574 cloud_env=None,
575 account_info=None,
576 fqdn=None,
577 ):
578 """
579 Insert an IP into the tracking table
580 This function completely rebuilds the record because it is simpler and cleaner than tracking which
581 data came from which location and whether to expire specific sections.
582 """
583
584 if ip is None or ip == "":
585 self._logger.error("ERROR: Sent an invalid IP address: " + str(ip))
586 return
587
588 if isinstance(ip, str):
589 ip_addr = IPAddress(ip)
590 else:
591 ip_addr = ip
592 ip = str(ip_addr)
593
594 if ip_addr is None:
595 self._logger.error("ERROR: Could not insert: " + str(ip))
596 return
597
598 if self.is_local_ip(ip):
599 if fqdn is not None:
600 self._logger.warning(
601 "WARNING: all_ips does not track local IP addresses: " + str(fqdn)
602 )
603 else:
604 self._logger.warning(
605 "WARNING: all_ips does not track local IP addresses"
606 )
607 return
608
609 record = {}
610 record["ip"] = ip
611 record["version"] = ip_addr.version
612 record["updated"] = datetime.now()
613
614 if account_info is not None:
615 record["accountInfo"] = account_info
616
617 if account_id is None and account_info is not None:
618 for entry in account_info:
619 if entry["key"] == "accountId":
620 account_id = entry["value"]
621
622 # Check existance
623 result = self._mongo_connector.perform_find_one(
624 self.all_ips_collection, {"ip": ip}
625 )
626 if result is not None:

Callers 11

record_findingFunction · 0.45
download_sonar_dnsFunction · 0.45
update_dnsFunction · 0.45
check_for_ptr_recordFunction · 0.45
parse_fileFunction · 0.45
insert_current_resultsFunction · 0.45
update_recordsFunction · 0.45
update_dnsFunction · 0.45
check_for_ptr_recordFunction · 0.45

Calls 8

is_local_ipMethod · 0.95
find_partner_rangeMethod · 0.95
find_partner_notesMethod · 0.95
find_splunk_dataMethod · 0.95
extract_rdns_infoMethod · 0.95
find_dns_zonesMethod · 0.95
perform_find_oneMethod · 0.80
get_distinct_zonesMethod · 0.80

Tested by

no test coverage detected