Bulk migrating patched cables from one device to another

88 views
Skip to first unread message

Christian Strauf

unread,
Jan 6, 2021, 1:01:41 AM1/6/21
to NetBox
Hi all!

I have a question regarding the migration of patches in interfaces of a switch unit that go to front ports (or other switches for that matter) to a different, new switch. Here's a detailed description of the scenario that we want to address:

- We have a 48 port workgroup switch in a rack. Its interfaces are mostly connected to front ports of patch panels via cables in NetBox. The switch needs to be replaced by a new 48 port switch.
- What we would like to do is this:
- Integrate the new switch as an unracked device for the rack where the old switch is racked.
- Move all patches of the old switch to the new switch 1:1 (e.g. move the cable plugged into old-1/1 to new-1/1 etc.) in NetBox.
- Remove the old switch from the rack in NetBox and put the new switch in its place instead.

I've looked at the docs and functions and I haven't seen any other way than writing a custom script to do this -- or have I missed something? If yes, I'd be thankful if you could point me in the right direction. Thanks!

Christian

Brian Candler

unread,
Jan 6, 2021, 5:04:09 AM1/6/21
to NetBox
You're correct. Moving cable endpoints is not possible in the GUI - you have to delete them and recreate them, and there's no bulk facility for this.

I'm not sure if it's possible via the API to modify a cable endpoint, but at worst you'd read, delete, and re-create.

You certainly shouldn't do it via direct SQL updates, because as of Netbox v2.10 there's a separate model for cable paths which would become invalid.

Christian Strauf

unread,
Jan 6, 2021, 5:18:42 AM1/6/21
to NetBox
Hi Brian!

> You're correct. Moving cable endpoints is not possible in the GUI - you have to delete them and recreate them, and there's no bulk facility for this.
Thanks for the confirmation, that's what I thought.

> I'm not sure if it's possible via the API to modify a cable endpoint, but at worst you'd read, delete, and re-create.
I'll have a look at it, I'm not entirely sure if it will work.

> You certainly shouldn't do it via direct SQL updates, because as of Netbox v2.10 there's a separate model for cable paths which would become invalid.
No, I completely agree with you, I don't plan to do it that way because that is prone to breaking with NetBox updates. My thinking was more in the lines of using official scripting calls in the scripting engine so that you get a nice integration in the GUI. I'm afraid that migrating patches between switches is quite a standard lifecycle process at our facility so it makes sense to integrate it via custom script. Or would you say that it would make sense to open a feature request for it?

Christian

Christian Strauf

unread,
Jan 6, 2021, 6:56:48 AM1/6/21
to Christopher Mills, NetBox
> Is there any reason not to simply modify the attributes of the current device to match the new? If you are planning on removing it anyway?
We thought that through but the switch "keeps living" in NetBox for a while after being pulled from that particular rack where the new switch will reside so we would lose the information stored in NB for that switch.

> Just change the name, asset tag, type, IP address etc as needed and add/delete/rename any interfaces if they aren’t the same on the new device as the old? Cables are more onerous to delete and recreate than it is to update the switch details. If you want to keep the old switch in the rack (unracked or at another U, duplicate it first).
Since we switch vendors from time to time, reworking the old switch to match the device type for a new vendor is quite a big deal (we use Ansible to read configuration data from NB so it's essential that interface names etc. are correct). But I've looked at the API and I see a chance to patch the termination_a and/or termination_b data of a cable via said API. I'm in the progress of writing a Python script to achieve that. I'll try to write it in a way that I can change it from being an API script to being a custom script because I think that it makes sense to have this functionality in the NB GUI.

Christian

Christopher Mills

unread,
Jan 6, 2021, 7:14:46 AM1/6/21
to Christian Strauf, NetBox
For what it is worth, I believe the capability to ‘move’ cable connections has been raised as an FR but was blocked by some fundamental challenges to make that happen. It might be worth digging through the GitHub issues tracker and seeing if you can find it, then adding your use-case to strengthen that. In the meantime, the API, Pynetbox or the NetBox Ansible Modules are likely your best bet.

Sent from my iPhone

> On 6 Jan 2021, at 11:56, Christian Strauf <rzcs...@googlemail.com> wrote:
>
> 

Christian Strauf

unread,
Jan 6, 2021, 7:16:26 AM1/6/21
to Christopher Mills, NetBox
> For what it is worth, I believe the capability to ‘move’ cable connections has been raised as an FR but was blocked by some fundamental challenges to make that happen. It might be worth digging through the GitHub issues tracker and seeing if you can find it, then adding your use-case to strengthen that.
Thanks for the hint. I'll have a look.

> In the meantime, the API, Pynetbox or the NetBox Ansible Modules are likely your best bet.
Yes, I agree. I'll give it a try.

Cheers,
Christian

Christian Strauf

unread,
Jan 7, 2021, 2:04:20 AM1/7/21
to Brian Candler, NetBox
Hi Brian!

> I'm not sure if it's possible via the API to modify a cable endpoint, but at worst you'd read, delete, and re-create.
Unfortunately it isn't possible:

------8<------8<------8<------8<------8<------8<------8<------

pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'termination_b': ['Cable termination points may not be modified. Delete and recreate the cable instead.']}

------8<------8<------8<------8<------8<------8<------8<------

So deleting and recreating the cable is what I'm going to do.

Christian

Christopher Mills

unread,
Jan 8, 2021, 4:22:07 PM1/8/21
to Christian Strauf, NetBox
Is there any reason not to simply modify the attributes of the current device to match the new? If you are planning on removing it anyway?

Just change the name, asset tag, type, IP address etc as needed and add/delete/rename any interfaces if they aren’t the same on the new device as the old? Cables are more onerous to delete and recreate than it is to update the switch details. If you want to keep the old switch in the rack (unracked or at another U, duplicate it first).

Sent from my iPhone

> On 6 Jan 2021, at 10:18, 'Christian Strauf' via NetBox <netbox-...@googlegroups.com> wrote:
>
> Hi Brian!
> --
> You received this message because you are subscribed to the Google Groups "NetBox" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/C58A6E31-06B7-4F02-B002-0B4CDAC5BA85%40googlemail.com.

Reply all
Reply to author
Forward
0 new messages