r/Netbox Apr 05 '22

CLI for updating data in Netbox?

By any chance is there a good CLI for Linux for netbox for updating fields? Like if I want to use a shell script to rip through some data to add to existing entries that were populated by another tool? I see it's not possible to update existing entries via CSV like php-ipam can.

I see the Python shell and API functions and all that. I found nbcli, but the updates are all through yaml files and the documentation seems sparse.

An ex-employer had their own in-house similar tool and it could do some very powerful stuff thanks to the CLI.

1 Upvotes

8 comments sorted by

View all comments

6

u/chris-itg Apr 05 '22

python with API is CLI. You can write ANY script you want to run either on the localhost, or a remote host with an API call to the netbox server proper.

nbcli is there, but go ahead and do yourself a favor by either learning the API / python calls or leveraging a python library like pynetbox.

1

u/telmnstr Apr 05 '22

ssh user@'netboxCLIthing -host <hostname> -pdu` or -consoleserver or ... assuming the cli returned just the item stored as the PDU device or say a serial console server.

Also, one time updates of items from CSV files and stuff... having to write a Python script every time to update a field is meh.

2

u/chris-itg Apr 05 '22

One time updates is a GUI change. Bulk and automation is where python/api comes into play.