2018-11-05 11:51:38 -05:00
|
|
|
from django.db.models import Manager, QuerySet
|
2017-10-10 17:23:41 -04:00
|
|
|
|
2018-11-05 11:51:38 -05:00
|
|
|
from .constants import NONCONNECTABLE_IFACE_TYPES
|
|
|
|
|
2017-10-10 17:23:41 -04:00
|
|
|
|
|
|
|
class InterfaceQuerySet(QuerySet):
|
|
|
|
|
2018-11-05 11:51:38 -05:00
|
|
|
def connectable(self):
|
|
|
|
"""
|
|
|
|
Return only physical interfaces which are capable of being connected to other interfaces (i.e. not virtual or
|
|
|
|
wireless).
|
2017-10-10 17:23:41 -04:00
|
|
|
"""
|
2019-04-12 13:42:56 -04:00
|
|
|
return self.exclude(type__in=NONCONNECTABLE_IFACE_TYPES)
|
2018-11-05 11:51:38 -05:00
|
|
|
|
2017-10-10 17:23:41 -04:00
|
|
|
|
2018-11-05 11:51:38 -05:00
|
|
|
class InterfaceManager(Manager):
|
|
|
|
|
|
|
|
def get_queryset(self):
|
2020-02-07 15:47:53 -05:00
|
|
|
return InterfaceQuerySet(self.model, using=self._db)
|