mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-31 04:46:26 -06:00
9604 updates
This commit is contained in:
parent
60f6bc3e88
commit
0e60a5de44
@ -21,13 +21,13 @@ Designates the termination as forming either the A or Z end of the circuit.
|
|||||||
|
|
||||||
If selected, the circuit termination will be considered "connected" even if no cable has been connected to it in NetBox.
|
If selected, the circuit termination will be considered "connected" even if no cable has been connected to it in NetBox.
|
||||||
|
|
||||||
### Site
|
### Scope
|
||||||
|
|
||||||
The [site](../dcim/site.md) with which this circuit termination is associated. Once created, a cable can be connected between the circuit termination and a device interface (or similar component).
|
The [region](../dcim/region.md), [site](../dcim/site.md) or [location](../dcim/location.md) with which this circuit termination is associated. Once created, a cable can be connected between the circuit termination and a device interface (or similar component).
|
||||||
|
|
||||||
### Provider Network
|
### Provider Network
|
||||||
|
|
||||||
Circuits which do not connect to a site modeled by NetBox can instead be terminated to a [provider network](./providernetwork.md) representing an unknown network operated by a [provider](./provider.md).
|
Circuits which do not connect to a scope modeled by NetBox can instead be terminated to a [provider network](./providernetwork.md) representing an unknown network operated by a [provider](./provider.md).
|
||||||
|
|
||||||
### Port Speed
|
### Port Speed
|
||||||
|
|
||||||
|
@ -339,10 +339,35 @@ class CircuitTermination(
|
|||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
# Must define either site *or* provider network
|
# Must define either site *or* provider network
|
||||||
if self.site is None and self.provider_network is None:
|
if self.scope is None and self.provider_network is None:
|
||||||
raise ValidationError(_("A circuit termination must attach to either a site or a provider network."))
|
raise ValidationError(_("A circuit termination must attach to either a scope or a provider network."))
|
||||||
if self.site and self.provider_network:
|
if self.scope and self.provider_network:
|
||||||
raise ValidationError(_("A circuit termination cannot attach to both a site and a provider network."))
|
raise ValidationError(_("A circuit termination cannot attach to both a scope and a provider network."))
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
# Cache objects associated with the terminating object (for filtering)
|
||||||
|
self.cache_related_objects()
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def cache_related_objects(self):
|
||||||
|
self._region = self._sitegroup = self._site = self._location = None
|
||||||
|
if self.scope_type:
|
||||||
|
scope_type = self.scope_type.model_class()
|
||||||
|
if scope_type == apps.get_model('dcim', 'region'):
|
||||||
|
self._region = self.scope
|
||||||
|
elif scope_type == apps.get_model('dcim', 'sitegroup'):
|
||||||
|
self._sitegroup = self.scope
|
||||||
|
elif scope_type == apps.get_model('dcim', 'site'):
|
||||||
|
self._region = self.scope.region
|
||||||
|
self._sitegroup = self.scope.group
|
||||||
|
self._site = self.scope
|
||||||
|
elif scope_type == apps.get_model('dcim', 'location'):
|
||||||
|
self._region = self.scope.site.region
|
||||||
|
self._sitegroup = self.scope.site.group
|
||||||
|
self._site = self.scope.site
|
||||||
|
self._location = self.scope
|
||||||
|
cache_related_objects.alters_data = True
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
objectchange = super().to_objectchange(action)
|
objectchange = super().to_objectchange(action)
|
||||||
|
Loading…
Reference in New Issue
Block a user