|
@@ -22,6 +22,7 @@ from netbox.config import ConfigItem
|
|
|
from netbox.models import OrganizationalModel, PrimaryModel
|
|
from netbox.models import OrganizationalModel, PrimaryModel
|
|
|
from utilities.choices import ColorChoices
|
|
from utilities.choices import ColorChoices
|
|
|
from utilities.fields import ColorField, CounterCacheField, NaturalOrderingField
|
|
from utilities.fields import ColorField, CounterCacheField, NaturalOrderingField
|
|
|
|
|
+from utilities.tracking import TrackingModelMixin
|
|
|
from .device_components import *
|
|
from .device_components import *
|
|
|
from .mixins import WeightMixin
|
|
from .mixins import WeightMixin
|
|
|
|
|
|
|
@@ -469,7 +470,7 @@ def update_interface_bridges(device, interface_templates, module=None):
|
|
|
interface.save()
|
|
interface.save()
|
|
|
|
|
|
|
|
|
|
|
|
|
-class Device(PrimaryModel, ConfigContextModel):
|
|
|
|
|
|
|
+class Device(PrimaryModel, ConfigContextModel, TrackingModelMixin):
|
|
|
"""
|
|
"""
|
|
|
A Device represents a piece of physical hardware mounted within a Rack. Each Device is assigned a DeviceType,
|
|
A Device represents a piece of physical hardware mounted within a Rack. Each Device is assigned a DeviceType,
|
|
|
DeviceRole, and (optionally) a Platform. Device names are not required, however if one is set it must be unique.
|
|
DeviceRole, and (optionally) a Platform. Device names are not required, however if one is set it must be unique.
|
|
@@ -1206,6 +1207,12 @@ class VirtualChassis(PrimaryModel):
|
|
|
blank=True
|
|
blank=True
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ # Counter fields
|
|
|
|
|
+ member_count = CounterCacheField(
|
|
|
|
|
+ to_model='dcim.Device',
|
|
|
|
|
+ to_field='virtual_chassis'
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
class Meta:
|
|
class Meta:
|
|
|
ordering = ['name']
|
|
ordering = ['name']
|
|
|
verbose_name_plural = 'virtual chassis'
|
|
verbose_name_plural = 'virtual chassis'
|