mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 16:26:09 -06:00
9817 ipan graphql gfk
This commit is contained in:
parent
61b2274504
commit
0b38d40b48
@ -1,10 +1,17 @@
|
|||||||
import graphene
|
import graphene
|
||||||
from dcim.graphql.types import InterfaceType
|
from dcim.graphql.types import (
|
||||||
from dcim.models import Interface
|
InterfaceType,
|
||||||
|
LocationType,
|
||||||
|
RackType,
|
||||||
|
RegionType,
|
||||||
|
SiteGroupType,
|
||||||
|
SiteType,
|
||||||
|
)
|
||||||
|
from dcim.models import Interface, Location, Rack, Region, Site, SiteGroup
|
||||||
from ipam.graphql.types import FHRPGroupType, VLANType
|
from ipam.graphql.types import FHRPGroupType, VLANType
|
||||||
from ipam.models import FHRPGroup, VLAN
|
from ipam.models import VLAN, FHRPGroup
|
||||||
from virtualization.graphql.types import VMInterfaceType
|
from virtualization.graphql.types import ClusterGroupType, ClusterType, VMInterfaceType
|
||||||
from virtualization.models import VMInterface
|
from virtualization.models import Cluster, ClusterGroup, VMInterface
|
||||||
|
|
||||||
|
|
||||||
class IPAddressAssignmentType(graphene.Union):
|
class IPAddressAssignmentType(graphene.Union):
|
||||||
@ -41,3 +48,48 @@ class L2VPNAssignmentType(graphene.Union):
|
|||||||
return VLANType
|
return VLANType
|
||||||
if type(instance) == VMInterface:
|
if type(instance) == VMInterface:
|
||||||
return VMInterfaceType
|
return VMInterfaceType
|
||||||
|
|
||||||
|
|
||||||
|
class FHRPGroupInterfaceType(graphene.Union):
|
||||||
|
class Meta:
|
||||||
|
types = (
|
||||||
|
InterfaceType,
|
||||||
|
VMInterfaceType,
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def resolve_type(cls, instance, info):
|
||||||
|
if type(instance) == Interface:
|
||||||
|
return InterfaceType
|
||||||
|
if type(instance) == VMInterface:
|
||||||
|
return VMInterfaceType
|
||||||
|
|
||||||
|
|
||||||
|
class VLANGroupScopeType(graphene.Union):
|
||||||
|
class Meta:
|
||||||
|
types = (
|
||||||
|
ClusterType,
|
||||||
|
ClusterGroupType,
|
||||||
|
LocationType,
|
||||||
|
RackType,
|
||||||
|
RegionType,
|
||||||
|
SiteType,
|
||||||
|
SiteGroupType,
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def resolve_type(cls, instance, info):
|
||||||
|
if type(instance) == Cluster:
|
||||||
|
return ClusterType
|
||||||
|
if type(instance) == ClusterGroup:
|
||||||
|
return ClusterGroupType
|
||||||
|
if type(instance) == Location:
|
||||||
|
return LocationType
|
||||||
|
if type(instance) == Rack:
|
||||||
|
return RackType
|
||||||
|
if type(instance) == Region:
|
||||||
|
return RegionType
|
||||||
|
if type(instance) == Site:
|
||||||
|
return SiteType
|
||||||
|
if type(instance) == SiteGroup:
|
||||||
|
return SiteGroupType
|
||||||
|
@ -55,10 +55,11 @@ class FHRPGroupType(NetBoxObjectType):
|
|||||||
|
|
||||||
|
|
||||||
class FHRPGroupAssignmentType(BaseObjectType):
|
class FHRPGroupAssignmentType(BaseObjectType):
|
||||||
|
interface = graphene.Field('ipam.graphql.gfk_mixins.FHRPGroupInterfaceType')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.FHRPGroupAssignment
|
model = models.FHRPGroupAssignment
|
||||||
fields = '__all__'
|
exclude = ('interface_type', 'interface_id')
|
||||||
filterset_class = filtersets.FHRPGroupAssignmentFilterSet
|
filterset_class = filtersets.FHRPGroupAssignmentFilterSet
|
||||||
|
|
||||||
|
|
||||||
@ -142,10 +143,11 @@ class VLANType(NetBoxObjectType):
|
|||||||
|
|
||||||
|
|
||||||
class VLANGroupType(OrganizationalObjectType):
|
class VLANGroupType(OrganizationalObjectType):
|
||||||
|
scope = graphene.Field('ipam.graphql.gfk_mixins.VLANGroupScopeType')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.VLANGroup
|
model = models.VLANGroup
|
||||||
fields = '__all__'
|
exclude = ('scope_type', 'scope_id')
|
||||||
filterset_class = filtersets.VLANGroupFilterSet
|
filterset_class = filtersets.VLANGroupFilterSet
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user