-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5212 from netbox-community/4900-cable-paths
#4900: New model for cable paths
- Loading branch information
Showing
66 changed files
with
2,591 additions
and
2,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import sys | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
def cache_cable_peers(apps, schema_editor): | ||
ContentType = apps.get_model('contenttypes', 'ContentType') | ||
Cable = apps.get_model('dcim', 'Cable') | ||
CircuitTermination = apps.get_model('circuits', 'CircuitTermination') | ||
|
||
if 'test' not in sys.argv: | ||
print(f"\n Updating circuit termination cable peers...", flush=True) | ||
ct = ContentType.objects.get_for_model(CircuitTermination) | ||
for cable in Cable.objects.filter(termination_a_type=ct): | ||
CircuitTermination.objects.filter(pk=cable.termination_a_id).update( | ||
_cable_peer_type_id=cable.termination_b_type_id, | ||
_cable_peer_id=cable.termination_b_id | ||
) | ||
for cable in Cable.objects.filter(termination_b_type=ct): | ||
CircuitTermination.objects.filter(pk=cable.termination_b_id).update( | ||
_cable_peer_type_id=cable.termination_a_type_id, | ||
_cable_peer_id=cable.termination_a_id | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('contenttypes', '0002_remove_content_type_name'), | ||
('circuits', '0020_custom_field_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='circuittermination', | ||
name='_cable_peer_id', | ||
field=models.PositiveIntegerField(blank=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='circuittermination', | ||
name='_cable_peer_type', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='contenttypes.contenttype'), | ||
), | ||
migrations.RunPython( | ||
code=cache_cable_peers, | ||
reverse_code=migrations.RunPython.noop | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dcim', '0121_cablepath'), | ||
('circuits', '0021_cache_cable_peer'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='circuittermination', | ||
name='_path', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dcim.cablepath'), | ||
), | ||
migrations.RemoveField( | ||
model_name='circuittermination', | ||
name='connected_endpoint', | ||
), | ||
migrations.RemoveField( | ||
model_name='circuittermination', | ||
name='connection_status', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.