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
Hey all, just getting started with pynetbox and having some issues creating devices with it. I am trying to create them from a csv file. I have the following as my code, and despite it being about the same as any other example online, it isnt creating anything.
import os
import csv
import pynetbox
from pynetbox import api
nb = pynetbox.api(
url='<ServerURL>',
token='<token>'
)
nb.http_session.verify = False
os.chdir('<directory>')
with open('<path to csv>', 'r') as file:
reader = csv.DictReader(file)
for row in reader:
try:
result = nb.dcim.devices.create(
name=row["name"],
device_type=85,
role=35,
site=36,
#status="active"
)
print(result)
except pynetbox.RequestError as e:
print(e.error)
else:
print(result)
When this is run, it doesn't return a result, nor does it print an error. In testing, I got this to create a device once:
but it hasn't worked since. I cannot remember if I had status enabled or not for it, and also have no idea what is different now, or would have been to make it create an object that one time. I'm sure this is something dumb, but I can't get there. Thanks.
What I have checked:
network connectivity is confirmed
write is enabled on the api token
I can query netbox just fine and return all expected objects
I do notice that when I attempt to create a device, I can go to netbox and see that the api key usage time updates to the time of my attempt, not sure if this would be indicative of anything important.
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
-
Hey all, just getting started with pynetbox and having some issues creating devices with it. I am trying to create them from a csv file. I have the following as my code, and despite it being about the same as any other example online, it isnt creating anything.
When this is run, it doesn't return a result, nor does it print an error. In testing, I got this to create a device once:
but it hasn't worked since. I cannot remember if I had status enabled or not for it, and also have no idea what is different now, or would have been to make it create an object that one time. I'm sure this is something dumb, but I can't get there. Thanks.
What I have checked:
Environment:
Beta Was this translation helpful? Give feedback.
All reactions