You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have this script to test the creation of a cable using pynetbox (7.4.1) on Netbox 4.2.5:
import paramiko
import pynetbox
NETBOX_URL = "xxxxxxxxxxxxxx"
NETBOX_API_TOKEN = "xxxxxxxxxx"
local_host = "SW1" # Hardcoded local device name
remote_host = "SW2" # Hardcoded remote device name
nb = pynetbox.api(NETBOX_URL, token=NETBOX_API_TOKEN)
# Prepare cable data
cable_data = {
"side_a_device": local_host, # Local device name
"side_a_type": "dcim.interface", # Termination type for side A
"side_a_name": "ethernet1/1/50", # Local termination name (interface name)
"side_b_device": remote_host, # Remote device name
"side_b_type": "dcim.interface", # Termination type for side B
"side_b_name": "ethernet1/1/50", # Remote termination name (interface name)
"type": "mmf-om4", # Cable type (as required)
"color": "00ffff", # Cable color (as required)
"status": "connected", # Cable status
}
# Log the cable data before creation
print(f"Prepared cable data: {cable_data}")
# Attempt to create the cable
try:
nb.dcim.cables.create(cable_data)
print(f"Cable created: {cable_data['side_a_name']} <-> {cable_data['side_b_device']}:{cable_data['side_b_name']}")
except pynetbox.RequestError as e:
print(f"Failed to create cable: {e.error}")
But when I run it, got this error:
Prepared cable data: {'side_a_device': 'SW1', 'side_a_type': 'dcim.interface', 'side_a_name': 'ethernet1/1/50', 'side_b_device': 'SW2', 'side_b_type': 'dcim.interface', 'side_b_name': 'ethernet1/1/50', 'type': 'mmf-om4', 'color': '00ffff', 'status': 'connected'}
Failed to create cable: {"__all__":["Must define A and B terminations when creating a new cable."]}
If I feed the contents of cable_data into Cable Bulk Import --> Direct Import the cable is successfully created.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I have this script to test the creation of a cable using pynetbox (7.4.1) on Netbox 4.2.5:
But when I run it, got this error:
If I feed the contents of cable_data into Cable Bulk Import --> Direct Import the cable is successfully created.
Can anyone point me to what am I doing wrong?
TIA
Beta Was this translation helpful? Give feedback.
All reactions