mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 08:38:16 -06:00
11960 Add airflow
This commit is contained in:
parent
f7fdfdd925
commit
4c9ba04f12
@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 5.0.7 on 2024-07-24 08:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('dcim', '0188_racktype'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='module',
|
||||||
|
name='airflow',
|
||||||
|
field=models.CharField(blank=True, max_length=50),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='rack',
|
||||||
|
name='airflow',
|
||||||
|
field=models.CharField(blank=True, max_length=50),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='racktype',
|
||||||
|
name='airflow',
|
||||||
|
field=models.CharField(blank=True, max_length=50),
|
||||||
|
),
|
||||||
|
]
|
@ -25,7 +25,7 @@ from netbox.models.features import ContactsMixin, ImageAttachmentsMixin
|
|||||||
from utilities.fields import ColorField, CounterCacheField, NaturalOrderingField
|
from utilities.fields import ColorField, CounterCacheField, NaturalOrderingField
|
||||||
from utilities.tracking import TrackingModelMixin
|
from utilities.tracking import TrackingModelMixin
|
||||||
from .device_components import *
|
from .device_components import *
|
||||||
from .mixins import RenderConfigMixin, WeightMixin
|
from .mixins import AirflowMixin, RenderConfigMixin, WeightMixin
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -58,7 +58,7 @@ class Manufacturer(ContactsMixin, OrganizationalModel):
|
|||||||
return reverse('dcim:manufacturer', args=[self.pk])
|
return reverse('dcim:manufacturer', args=[self.pk])
|
||||||
|
|
||||||
|
|
||||||
class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin, AirflowMixin):
|
||||||
"""
|
"""
|
||||||
A DeviceType represents a particular make (Manufacturer) and model of device. It specifies rack height and depth, as
|
A DeviceType represents a particular make (Manufacturer) and model of device. It specifies rack height and depth, as
|
||||||
well as high-level functional role(s).
|
well as high-level functional role(s).
|
||||||
@ -124,12 +124,6 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
|||||||
help_text=_('Parent devices house child devices in device bays. Leave blank '
|
help_text=_('Parent devices house child devices in device bays. Leave blank '
|
||||||
'if this device type is neither a parent nor a child.')
|
'if this device type is neither a parent nor a child.')
|
||||||
)
|
)
|
||||||
airflow = models.CharField(
|
|
||||||
verbose_name=_('airflow'),
|
|
||||||
max_length=50,
|
|
||||||
choices=DeviceAirflowChoices,
|
|
||||||
blank=True
|
|
||||||
)
|
|
||||||
front_image = models.ImageField(
|
front_image = models.ImageField(
|
||||||
upload_to='devicetype-images',
|
upload_to='devicetype-images',
|
||||||
blank=True
|
blank=True
|
||||||
@ -541,6 +535,7 @@ class Device(
|
|||||||
RenderConfigMixin,
|
RenderConfigMixin,
|
||||||
ConfigContextModel,
|
ConfigContextModel,
|
||||||
TrackingModelMixin,
|
TrackingModelMixin,
|
||||||
|
AirflowMixin,
|
||||||
PrimaryModel
|
PrimaryModel
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
@ -645,12 +640,6 @@ class Device(
|
|||||||
choices=DeviceStatusChoices,
|
choices=DeviceStatusChoices,
|
||||||
default=DeviceStatusChoices.STATUS_ACTIVE
|
default=DeviceStatusChoices.STATUS_ACTIVE
|
||||||
)
|
)
|
||||||
airflow = models.CharField(
|
|
||||||
verbose_name=_('airflow'),
|
|
||||||
max_length=50,
|
|
||||||
choices=DeviceAirflowChoices,
|
|
||||||
blank=True
|
|
||||||
)
|
|
||||||
primary_ip4 = models.OneToOneField(
|
primary_ip4 = models.OneToOneField(
|
||||||
to='ipam.IPAddress',
|
to='ipam.IPAddress',
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
@ -1131,7 +1120,7 @@ class Device(
|
|||||||
return round(total_weight / 1000, 2)
|
return round(total_weight / 1000, 2)
|
||||||
|
|
||||||
|
|
||||||
class Module(PrimaryModel, ConfigContextModel):
|
class Module(PrimaryModel, ConfigContextModel, AirflowMixin):
|
||||||
"""
|
"""
|
||||||
A Module represents a field-installable component within a Device which may itself hold multiple device components
|
A Module represents a field-installable component within a Device which may itself hold multiple device components
|
||||||
(for example, a line card within a chassis switch). Modules are instantiated from ModuleTypes.
|
(for example, a line card within a chassis switch). Modules are instantiated from ModuleTypes.
|
||||||
@ -1171,7 +1160,7 @@ class Module(PrimaryModel, ConfigContextModel):
|
|||||||
help_text=_('A unique tag used to identify this device')
|
help_text=_('A unique tag used to identify this device')
|
||||||
)
|
)
|
||||||
|
|
||||||
clone_fields = ('device', 'module_type', 'status')
|
clone_fields = ('device', 'module_type', 'status', 'airflow')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('module_bay',)
|
ordering = ('module_bay',)
|
||||||
|
@ -73,3 +73,15 @@ class RenderConfigMixin(models.Model):
|
|||||||
return self.role.config_template
|
return self.role.config_template
|
||||||
if self.platform and self.platform.config_template:
|
if self.platform and self.platform.config_template:
|
||||||
return self.platform.config_template
|
return self.platform.config_template
|
||||||
|
|
||||||
|
|
||||||
|
class AirflowMixin(models.Model):
|
||||||
|
airflow = models.CharField(
|
||||||
|
verbose_name=_('airflow'),
|
||||||
|
max_length=50,
|
||||||
|
choices=DeviceAirflowChoices,
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
@ -22,7 +22,7 @@ from utilities.data import array_to_string, drange
|
|||||||
from utilities.fields import ColorField, NaturalOrderingField
|
from utilities.fields import ColorField, NaturalOrderingField
|
||||||
from .device_components import PowerPort
|
from .device_components import PowerPort
|
||||||
from .devices import Device, Module
|
from .devices import Device, Module
|
||||||
from .mixins import WeightMixin
|
from .mixins import AirflowMixin, WeightMixin
|
||||||
from .power import PowerFeed
|
from .power import PowerFeed
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -37,7 +37,7 @@ __all__ = (
|
|||||||
# Rack Types
|
# Rack Types
|
||||||
#
|
#
|
||||||
|
|
||||||
class RackBase(WeightMixin, PrimaryModel):
|
class RackBase(WeightMixin, PrimaryModel, AirflowMixin):
|
||||||
"""
|
"""
|
||||||
Base class for RackType & Rack. Holds
|
Base class for RackType & Rack. Holds
|
||||||
"""
|
"""
|
||||||
@ -317,7 +317,7 @@ class Rack(ContactsMixin, ImageAttachmentsMixin, RackBase):
|
|||||||
|
|
||||||
clone_fields = (
|
clone_fields = (
|
||||||
'site', 'location', 'tenant', 'status', 'role', 'form_factor', 'width', 'u_height', 'desc_units', 'outer_width',
|
'site', 'location', 'tenant', 'status', 'role', 'form_factor', 'width', 'u_height', 'desc_units', 'outer_width',
|
||||||
'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit',
|
'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'airflow',
|
||||||
)
|
)
|
||||||
prerequisite_models = (
|
prerequisite_models = (
|
||||||
'dcim.Site',
|
'dcim.Site',
|
||||||
|
Loading…
Reference in New Issue
Block a user