Arthur 1 vecka sedan
förälder
incheckning
2f0ca203e0

+ 7 - 5
netbox/dcim/forms/bulk_create.py

@@ -85,24 +85,26 @@ class PowerOutletBulkCreateForm(
 
 class CoolingPortBulkCreateForm(
     form_from_model(
-        CoolingPort, ['type', 'connector_type', 'diameter', 'maximum_flow', 'heat_capacity', 'mark_connected']
+        CoolingPort,
+        ['type', 'connector_type', 'diameter', 'diameter_unit', 'maximum_flow', 'heat_capacity', 'mark_connected']
     ),
     DeviceBulkAddComponentForm
 ):
     model = CoolingPort
     field_order = (
-        'name', 'label', 'type', 'connector_type', 'diameter', 'maximum_flow', 'heat_capacity', 'mark_connected',
-        'description', 'tags',
+        'name', 'label', 'type', 'connector_type', 'diameter', 'diameter_unit', 'maximum_flow', 'heat_capacity',
+        'mark_connected', 'description', 'tags',
     )
 
 
 class CoolingOutletBulkCreateForm(
-    form_from_model(CoolingOutlet, ['type', 'connector_type', 'diameter', 'color', 'mark_connected']),
+    form_from_model(CoolingOutlet, ['type', 'connector_type', 'diameter', 'diameter_unit', 'color', 'mark_connected']),
     DeviceBulkAddComponentForm
 ):
     model = CoolingOutlet
     field_order = (
-        'name', 'label', 'type', 'connector_type', 'diameter', 'color', 'mark_connected', 'description', 'tags',
+        'name', 'label', 'type', 'connector_type', 'diameter', 'diameter_unit', 'color', 'mark_connected',
+        'description', 'tags',
     )
 
 

+ 1 - 1
netbox/dcim/forms/bulk_edit.py

@@ -1122,7 +1122,7 @@ class CoolingSourceBulkEditForm(PrimaryModelBulkEditForm):
         ),
     )
     nullable_fields = (
-        'location', 'type', 'cooling_capacity', 'supply_temperature', 'return_temperature', 'description', 'comments',
+        'location', 'cooling_capacity', 'supply_temperature', 'return_temperature', 'description', 'comments',
     )
 
 

+ 2 - 0
netbox/dcim/graphql/enums.py

