9856 fix virtualization FK

This commit is contained in:
Arthur 2024-03-07 11:55:35 -08:00
parent a32f4b82e9
commit 133d6bfcb3

View File

@ -3,7 +3,6 @@ from typing import Annotated, List
import strawberry import strawberry
import strawberry_django import strawberry_django
from dcim.graphql.types import ComponentType
from extras.graphql.mixins import ConfigContextMixin from extras.graphql.mixins import ConfigContextMixin
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
from netbox.graphql.scalars import BigInt from netbox.graphql.scalars import BigInt
@ -21,6 +20,15 @@ __all__ = (
) )
@strawberry.type
class ComponentType(NetBoxObjectType):
"""
Base type for device/VM components
"""
_name: str
virtual_machine: Annotated["VirtualMachineType", strawberry.lazy('virtualization.graphql.types')]
@strawberry_django.type( @strawberry_django.type(
models.Cluster, models.Cluster,
fields='__all__', fields='__all__',
@ -114,7 +122,6 @@ class VMInterfaceType(IPAddressesMixin, ComponentType):
mac_address: str | None mac_address: str | None
parent: Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')] | None parent: Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')] | None
bridge: Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')] | None bridge: Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')] | None
virtual_machine: Annotated["VirtualMachineType", strawberry.lazy('virtualization.graphql.types')]
untagged_vlan: Annotated["VLANType", strawberry.lazy('ipam.graphql.types')] | None untagged_vlan: Annotated["VLANType", strawberry.lazy('ipam.graphql.types')] | None
vrf: Annotated["VRFType", strawberry.lazy('ipam.graphql.types')] | None vrf: Annotated["VRFType", strawberry.lazy('ipam.graphql.types')] | None
@ -141,4 +148,4 @@ class VMInterfaceType(IPAddressesMixin, ComponentType):
filters=VirtualDiskFilter filters=VirtualDiskFilter
) )
class VirtualDiskType(ComponentType): class VirtualDiskType(ComponentType):
virtual_machine: Annotated["VirtualMachineType", strawberry.lazy('virtualization.graphql.types')] pass