Find the region and/or note information for the provided CIDR. Returns a string with the relevant data.
(self, cidr_value, partner)
| 414 | return self.UNKNOWN, None |
| 415 | |
| 416 | def find_partner_notes(self, cidr_value, partner): |
| 417 | """ |
| 418 | Find the region and/or note information for the provided CIDR. |
| 419 | Returns a string with the relevant data. |
| 420 | """ |
| 421 | if isinstance(cidr_value, str): |
| 422 | cidr = IPNetwork(cidr_value) |
| 423 | else: |
| 424 | cidr = cidr_value |
| 425 | |
| 426 | if partner == self.AWS: |
| 427 | aws_ips_collection = self._mongo_connector.get_aws_ips_connection() |
| 428 | |
| 429 | if cidr.version == 4: |
| 430 | meta_result = self._mongo_connector.perform_find_one( |
| 431 | aws_ips_collection, {"prefixes.ip_prefix": str(cidr)} |
| 432 | ) |
| 433 | if meta_result is None: |
| 434 | return "" |
| 435 | for result in meta_result["prefixes"]: |
| 436 | if result["ip_prefix"] == str(cidr): |
| 437 | return result["region"] |
| 438 | else: |
| 439 | meta_result = self._mongo_connector.perform_find_one( |
| 440 | aws_ips_collection, {"ipv6_prefixes.ipv6_prefix": str(cidr)} |
| 441 | ) |
| 442 | if meta_result is None: |
| 443 | return "" |
| 444 | for result in meta_result["ipv6_prefixes"]: |
| 445 | if result["ipv6_prefix"] == str(cidr): |
| 446 | return result["region"] |
| 447 | elif partner == self.AZURE: |
| 448 | azure_ips_collection = self._mongo_connector.get_azure_ips_connection() |
| 449 | |
| 450 | meta_result = self._mongo_connector.perform_find_one( |
| 451 | azure_ips_collection, {"prefixes.ip_prefix": str(cidr)} |
| 452 | ) |
| 453 | if meta_result is None: |
| 454 | return "" |
| 455 | for result in meta_result["prefixes"]: |
| 456 | if result["ip_prefix"] == str(cidr): |
| 457 | return result["region"] |
| 458 | elif partner == self.TRACKED: |
| 459 | if cidr.version == 4: |
| 460 | ip_zones_collection = self._mongo_connector.get_ipzone_connection() |
| 461 | |
| 462 | meta_result = self._mongo_connector.perform_find_one( |
| 463 | ip_zones_collection, {"zone": str(cidr)} |
| 464 | ) |
| 465 | if meta_result is not None and "notes" in meta_result: |
| 466 | return meta_result["notes"] |
| 467 | else: |
| 468 | ipv6_zone_collection = self._mongo_connector.get_ipv6_zone_connection() |
| 469 | |
| 470 | meta_result = self._mongo_connector.perform_find_one( |
| 471 | ipv6_zone_collection, {"zone": str(cidr)} |
| 472 | ) |
| 473 | if meta_result is not None and "notes" in meta_result: |
no test coverage detected