Skip to content

Commit

Permalink
17614 Disallow removal of virtual chassis from device if set as master (
Browse files Browse the repository at this point in the history
#17731)

* 17614 Disallow removal of virtual chassis from device if set as master

* 17614 review changes

* 17614 review changes
  • Loading branch information
arthanson authored Oct 11, 2024
1 parent a964645 commit 9a655d8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions netbox/dcim/models/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,13 @@ def clean(self):
'vc_position': _("A device assigned to a virtual chassis must have its position defined.")
})

if hasattr(self, 'vc_master_for') and self.vc_master_for and self.vc_master_for != self.virtual_chassis:
raise ValidationError({
'virtual_chassis': _('Device cannot be removed from virtual chassis {virtual_chassis} because it is currently designated as its master.').format(
virtual_chassis=self.vc_master_for
)
})

def _instantiate_components(self, queryset, bulk_create=True):
"""
Instantiate components for the device from the specified component templates.
Expand Down

0 comments on commit 9a655d8

Please sign in to comment.