Skip to content

Commit 9a655d8

Browse files
authored
17614 Disallow removal of virtual chassis from device if set as master (#17731)
* 17614 Disallow removal of virtual chassis from device if set as master * 17614 review changes * 17614 review changes
1 parent a964645 commit 9a655d8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

netbox/dcim/models/devices.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,13 @@ def clean(self):
983983
'vc_position': _("A device assigned to a virtual chassis must have its position defined.")
984984
})
985985

986+
if hasattr(self, 'vc_master_for') and self.vc_master_for and self.vc_master_for != self.virtual_chassis:
987+
raise ValidationError({
988+
'virtual_chassis': _('Device cannot be removed from virtual chassis {virtual_chassis} because it is currently designated as its master.').format(
989+
virtual_chassis=self.vc_master_for
990+
)
991+
})
992+
986993
def _instantiate_components(self, queryset, bulk_create=True):
987994
"""
988995
Instantiate components for the device from the specified component templates.

0 commit comments

Comments
 (0)