Arthur hace 1 semana
padre
commit
e7cde810a8

+ 32 - 0
netbox/dcim/migrations/0242_cooling_denormalization_triggers.py

@@ -0,0 +1,32 @@
+"""
+Install denormalized device → component triggers for the cooling device components (CoolingPort,
+CoolingOutlet), mirroring the triggers created for the other device components in migration 0239.
+"""
+from django.db import migrations
+
+from utilities.migration import InstallDenormalizationTrigger
+
+# Cooling device component tables carrying _site/_location/_rack denormalized from their parent Device.
+COMPONENT_TABLES = (
+    'dcim_coolingport',
+    'dcim_coolingoutlet',
+)
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('dcim', '0241_device_cooling_method_device_cooling_outlet_count_and_more'),
+    ]
+
+    operations = [
+        *[
+            InstallDenormalizationTrigger(
+                dependent_table=table,
+                source_table='dcim_device',
+                fk_column='device_id',
+                mappings={'_site_id': 'site_id', '_location_id': 'location_id', '_rack_id': 'rack_id'},
+            )
+            for table in COMPONENT_TABLES
+        ],
+    ]

+ 20 - 0
netbox/dcim/tests/test_tables.py

@@ -191,6 +191,26 @@ class PowerFeedTableTestCase(TableTestCases.StandardTableTestCase):
     table = PowerFeedTable
 
 
+#
+# Cooling
+#
+
+class CoolingSourceTableTestCase(TableTestCases.StandardTableTestCase):
+    table = CoolingSourceTable
+
+
+class CoolingFeedTableTestCase(TableTestCases.StandardTableTestCase):
+    table = CoolingFeedTable
+
+
+class CoolingPortTableTestCase(TableTestCases.StandardTableTestCase):
+    table = CoolingPortTable
+
+
+class CoolingOutletTableTestCase(TableTestCases.StandardTableTestCase):
+    table = CoolingOutletTable
+
+
 #
 # Virtual chassis
 #