mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
9856 virtualization, vpn, wireless schema
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from strawberry import auto
|
||||
from virtualization import models, filtersets
|
||||
from netbox.graphql import filters
|
||||
|
||||
|
||||
__all__ = (
|
||||
'ClusterFilter',
|
||||
'ClusterGroupFilter',
|
||||
'ClusterTypeFilter',
|
||||
'VirtualMachineFilter',
|
||||
'VMInterfaceFilter',
|
||||
'VirtualDiskFilter',
|
||||
)
|
||||
|
||||
|
||||
@strawberry_django.filter(models.Cluster, lookups=True)
|
||||
class ClusterFilter(filtersets.ClusterFilterSet):
|
||||
id: auto
|
||||
|
||||
|
||||
@strawberry_django.filter(models.ClusterGroup, lookups=True)
|
||||
class ClusterGroupFilter(filtersets.ClusterGroupFilterSet):
|
||||
id: auto
|
||||
|
||||
|
||||
@strawberry_django.filter(models.ClusterType, lookups=True)
|
||||
class ClusterTypeFilter(filtersets.ClusterTypeFilterSet):
|
||||
id: auto
|
||||
|
||||
|
||||
@strawberry_django.filter(models.VirtualMachine, lookups=True)
|
||||
class VirtualMachineFilter(filtersets.VirtualMachineFilterSet):
|
||||
id: auto
|
||||
|
||||
|
||||
@strawberry_django.filter(models.VMInterface, lookups=True)
|
||||
class VMInterfaceFilter(filtersets.VMInterfaceFilterSet):
|
||||
id: auto
|
||||
|
||||
|
||||
@strawberry_django.filter(models.VirtualDisk, lookups=True)
|
||||
class VirtualDiskFilter(filtersets.VirtualDiskFilterSet):
|
||||
id: auto
|
||||
|
||||
@@ -1,44 +1,27 @@
|
||||
import graphene
|
||||
from typing import List
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from netbox.graphql.fields import ObjectField, ObjectListField
|
||||
from .types import *
|
||||
from utilities.graphql_optimizer import gql_query_optimizer
|
||||
from virtualization import models
|
||||
from .types import *
|
||||
|
||||
|
||||
class VirtualizationQuery(graphene.ObjectType):
|
||||
cluster = ObjectField(ClusterType)
|
||||
cluster_list = ObjectListField(ClusterType)
|
||||
@strawberry.type
|
||||
class VirtualizationQuery:
|
||||
cluster: ClusterType = strawberry_django.field()
|
||||
cluster_list: List[ClusterType] = strawberry_django.field()
|
||||
|
||||
def resolve_cluster_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.Cluster.objects.all(), info)
|
||||
cluster_group: ClusterGroupType = strawberry_django.field()
|
||||
cluster_group_list: List[ClusterGroupType] = strawberry_django.field()
|
||||
|
||||
cluster_group = ObjectField(ClusterGroupType)
|
||||
cluster_group_list = ObjectListField(ClusterGroupType)
|
||||
cluster_type: ClusterTypeType = strawberry_django.field()
|
||||
cluster_type_list: List[ClusterTypeType] = strawberry_django.field()
|
||||
|
||||
def resolve_cluster_group_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.ClusterGroup.objects.all(), info)
|
||||
virtual_machine: VirtualMachineType = strawberry_django.field()
|
||||
virtual_machine_list: List[VirtualMachineType] = strawberry_django.field()
|
||||
|
||||
cluster_type = ObjectField(ClusterTypeType)
|
||||
cluster_type_list = ObjectListField(ClusterTypeType)
|
||||
vm_interface: VMInterfaceType = strawberry_django.field()
|
||||
vm_interface_list: List[VMInterfaceType] = strawberry_django.field()
|
||||
|
||||
def resolve_cluster_type_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.ClusterType.objects.all(), info)
|
||||
|
||||
virtual_machine = ObjectField(VirtualMachineType)
|
||||
virtual_machine_list = ObjectListField(VirtualMachineType)
|
||||
|
||||
def resolve_virtual_machine_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.VirtualMachine.objects.all(), info)
|
||||
|
||||
vm_interface = ObjectField(VMInterfaceType)
|
||||
vm_interface_list = ObjectListField(VMInterfaceType)
|
||||
|
||||
def resolve_vm_interface_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.VMInterface.objects.all(), info)
|
||||
|
||||
virtual_disk = ObjectField(VirtualDiskType)
|
||||
virtual_disk_list = ObjectListField(VirtualDiskType)
|
||||
|
||||
def resolve_virtual_disk_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.VirtualDisk.objects.all(), info)
|
||||
virtual_disk: VirtualDiskType = strawberry_django.field()
|
||||
virtual_disk_list: List[VirtualDiskType] = strawberry_django.field()
|
||||
|
||||
@@ -47,7 +47,8 @@ class ClusterTypeType(OrganizationalObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.VirtualMachine,
|
||||
fields='__all__',
|
||||
# fields='__all__',
|
||||
exclude=('_name', 'interface_count', 'virtual_disk_count',), # bug - temp
|
||||
filters=VirtualMachineFilter
|
||||
)
|
||||
class VirtualMachineType(ConfigContextMixin, NetBoxObjectType):
|
||||
@@ -56,7 +57,8 @@ class VirtualMachineType(ConfigContextMixin, NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.VMInterface,
|
||||
fields='__all__',
|
||||
# fields='__all__',
|
||||
exclude=('mac_address', '_name',), # bug - temp
|
||||
filters=VMInterfaceFilter
|
||||
)
|
||||
class VMInterfaceType(IPAddressesMixin, ComponentObjectType):
|
||||
@@ -67,7 +69,8 @@ class VMInterfaceType(IPAddressesMixin, ComponentObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.VirtualDisk,
|
||||
fields='__all__',
|
||||
# fields='__all__',
|
||||
exclude=('_name',), # bug - temp
|
||||
filters=VirtualDiskFilter
|
||||
)
|
||||
class VirtualDiskType(ComponentObjectType):
|
||||
|
||||
Reference in New Issue
Block a user