feat: support partial-width rack devices
This commit is contained in:
@@ -46,3 +46,36 @@ class UtilitiesSettings(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return "NetBox Utilities settings"
|
||||
|
||||
|
||||
class DeviceRackPlacement(models.Model):
|
||||
WIDTH_CHOICES = (
|
||||
(2, "1/2 Rackbreite"),
|
||||
(3, "1/3 Rackbreite"),
|
||||
(4, "1/4 Rackbreite"),
|
||||
)
|
||||
|
||||
device = models.OneToOneField(
|
||||
"dcim.Device",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="netbox_utilities_rack_placement",
|
||||
)
|
||||
width = models.PositiveSmallIntegerField(choices=WIDTH_CHOICES)
|
||||
horizontal_position = models.PositiveSmallIntegerField(
|
||||
validators=[MinValueValidator(1), MaxValueValidator(4)],
|
||||
help_text="Position von links innerhalb der Rackbreite.",
|
||||
)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
constraints = (
|
||||
models.CheckConstraint(
|
||||
condition=models.Q(width__gte=models.F("horizontal_position")),
|
||||
name="netbox_utilities_placement_position_within_width",
|
||||
),
|
||||
)
|
||||
verbose_name = "Gerätebreite im Rack"
|
||||
verbose_name_plural = "Gerätebreiten im Rack"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.device}: 1/{self.width}, Position {self.horizontal_position}"
|
||||
|
||||
Reference in New Issue
Block a user