nautobot 1.6.24__py3-none-any.whl → 1.6.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nautobot/dcim/models/devices.py +10 -3
- nautobot/dcim/tests/test_models.py +74 -0
- nautobot/project-static/docs/release-notes/version-1.6.html +231 -123
- nautobot/project-static/docs/search/search_index.json +1 -1
- nautobot/project-static/docs/sitemap.xml +187 -187
- nautobot/project-static/docs/sitemap.xml.gz +0 -0
- {nautobot-1.6.24.dist-info → nautobot-1.6.26.dist-info}/METADATA +1 -1
- {nautobot-1.6.24.dist-info → nautobot-1.6.26.dist-info}/RECORD +12 -12
- {nautobot-1.6.24.dist-info → nautobot-1.6.26.dist-info}/LICENSE.txt +0 -0
- {nautobot-1.6.24.dist-info → nautobot-1.6.26.dist-info}/NOTICE +0 -0
- {nautobot-1.6.24.dist-info → nautobot-1.6.26.dist-info}/WHEEL +0 -0
- {nautobot-1.6.24.dist-info → nautobot-1.6.26.dist-info}/entry_points.txt +0 -0
nautobot/dcim/models/devices.py
CHANGED
|
@@ -842,9 +842,16 @@ class Device(PrimaryModel, ConfigContextModel, StatusModel):
|
|
|
842
842
|
# Update Site and Rack assignment for any child Devices
|
|
843
843
|
devices = Device.objects.filter(parent_bay__device=self)
|
|
844
844
|
for device in devices:
|
|
845
|
-
|
|
846
|
-
device.
|
|
847
|
-
|
|
845
|
+
save_child_device = False
|
|
846
|
+
if device.site != self.site:
|
|
847
|
+
device.site = self.site
|
|
848
|
+
save_child_device = True
|
|
849
|
+
if device.rack != self.rack:
|
|
850
|
+
device.rack = self.rack
|
|
851
|
+
save_child_device = True
|
|
852
|
+
|
|
853
|
+
if save_child_device:
|
|
854
|
+
device.save()
|
|
848
855
|
|
|
849
856
|
def create_components(self):
|
|
850
857
|
"""Create device components from the device type definition."""
|
|
@@ -14,6 +14,7 @@ from nautobot.dcim.choices import (
|
|
|
14
14
|
InterfaceTypeChoices,
|
|
15
15
|
PortTypeChoices,
|
|
16
16
|
PowerOutletFeedLegChoices,
|
|
17
|
+
SubdeviceRoleChoices,
|
|
17
18
|
)
|
|
18
19
|
from nautobot.dcim.models import (
|
|
19
20
|
Cable,
|
|
@@ -925,6 +926,14 @@ class DeviceTestCase(TestCase):
|
|
|
925
926
|
manufacturer=manufacturer,
|
|
926
927
|
model="Test Device Type 1",
|
|
927
928
|
slug="test-device-type-1",
|
|
929
|
+
subdevice_role=SubdeviceRoleChoices.ROLE_PARENT,
|
|
930
|
+
)
|
|
931
|
+
self.child_devicetype = DeviceType.objects.create(
|
|
932
|
+
model="Child Device Type 1",
|
|
933
|
+
slug="child-device-type-1",
|
|
934
|
+
manufacturer=manufacturer,
|
|
935
|
+
subdevice_role=SubdeviceRoleChoices.ROLE_CHILD,
|
|
936
|
+
u_height=0,
|
|
928
937
|
)
|
|
929
938
|
self.device_role = DeviceRole.objects.create(
|
|
930
939
|
name="Test Device Role 1", slug="test-device-role-1", color="ff0000"
|
|
@@ -1164,6 +1173,71 @@ class DeviceTestCase(TestCase):
|
|
|
1164
1173
|
):
|
|
1165
1174
|
d1.validated_save()
|
|
1166
1175
|
|
|
1176
|
+
def test_child_devices_are_not_saved_when_unnecessary(self):
|
|
1177
|
+
parent_device = Device.objects.create(
|
|
1178
|
+
name="Parent Device 1",
|
|
1179
|
+
site=self.site,
|
|
1180
|
+
device_type=self.device_type,
|
|
1181
|
+
device_role=self.device_role,
|
|
1182
|
+
status=self.device_status,
|
|
1183
|
+
)
|
|
1184
|
+
parent_device.validated_save()
|
|
1185
|
+
|
|
1186
|
+
child_device = Device.objects.create(
|
|
1187
|
+
name="Child Device 1",
|
|
1188
|
+
site=parent_device.site,
|
|
1189
|
+
device_type=self.child_devicetype,
|
|
1190
|
+
device_role=parent_device.device_role,
|
|
1191
|
+
status=self.device_status,
|
|
1192
|
+
)
|
|
1193
|
+
child_device.validated_save()
|
|
1194
|
+
child_mtime_before_parent_saved = str(child_device.last_updated)
|
|
1195
|
+
|
|
1196
|
+
devicebay = DeviceBay.objects.get(device=parent_device, name="Device Bay 1")
|
|
1197
|
+
devicebay.installed_device = child_device
|
|
1198
|
+
devicebay.validated_save()
|
|
1199
|
+
|
|
1200
|
+
#
|
|
1201
|
+
# Tests
|
|
1202
|
+
#
|
|
1203
|
+
|
|
1204
|
+
#
|
|
1205
|
+
# On a NOOP save, the child device shouldn't be updated
|
|
1206
|
+
parent_device.save()
|
|
1207
|
+
|
|
1208
|
+
child_mtime_after_parent_noop_save = str(Device.objects.get(name="Child Device 1").last_updated)
|
|
1209
|
+
|
|
1210
|
+
self.assertEqual(child_mtime_before_parent_saved, child_mtime_after_parent_noop_save)
|
|
1211
|
+
|
|
1212
|
+
#
|
|
1213
|
+
# On a serial number update, the child device shouldn't be updated
|
|
1214
|
+
parent_device.serial = "12345"
|
|
1215
|
+
parent_device.save()
|
|
1216
|
+
|
|
1217
|
+
child_mtime_after_parent_serial_update_save = str(Device.objects.get(name="Child Device 1").last_updated)
|
|
1218
|
+
|
|
1219
|
+
self.assertEqual(child_mtime_before_parent_saved, child_mtime_after_parent_serial_update_save)
|
|
1220
|
+
|
|
1221
|
+
#
|
|
1222
|
+
# If the parent rack updates, the child mtime should update.
|
|
1223
|
+
rack = Rack.objects.create(name="Rack 1", site=parent_device.site)
|
|
1224
|
+
parent_device.rack = rack
|
|
1225
|
+
parent_device.save()
|
|
1226
|
+
|
|
1227
|
+
child_mtime_after_parent_rack_update_save = str(Device.objects.get(name="Child Device 1").last_updated)
|
|
1228
|
+
|
|
1229
|
+
self.assertNotEqual(child_mtime_after_parent_noop_save, child_mtime_after_parent_rack_update_save)
|
|
1230
|
+
|
|
1231
|
+
#
|
|
1232
|
+
# If the parent site updates, the child mtime should update
|
|
1233
|
+
site = Site.objects.create(name="New Site 1")
|
|
1234
|
+
parent_device.site = site
|
|
1235
|
+
parent_device.save()
|
|
1236
|
+
|
|
1237
|
+
child_mtime_after_parent_site_update_save = str(Device.objects.get(name="Child Device 1").last_updated)
|
|
1238
|
+
|
|
1239
|
+
self.assertNotEqual(child_mtime_after_parent_rack_update_save, child_mtime_after_parent_site_update_save)
|
|
1240
|
+
|
|
1167
1241
|
|
|
1168
1242
|
class CableTestCase(TestCase):
|
|
1169
1243
|
def setUp(self):
|