Creating cable labels using API and pynetbox #11476
nomad-cyanide
started this conversation in
General
Replies: 1 comment 1 reply
-
You need to upgrade pynetbox. I can reproduce your problem here with pynetbox 6.1.2:
But after upgrading to pynetbox 7.0.0:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I am just trying to make a little script, that takes the interfaces of a device that has cables defined and print the termination-points. I need this information to piece together the label, that we are going to print out and put on the cable itself.
I have gotten to point of fetching the cable from Netbox, but I cannot figure out how to print the tuple information about just the a and b termination points.
device_name = TESTSRV
nb_device = nb.dcim.devices.get(name=device_name)
if not nb_device:
print ("Device not found in netbox")
exit()
nb_device_name = str(nb_device.name)
nb_device_interfaces = nb.dcim.interfaces.filter(device=nb_device_name)
for nb_interface in nb_device_interfaces:
nb_interface_cable = nb_interface.cable
if nb_interface_cable == None:
continue
else:
print("interface_cable id",nb_interface_cable.id)
nb_cable = nb.dcim.cables.get(nb_interface_cable.id)
for output in nb_cable:
print (output)
print("interface cable",nb_cable)
Output:
If I try something like printing nb_cable.a_terminations I just get empty output.
I need the a and b terminations a list or dict, so I can pick and choose from the contents. Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions