2021-06-25 15:31:43 -04:00
|
|
|
import graphene
|
|
|
|
|
|
|
|
from netbox.graphql.fields import ObjectField, ObjectListField
|
|
|
|
from .types import *
|
2023-03-23 05:42:18 -07:00
|
|
|
from utilities.graphql_optimizer import gql_query_optimizer
|
|
|
|
from virtualization import models
|
2021-06-25 15:31:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
class VirtualizationQuery(graphene.ObjectType):
|
|
|
|
cluster = ObjectField(ClusterType)
|
2021-06-30 09:57:33 -04:00
|
|
|
cluster_list = ObjectListField(ClusterType)
|
2021-06-25 15:31:43 -04:00
|
|
|
|
2023-03-23 05:42:18 -07:00
|
|
|
def resolve_cluster_list(root, info, **kwargs):
|
|
|
|
return gql_query_optimizer(models.Cluster.objects.all(), info)
|
|
|
|
|
2021-06-25 15:31:43 -04:00
|
|
|
cluster_group = ObjectField(ClusterGroupType)
|
2021-06-30 09:57:33 -04:00
|
|
|
cluster_group_list = ObjectListField(ClusterGroupType)
|
2021-06-25 15:31:43 -04:00
|
|
|
|
2023-03-23 05:42:18 -07:00
|
|
|
def resolve_cluster_group_list(root, info, **kwargs):
|
|
|
|
return gql_query_optimizer(models.ClusterGroup.objects.all(), info)
|
|
|
|
|
2021-06-25 15:31:43 -04:00
|
|
|
cluster_type = ObjectField(ClusterTypeType)
|
2021-06-30 09:57:33 -04:00
|
|
|
cluster_type_list = ObjectListField(ClusterTypeType)
|
2021-06-25 15:31:43 -04:00
|
|
|
|
2023-03-23 05:42:18 -07:00
|
|
|
def resolve_cluster_type_list(root, info, **kwargs):
|
|
|
|
return gql_query_optimizer(models.ClusterType.objects.all(), info)
|
|
|
|
|
2021-06-25 15:31:43 -04:00
|
|
|
virtual_machine = ObjectField(VirtualMachineType)
|
2021-06-30 09:57:33 -04:00
|
|
|
virtual_machine_list = ObjectListField(VirtualMachineType)
|
2021-06-25 15:31:43 -04:00
|
|
|
|
2023-03-23 05:42:18 -07:00
|
|
|
def resolve_virtual_machine_list(root, info, **kwargs):
|
|
|
|
return gql_query_optimizer(models.VirtualMachine.objects.all(), info)
|
|
|
|
|
2021-06-25 15:31:43 -04:00
|
|
|
vm_interface = ObjectField(VMInterfaceType)
|
2021-06-30 09:57:33 -04:00
|
|
|
vm_interface_list = ObjectListField(VMInterfaceType)
|
2023-03-23 05:42:18 -07:00
|
|
|
|
|
|
|
def resolve_vm_interface_list(root, info, **kwargs):
|
|
|
|
return gql_query_optimizer(models.VMInterface.objects.all(), info)
|