mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-20 12:22:23 -06:00
* Move L2VPN and L2VPNTermination models from ipam to vpn * Move L2VPN resources from ipam to vpn * Extend migration to update content types * Misc cleanup
This commit is contained in:
30
netbox/vpn/graphql/gfk_mixins.py
Normal file
30
netbox/vpn/graphql/gfk_mixins.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import graphene
|
||||
|
||||
from dcim.graphql.types import InterfaceType
|
||||
from dcim.models import Interface
|
||||
from ipam.graphql.types import VLANType
|
||||
from ipam.models import VLAN
|
||||
from virtualization.graphql.types import VMInterfaceType
|
||||
from virtualization.models import VMInterface
|
||||
|
||||
__all__ = (
|
||||
'L2VPNAssignmentType',
|
||||
)
|
||||
|
||||
|
||||
class L2VPNAssignmentType(graphene.Union):
|
||||
class Meta:
|
||||
types = (
|
||||
InterfaceType,
|
||||
VLANType,
|
||||
VMInterfaceType,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def resolve_type(cls, instance, info):
|
||||
if type(instance) is Interface:
|
||||
return InterfaceType
|
||||
if type(instance) is VLAN:
|
||||
return VLANType
|
||||
if type(instance) is VMInterface:
|
||||
return VMInterfaceType
|
||||
@@ -38,6 +38,18 @@ class VPNQuery(graphene.ObjectType):
|
||||
def resolve_ipsec_proposal_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.IPSecProposal.objects.all(), info)
|
||||
|
||||
l2vpn = ObjectField(L2VPNType)
|
||||
l2vpn_list = ObjectListField(L2VPNType)
|
||||
|
||||
def resolve_l2vpn_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.L2VPN.objects.all(), info)
|
||||
|
||||
l2vpn_termination = ObjectField(L2VPNTerminationType)
|
||||
l2vpn_termination_list = ObjectListField(L2VPNTerminationType)
|
||||
|
||||
def resolve_l2vpn_termination_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.L2VPNTermination.objects.all(), info)
|
||||
|
||||
tunnel = ObjectField(TunnelType)
|
||||
tunnel_list = ObjectListField(TunnelType)
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from extras.graphql.mixins import CustomFieldsMixin, TagsMixin
|
||||
import graphene
|
||||
|
||||
from extras.graphql.mixins import ContactsMixin, CustomFieldsMixin, TagsMixin
|
||||
from netbox.graphql.types import ObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||
from vpn import filtersets, models
|
||||
|
||||
@@ -8,6 +10,8 @@ __all__ = (
|
||||
'IPSecPolicyType',
|
||||
'IPSecProfileType',
|
||||
'IPSecProposalType',
|
||||
'L2VPNType',
|
||||
'L2VPNTerminationType',
|
||||
'TunnelTerminationType',
|
||||
'TunnelType',
|
||||
)
|
||||
@@ -67,3 +71,19 @@ class IPSecProfileType(OrganizationalObjectType):
|
||||
model = models.IPSecProfile
|
||||
fields = '__all__'
|
||||
filterset_class = filtersets.IPSecProfileFilterSet
|
||||
|
||||
|
||||
class L2VPNType(ContactsMixin, NetBoxObjectType):
|
||||
class Meta:
|
||||
model = models.L2VPN
|
||||
fields = '__all__'
|
||||
filtersets_class = filtersets.L2VPNFilterSet
|
||||
|
||||
|
||||
class L2VPNTerminationType(NetBoxObjectType):
|
||||
assigned_object = graphene.Field('vpn.graphql.gfk_mixins.L2VPNAssignmentType')
|
||||
|
||||
class Meta:
|
||||
model = models.L2VPNTermination
|
||||
exclude = ('assigned_object_type', 'assigned_object_id')
|
||||
filtersets_class = filtersets.L2VPNTerminationFilterSet
|
||||
|
||||
Reference in New Issue
Block a user