Skip to content

Changing a site's region does not change the circuit or circuit-termination region #20140

@rfdrake

Description

@rfdrake

Deployment Type

Self-hosted

NetBox Version

v4.3.6

Python Version

3.12

Steps to Reproduce

  1. Edit a site and change it's region from one place to another
  2. Check and see that circuits and circuit-terminations are still showing for that site in the old region

I have tested this on my local instance and on the demo instance. Both with a GUI move and a pynetbox move. Afterwords, I tried a manage.py reindex, restarting netbox, and various other commands to see if I could force it to update.

Finally I tried writing this script to change the region on all the circuits. It didn't work.

region_name = 'Old region'
for circuit in nb.circuits.circuits.filter(region=slugify(region_name)):
        for side in [ circuit.termination_a, circuit.termination_z ]:
           if side and re.search(r'/sites/', side.termination.url):
                term = nb.circuits.circuit_terminations.get(id=side.id)
                site = nb.dcim.sites.get(id=side.termination_id)
                print(f"Moving {circuit} from {region_name} to {site.region}")
                term.region = site.region
                term.save()
                circuit.region = site.region
                circuit.save()

But, as a workaround, this does work:

region_name = 'Old region'
for circuit in nb.circuits.circuits.filter(region=slugify(region_name)):
        for side in [ circuit.termination_a, circuit.termination_z ]:
           if side and re.search(r'/sites/', side.termination.url):
                term = nb.circuits.circuit_terminations.get(id=side.id)
                old_desc = term.description
                term.description = 'z'
                term.save()
                term.description = old_desc
                term.save()    

Expected Behavior

Circuits and circuit terminations should update when the site updates. I recognize this is super rare for most people. Even I don't move sites around much, but sometimes I need to expand the hierarchy to add something more specific, like if a site is tagged as "USA" and we decide to put it in "DC" because that is where it actually is.

Observed Behavior

Circuits just won't move regions.

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions