1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #1509: Extended cluster model to allow site assignment

This commit is contained in:
Jeremy Stretch
2017-09-22 12:53:09 -04:00
parent 4cfad2ef3b
commit 2ca161f3d8
9 changed files with 117 additions and 14 deletions

View File

@@ -921,6 +921,12 @@ class Device(CreatedUpdatedModel, CustomFieldModel):
'primary_ip6': "The specified IP address ({}) is not assigned to this device.".format(self.primary_ip6),
})
# A Device can only be assigned to a Cluster in the same Site (or no Site)
if self.cluster and self.cluster.site is not None and self.cluster.site != self.site:
raise ValidationError({
'cluster': "The assigned cluster belongs to a different site ({})".format(self.cluster.site)
})
def save(self, *args, **kwargs):
is_new = not bool(self.pk)