@@ -43,6 +43,7 @@ __all__ = (
     'PowerPortTypeEnum',
     'PressureUnitEnum',
     'RackAirflowEnum',
+    'RackCoolingCapabilityEnum',
     'RackDimensionUnitEnum',
     'RackFormFactorEnum',
     'RackReservationStatusEnum',
@@ -93,6 +94,7 @@ PowerOutletTypeEnum = strawberry.enum(PowerOutletTypeChoices.as_enum(prefix='typ
 PowerPortTypeEnum = strawberry.enum(PowerPortTypeChoices.as_enum(prefix='type'))
 PressureUnitEnum = strawberry.enum(PressureUnitChoices.as_enum(prefix='unit'))
 RackAirflowEnum = strawberry.enum(RackAirflowChoices.as_enum())
+RackCoolingCapabilityEnum = strawberry.enum(RackCoolingCapabilityChoices.as_enum())
 RackDimensionUnitEnum = strawberry.enum(RackDimensionUnitChoices.as_enum(prefix='unit'))
 RackFormFactorEnum = strawberry.enum(RackFormFactorChoices.as_enum(prefix='type'))
 RackReservationStatusEnum = strawberry.enum(RackReservationStatusChoices.as_enum(prefix='status'))

+ 7 - 1
netbox/dcim/graphql/filter_mixins.py

@@ -14,7 +14,7 @@ if TYPE_CHECKING:
     from dcim.graphql.filters import LocationFilter, RegionFilter, SiteFilter, SiteGroupFilter
     from extras.graphql.filters import ConfigTemplateFilter
     from ipam.graphql.filters import VLANFilter, VLANTranslationPolicyFilter
-    from netbox.graphql.filter_lookups import IntegerLookup
+    from netbox.graphql.filter_lookups import FloatLookup, IntegerLookup
 
     from .filters import *
 
@@ -177,3 +177,9 @@ class RackFilterMixin:
     max_weight: Annotated['IntegerLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
         strawberry_django.filter_field()
     )
+    cooling_capability: (
+        BaseFilterLookup[Annotated['RackCoolingCapabilityEnum', strawberry.lazy('dcim.graphql.enums')]] | None
+    ) = strawberry_django.filter_field()
+    cooling_capacity: Annotated['FloatLookup', strawberry.lazy('netbox.graphql.filter_lookups')] | None = (
+        strawberry_django.filter_field()
+    )

+ 10 - 0
netbox/dcim/graphql/filters.py

@@ -254,6 +254,9 @@ class DeviceFilter(
     airflow: BaseFilterLookup[Annotated['DeviceAirflowEnum', strawberry.lazy('dcim.graphql.enums')]] | None = (
         strawberry_django.filter_field()
     )
+    cooling_method: BaseFilterLookup[Annotated['CoolingMethodEnum', strawberry.lazy('dcim.graphql.enums')]] | None = (
+        strawberry_django.filter_field()
+    )
     primary_ip4: Annotated['IPAddressFilter', strawberry.lazy('ipam.graphql.filters')] | None = (
         strawberry_django.filter_field()
     )
@@ -397,6 +400,9 @@ class DeviceTypeFilter(ImageAttachmentFilterMixin, WeightFilterMixin, PrimaryMod
     airflow: BaseFilterLookup[Annotated['DeviceAirflowEnum', strawberry.lazy('dcim.graphql.enums')]] | None = (
         strawberry_django.filter_field()
     )
+    cooling_method: BaseFilterLookup[Annotated['CoolingMethodEnum', strawberry.lazy('dcim.graphql.enums')]] | None = (
+        strawberry_django.filter_field()
+    )
     front_image: Annotated['ImageAttachmentFilter', strawberry.lazy('extras.graphql.filters')] | None = (
         strawberry_django.filter_field()
     )
@@ -787,6 +793,9 @@ class ModuleTypeFilter(ImageAttachmentFilterMixin, WeightFilterMixin, PrimaryMod
     airflow: BaseFilterLookup[Annotated['ModuleAirflowEnum', strawberry.lazy('dcim.graphql.enums')]] | None = (
         strawberry_django.filter_field()
     )
+    cooling_method: BaseFilterLookup[Annotated['CoolingMethodEnum', strawberry.lazy('dcim.graphql.enums')]] | None = (
+        strawberry_django.filter_field()
+    )
     consoleporttemplates: Annotated['ConsolePortTemplateFilter', strawberry.lazy('dcim.graphql.filters')] | None = (
         strawberry_django.filter_field(name='console_port_templates')
     )
@@ -1154,6 +1163,7 @@ class RackFilter(
     airflow: BaseFilterLookup[Annotated['RackAirflowEnum', strawberry.lazy('dcim.graphql.enums')]] | None = (
         strawberry_django.filter_field()
     )
+    has_rdhx: FilterLookup[bool] | None = strawberry_django.filter_field()
     vlan_groups: Annotated['VLANGroupFilter', strawberry.lazy('ipam.graphql.filters')] | None = (
         strawberry_django.filter_field()
     )

+ 1 - 1
netbox/netbox/models/mixins.py

@@ -127,7 +127,7 @@ class DiameterMixin(models.Model):
         super().clean()
 
         # Validate diameter and diameter_unit
-        if self.diameter and not self.diameter_unit:
+        if self.diameter is not None and not self.diameter_unit:
             raise ValidationError(_("Must specify a unit when setting a diameter"))
 
 

+ 1 - 1
netbox/utilities/conversion.py

@@ -167,7 +167,7 @@ def to_millimeters(diameter, unit) -> Decimal:
     if unit == DiameterUnitChoices.UNIT_CENTIMETER:
         return round(Decimal(diameter * 10), 4)
     if unit == DiameterUnitChoices.UNIT_INCH:
-        return round(diameter * Decimal(25.4), 4)
+        return round(diameter * Decimal('25.4'), 4)
     raise ValueError(
         _("Unknown unit {unit}. Must be one of the following: {valid_units}").format(
             unit=unit,