How to use the peeringdb.models.NetworkIXLAN.objects.filter function in peeringdb

To help you get started, we’ve selected a few peeringdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github respawner / peering-manager / peeringdb / http.py View on Github external
def get_peers_for_ix(self, ix_id):
        """
        Returns a dict with details for peers for the IX corresponding to the
        given ID. This function try to leverage the use of local database
        caching. If the cache is not built it can take some time to execute due
        to the amount of peers on the IX which increases the number of API
        calls to be made.
        """
        # Try to get from cached data
        network_ixlans = NetworkIXLAN.objects.filter(ix_id=ix_id)

        # If nothing found in cache, try to fetch data online
        if not network_ixlans:
            search = {"ix_id": ix_id}
            result = self.lookup(NAMESPACES["network_internet_exchange_lan"], search)

            if not result or not result["data"]:
                return None

            network_ixlans = []
            for data in result["data"]:
                network_ixlans.append(Object(data))

        # List potential peers
        peers = []
        for network_ixlan in network_ixlans: