How to use the peeringdb.models.PeerRecord.objects.all 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 / views.py View on Github external
last_synchronization = PeeringDB().get_last_synchronization()
        sync_time = last_synchronization.time if last_synchronization else 0

        context = {
            "last_sync_time": sync_time,
            "peeringdb_contact_count": Contact.objects.count(),
            "peeringdb_network_count": Network.objects.count(),
            "peeringdb_networkixlan_count": NetworkIXLAN.objects.count(),
            "peer_record_count": PeerRecord.objects.count(),
        }
        return render(request, "peeringdb/cache.html", context)


class PeerRecordBulkEdit(PermissionRequiredMixin, BulkEditView):
    permission_required = "peeringdb.change_peerrecord"
    queryset = PeerRecord.objects.all()
    filter = PeerRecordFilterSet
    table = PeerRecordTable
    form = PeerRecordBulkEditForm
github respawner / peering-manager / peeringdb / http.py View on Github external
def force_peer_records_discovery(self):
        """
        Force the peer records cache to be [re]built. This function can be used
        if this cache appears to be out of sync or inconsistent.
        """
        indexed = 0

        with transaction.atomic():
            # First of all, delete all existing peer records
            PeerRecord.objects.all().delete()

            # Build the cache
            for network_ixlan in NetworkIXLAN.objects.all():
                # Ignore if we have no IPv6 and no IPv4 to peer with
                if not network_ixlan.ipaddr6 and not network_ixlan.ipaddr4:
                    self.logger.debug(
                        "network ixlan with as%s and ixlan id %s"
                        " ignored, no ipv6 and no ipv4",
                        network_ixlan.asn,
                        network_ixlan.ixlan_id,
                    )
                    continue

                network = None
                try:
                    network = Network.objects.get(asn=network_ixlan.asn)
github respawner / peering-manager / peeringdb / api / views.py View on Github external
class ContactsViewSet(ReadOnlyModelViewSet):
    queryset = Contact.objects.all()
    serializer_class = ContactSerializer
    filterset_class = ContactFilterSet


class NetworksViewSet(ReadOnlyModelViewSet):
    queryset = Network.objects.all()
    serializer_class = NetworkSerializer
    filterset_class = NetworkFilterSet


class PeerRecordViewSet(ModelViewSet):
    queryset = PeerRecord.objects.all()
    serializer_class = PeerRecordSerializer
    filterset_class = PeerRecordFilterSet


class SynchronizationViewSet(ReadOnlyModelViewSet):
    queryset = Synchronization.objects.all()
    serializer_class = SynchronizationSerializer
    filterset_class = SynchronizationFilterSet
github respawner / peering-manager / peeringdb / forms.py View on Github external
from django import forms

from .models import PeerRecord
from utils.forms import (
    BootstrapMixin,
    BulkEditForm,
    CustomNullBooleanSelect,
    DynamicModelMultipleChoiceField,
)


class PeerRecordBulkEditForm(BootstrapMixin, BulkEditForm):
    pk = DynamicModelMultipleChoiceField(
        queryset=PeerRecord.objects.all(), widget=forms.MultipleHiddenInput
    )
    visible = forms.NullBooleanField(required=False, widget=CustomNullBooleanSelect)

    class Meta:
        pass


class PeerRecordFilterForm(BootstrapMixin, forms.Form):
    model = PeerRecord
    q = forms.CharField(required=False, label="Search")
    network__asn = forms.IntegerField(required=False, label="ASN")
    network__name = forms.CharField(required=False, label="AS Name")
    network__irr_as_set = forms.CharField(required=False, label="IRR AS-SET")
    network__info_prefixes6 = forms.IntegerField(
        required=False, label="IPv6 Max Prefixes"
    )