adding patch panels and structured cabling

454 views
Skip to first unread message

Xav W

unread,
Sep 20, 2019, 6:49:35 AM9/20/19
to NetBox
I've seen a few posts on this topic and have attempted to follow the template of what others have done, but I'm not having much luck.

Using a fresh install of Netbox 2.6.3.

I've created the patch panels, with the associated front and rear ports. The structured cabling I want to add at this point is from the rear port of one patch panel to the rear port of another. I then attempt to create a cable with the following string:

side_a_device,side_a_type,side_a_name,side_b_device,side_b_type,side_b_name,label
pp1-1,rearport,1,pp2-1,rearport,1,et0000001

but when I do so, I get an error message:

<class 'dcim.models.Cable.termination_a_type.RelatedObjectDoesNotExist'>
Cable has no termination_a_type.

Having looked at similar topic discussions, I don't think I'm doing anything wrong. What is "termination_a_type" ? Upon creating the ports, I chose the 8P8C which is what a CAT6 cable would be using.

I've tried looking at it from another perspective: manually creating a cable by clicking on the green arrow button, I then get a cable, but the resulting output csv I was hoping to use is completely different!

termination_a_type, termination_a_id, termination_b_type, termination_b_id, type, status,     label
jdcim.rearport      74                dcim.rearport       50                CAT6  connected   et000001


Any suggestions?

davide Colombo

unread,
Sep 20, 2019, 7:23:06 AM9/20/19
to NetBox
Hi, I've just tried to insert a cable with csv import in many ways and it won't work, probably it's a bug, but, before opening an issue on github is better to wait someone else opinion justo to be sure.

If you have to create a large amount of cables and you know a little of python you could use the custom script function to create cables from there, and the parameters needed are exactly the ones that the csv export gives.

Xav W

unread,
Sep 20, 2019, 7:30:32 AM9/20/19
to NetBox
Ooh Grazzie Davide!

Maybe the python approach is better: yes, I have a LOT to import so clicking on green buttons isn't the solution!

I've not done any python, but have colleagues who have. If you have a template, please feel free to share it. I'll look into it in parallel.

Thanks again
Xav

davide Colombo

unread,
Sep 20, 2019, 7:35:45 AM9/20/19
to NetBox
At the moment I don't have a specific template for this task, but i can probably extract something useful from my scripts. I'll let you know something more later.

Brian Candler

unread,
Sep 20, 2019, 8:27:04 AM9/20/19
to NetBox
Importing cables in bulk via CSV worked for me when I last used it a couple of months ago.

I don't have the templates to hand, but the following works for me:

side_a_device,side_a_type,side_a_name,side_b_device,side_b_type,side_b_name
pp1,rearport,R7,pp1,rearport,R8

However, if I give the wrong name for one of the rearports, I get exactly the barf you showed.  e.g. if I change "R8" to "X8" above, then I get:

<class 'dcim.models.Cable.termination_b_type.RelatedObjectDoesNotExist'>
Cable has no termination_b_type.

So there is a bug, but only that it is not returning a sensible error message when the selected port does not exist.

In your case, I'd expect that means device pp1-1 does not have a rearport called "1".

I'm not sure how you're doing the CSV export - via an export template? - but yes indeed the fields will be different this way.  That's because on the import you're looking at *form* fields, but on the export you're looking at *model* fields.

Brian Candler

unread,
Sep 20, 2019, 8:29:07 AM9/20/19
to NetBox
P.S. I get the same error if there's already a cable in the selected port.  So it could be that your pp1-1 does have a rearport called "1" but there's already a cable in it.

Xav W

unread,
Sep 20, 2019, 8:30:10 AM9/20/19
to NetBox
Hi Brian,

Thanks for your reply.

Can I ask which version of Netbox you're using?

In my case, I'm using exactly the same text string, which is just a number.

Maybe the fact it's a single digit is a problem. I'll try again adding a R and F prefix for example... At the moment, it's just 1, 2, 3, etc, and the same for the front and the rear, but obviously no clash as they're on different sides of the patch panel, or at least that's what I think.

Brian Candler

unread,
Sep 20, 2019, 8:36:43 AM9/20/19
to NetBox
I am on 2.6.4.

Have a bug report for the exception issue:

If you can prove the issue is with numeric names for ports then that would be a separate bug.  I use "F1" and "R1", but only because I find it less confusing, not because there's a fundamental reason not to do what you're doing.

Xav W

unread,
Sep 20, 2019, 8:54:15 AM9/20/19
to NetBox
Hmm. Strange. I've just created some more patch panels, using the real names, not bogus test ones and tried again and now it works!

side_a_device,side_a_type,side_a_name,side_b_device,side_b_type,side_b_name,label
PP-MBT-01-A,rearport,1,PP-RX-05-MAIN-01,rearport,1,0101ET04001


But I double checked everything before and was sure I had the right syntax so not sure why it's now happy.

I'll see if I can bulk import quite a few lines and see what happens!

davide Colombo

unread,
Sep 20, 2019, 10:10:43 AM9/20/19
to NetBox
Here we are, I've made a simple demo (which does not work as it is, it must obviously be modified by you).

davide Colombo

unread,
Sep 20, 2019, 10:13:26 AM9/20/19
to NetBox
Ah, last thing, it would be better if you or the guy who will work on this know at least a minimum of django queryset and custom netbox scripts
Reply all
Reply to author
Forward
0 new messages