mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-20 12:22:23 -06:00
Introduce ContactsMixin
This commit is contained in:
@@ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from dcim.models import Device
|
||||
from netbox.models import OrganizationalModel, PrimaryModel
|
||||
from netbox.models.features import ContactsMixin
|
||||
from virtualization.choices import *
|
||||
|
||||
__all__ = (
|
||||
@@ -28,20 +29,16 @@ class ClusterType(OrganizationalModel):
|
||||
return reverse('virtualization:clustertype', args=[self.pk])
|
||||
|
||||
|
||||
class ClusterGroup(OrganizationalModel):
|
||||
class ClusterGroup(ContactsMixin, OrganizationalModel):
|
||||
"""
|
||||
An organizational group of Clusters.
|
||||
"""
|
||||
# Generic relations
|
||||
vlan_groups = GenericRelation(
|
||||
to='ipam.VLANGroup',
|
||||
content_type_field='scope_type',
|
||||
object_id_field='scope_id',
|
||||
related_query_name='cluster_group'
|
||||
)
|
||||
contacts = GenericRelation(
|
||||
to='tenancy.ContactAssignment'
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ('name',)
|
||||
@@ -52,7 +49,7 @@ class ClusterGroup(OrganizationalModel):
|
||||
return reverse('virtualization:clustergroup', args=[self.pk])
|
||||
|
||||
|
||||
class Cluster(PrimaryModel):
|
||||
class Cluster(ContactsMixin, PrimaryModel):
|
||||
"""
|
||||
A cluster of VirtualMachines. Each Cluster may optionally be associated with one or more Devices.
|
||||
"""
|
||||
@@ -101,9 +98,6 @@ class Cluster(PrimaryModel):
|
||||
object_id_field='scope_id',
|
||||
related_query_name='cluster'
|
||||
)
|
||||
contacts = GenericRelation(
|
||||
to='tenancy.ContactAssignment'
|
||||
)
|
||||
|
||||
clone_fields = (
|
||||
'type', 'group', 'status', 'tenant', 'site',
|
||||
|
||||
@@ -12,6 +12,7 @@ from extras.models import ConfigContextModel
|
||||
from extras.querysets import ConfigContextModelQuerySet
|
||||
from netbox.config import get_config
|
||||
from netbox.models import NetBoxModel, PrimaryModel
|
||||
from netbox.models.features import ContactsMixin
|
||||
from utilities.fields import CounterCacheField, NaturalOrderingField
|
||||
from utilities.ordering import naturalize_interface
|
||||
from utilities.query_functions import CollateAsChar
|
||||
@@ -24,7 +25,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
class VirtualMachine(PrimaryModel, ConfigContextModel):
|
||||
class VirtualMachine(ContactsMixin, PrimaryModel, ConfigContextModel):
|
||||
"""
|
||||
A virtual machine which runs inside a Cluster.
|
||||
"""
|
||||
@@ -129,11 +130,6 @@ class VirtualMachine(PrimaryModel, ConfigContextModel):
|
||||
to_field='virtual_machine'
|
||||
)
|
||||
|
||||
# Generic relation
|
||||
contacts = GenericRelation(
|
||||
to='tenancy.ContactAssignment'
|
||||
)
|
||||
|
||||
objects = ConfigContextModelQuerySet.as_manager()
|
||||
|
||||
clone_fields = (
|
||||
|
||||
Reference in New Issue
Block a user