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