mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-13 19:18:16 -06:00
Improve trace data
This commit is contained in:
parent
72f4ded24e
commit
f469706c9c
@ -319,5 +319,6 @@ class CircuitTermination(CableTermination):
|
||||
return {
|
||||
**super().get_endpoint_attributes(),
|
||||
'cid': self.circuit.cid,
|
||||
'provider': self.circuit.provider.name,
|
||||
'site': self.site.name,
|
||||
}
|
||||
|
@ -102,7 +102,9 @@ def migration_get_endpoint_attributes(endpoint):
|
||||
|
||||
if endpoint.__class__.__name__ == 'CircuitTermination':
|
||||
attributes['cid'] = endpoint.circuit.cid
|
||||
attributes['provider'] = endpoint.circuit.provider.name
|
||||
attributes['site'] = endpoint.site.name
|
||||
attributes['site_slug'] = endpoint.site.slug
|
||||
elif endpoint.__class__.__name__ in ('Interface', 'FrontPort', 'RearPort'):
|
||||
attributes['name'] = endpoint.name
|
||||
|
||||
@ -172,39 +174,36 @@ def from_generic_connected_endpoint(apps, schema_editor):
|
||||
model_type = contenttype_model.objects.get_for_model(interface_model)
|
||||
for interface in interface_model.objects.using(db_alias).filter(connected_endpoint_type=model_type):
|
||||
try:
|
||||
interface._connected_interface_id = interface.connected_endpoint_id
|
||||
interface._connected_interface = interface_model.objects.get(pk=interface.connected_endpoint_id)
|
||||
interface.save()
|
||||
print(".", end='', flush=True)
|
||||
except interface_model.DoesNotExist:
|
||||
# Dangling generic foreign key
|
||||
pass
|
||||
|
||||
print(".", end='', flush=True)
|
||||
print("X", end='', flush=True)
|
||||
|
||||
print("\nReverting circuit termination endpoints in interfaces...", end='')
|
||||
|
||||
model_type = contenttype_model.objects.get_for_model(circuittermination_model)
|
||||
for interface in interface_model.objects.using(db_alias).filter(connected_endpoint_type=model_type):
|
||||
try:
|
||||
interface._connected_circuittermination_id = interface.connected_endpoint_id
|
||||
interface._connected_circuittermination = circuittermination_model.objects.get(pk=interface.connected_endpoint_id)
|
||||
interface.save()
|
||||
print(".", end='', flush=True)
|
||||
except circuittermination_model.DoesNotExist:
|
||||
# Dangling generic foreign key
|
||||
pass
|
||||
|
||||
print(".", end='', flush=True)
|
||||
print("X", end='', flush=True)
|
||||
|
||||
print("\nReverting circuit termination endpoints...", end='')
|
||||
|
||||
model_type = contenttype_model.objects.get_for_model(interface_model)
|
||||
for interface in circuittermination_model.objects.using(db_alias).filter(connected_endpoint_type=model_type):
|
||||
try:
|
||||
interface.old_connected_interface_id = interface.connected_endpoint_id
|
||||
interface.old_connected_interface = interface_model.objects.get(pk=interface.connected_endpoint_id)
|
||||
interface.save()
|
||||
print(".", end='', flush=True)
|
||||
except interface_model.DoesNotExist:
|
||||
# Dangling generic foreign key
|
||||
pass
|
||||
|
||||
print(".", end='', flush=True)
|
||||
print("X", end='', flush=True)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -2397,6 +2397,7 @@ class Interface(CableTermination, ComponentModel):
|
||||
'device': self.parent.display_name,
|
||||
'device_id': self.parent.pk,
|
||||
'site': self.parent.site.name,
|
||||
'site_slug': self.parent.site.slug,
|
||||
}
|
||||
|
||||
|
||||
@ -2480,6 +2481,7 @@ class FrontPort(CableTermination, ComponentModel):
|
||||
'device': self.parent.display_name,
|
||||
'device_id': self.parent.pk,
|
||||
'site': self.parent.site.name,
|
||||
'site_slug': self.parent.site.slug,
|
||||
}
|
||||
|
||||
|
||||
@ -2546,6 +2548,7 @@ class RearPort(CableTermination, ComponentModel):
|
||||
'device': self.parent.display_name,
|
||||
'device_id': self.parent.pk,
|
||||
'site': self.parent.site.name,
|
||||
'site_slug': self.parent.site.slug,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user