mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Renamed Cable endpoints to terminations
This commit is contained in:
@@ -21,14 +21,14 @@ def console_connections_to_cables(apps, schema_editor):
|
||||
for consoleport in ConsolePort.objects.filter(connected_endpoint__isnull=False):
|
||||
c = Cable()
|
||||
# We have to assign GFK fields manually because we're inside a migration.
|
||||
c.endpoint_a_type = consoleport_type
|
||||
c.endpoint_a_id = consoleport.id
|
||||
c.endpoint_b_type = consoleserverport_type
|
||||
c.endpoint_b_id = consoleport.connected_endpoint_id
|
||||
c.termination_a_type = consoleport_type
|
||||
c.termination_a_id = consoleport.id
|
||||
c.termination_b_type = consoleserverport_type
|
||||
c.termination_b_id = consoleport.connected_endpoint_id
|
||||
c.connection_status = consoleport.connection_status
|
||||
c.save()
|
||||
|
||||
cable_count = Cable.objects.filter(endpoint_a_type=consoleport_type).count()
|
||||
cable_count = Cable.objects.filter(termination_a_type=consoleport_type).count()
|
||||
print("{} cables created".format(cable_count))
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ def power_connections_to_cables(apps, schema_editor):
|
||||
for powerport in PowerPort.objects.filter(connected_endpoint__isnull=False):
|
||||
c = Cable()
|
||||
# We have to assign GFK fields manually because we're inside a migration.
|
||||
c.endpoint_a_type = powerport_type
|
||||
c.endpoint_a_id = powerport.id
|
||||
c.endpoint_b_type = poweroutlet_type
|
||||
c.endpoint_b_id = powerport.connected_endpoint_id
|
||||
c.termination_a_type = powerport_type
|
||||
c.termination_a_id = powerport.id
|
||||
c.termination_b_type = poweroutlet_type
|
||||
c.termination_b_id = powerport.connected_endpoint_id
|
||||
c.connection_status = powerport.connection_status
|
||||
c.save()
|
||||
|
||||
cable_count = Cable.objects.filter(endpoint_a_type=powerport_type).count()
|
||||
cable_count = Cable.objects.filter(termination_a_type=powerport_type).count()
|
||||
print("{} cables created".format(cable_count))
|
||||
|
||||
|
||||
@@ -78,10 +78,10 @@ def interface_connections_to_cables(apps, schema_editor):
|
||||
for conn in InterfaceConnection.objects.all():
|
||||
c = Cable()
|
||||
# We have to assign GFK fields manually because we're inside a migration.
|
||||
c.endpoint_a_type = interface_type
|
||||
c.endpoint_a_id = conn.interface_a_id
|
||||
c.endpoint_b_type = interface_type
|
||||
c.endpoint_b_id = conn.interface_b_id
|
||||
c.termination_a_type = interface_type
|
||||
c.termination_a_id = conn.interface_a_id
|
||||
c.termination_b_type = interface_type
|
||||
c.termination_b_id = conn.interface_b_id
|
||||
c.connection_status = conn.connection_status
|
||||
c.save()
|
||||
|
||||
@@ -96,7 +96,7 @@ def interface_connections_to_cables(apps, schema_editor):
|
||||
connection_status=conn.connection_status
|
||||
)
|
||||
|
||||
cable_count = Cable.objects.filter(endpoint_a_type=interface_type).count()
|
||||
cable_count = Cable.objects.filter(termination_a_type=interface_type).count()
|
||||
print("{} cables created".format(cable_count))
|
||||
|
||||
|
||||
@@ -117,19 +117,19 @@ class Migration(migrations.Migration):
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False)),
|
||||
('created', models.DateField(auto_now_add=True, null=True)),
|
||||
('last_updated', models.DateTimeField(auto_now=True, null=True)),
|
||||
('endpoint_a_id', models.PositiveIntegerField()),
|
||||
('endpoint_b_id', models.PositiveIntegerField()),
|
||||
('termination_a_id', models.PositiveIntegerField()),
|
||||
('termination_b_id', models.PositiveIntegerField()),
|
||||
('type', models.PositiveSmallIntegerField(blank=True, null=True)),
|
||||
('status', models.BooleanField(default=True)),
|
||||
('label', models.CharField(blank=True, max_length=100)),
|
||||
('color', utilities.fields.ColorField(blank=True, max_length=6)),
|
||||
('endpoint_a_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontpanelport', 'rearpanelport']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')),
|
||||
('endpoint_b_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontpanelport', 'rearpanelport']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')),
|
||||
('termination_a_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontpanelport', 'rearpanelport']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')),
|
||||
('termination_b_type', models.ForeignKey(limit_choices_to={'model__in': ['consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontpanelport', 'rearpanelport']}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')),
|
||||
],
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='cable',
|
||||
unique_together={('endpoint_b_type', 'endpoint_b_id'), ('endpoint_a_type', 'endpoint_a_id')},
|
||||
unique_together={('termination_b_type', 'termination_b_id'), ('termination_a_type', 'termination_a_id')},
|
||||
),
|
||||
|
||||
# Alter console port models
|
||||
|
Reference in New Issue
Block a user