Is it possible to pull interfaces from the devices and create them automatically in netbox?

2,311 views
Skip to first unread message

Tony Pearce

unread,
Aug 24, 2019, 5:05:10 AM8/24/19
to NetBox
I have created a couple of devices and using the API I can get the interfaces:

"interface_list": [
            "Ethernet1/1",
            "Ethernet1/2",
            "Ethernet1/3",
            "Ethernet1/4",

Is it possible to have netbox save these interfaces so that I then can go and configure them in netbox? It seems I have to add the interfaces manually or import with a csv. So this would save me having to modify the json output into a csv, then paste in the csv to netbox after tweaking it.

Brian Candler

unread,
Aug 24, 2019, 6:48:57 PM8/24/19
to NetBox
I have no idea what you're trying to say.

If you can query the Netbox API and get a list of interfaces, then it means they must be in the Netbox database.  They will appear in the GUI as well, when you go to the device or VM they are attached to.

Tony Pearce

unread,
Aug 25, 2019, 2:14:44 AM8/25/19
to Brian Candler, NetBox
Any ideas why that wouldnt be happening for me? I have added three
devices now, and manually created the interfaces on two of them. The
third has not populated any interfaces automatically.

Apologies for the confusing OP. I am new to netbox. But seems you
understood me. The interfaces are not appearing in the gui unless I
manually create them using the gui. I can use an expression like
"Gigabit0/[1-48]" but would be much more convenient if it could be
automatically populated based on the discovery.

Are there any other steps to perform other than installing napalm and
specifying the driver to use in the gui for the platform? My devices
are two cisco nexus and one IOS switch. This is happening to both
platforms I have tried with.

Thanks

Tony Pearce


On Sun, 25 Aug 2019 at 06:48, Brian Candler <b.ca...@pobox.com> wrote:
>
> I have no idea what you're trying to say.
>
> If you can query the Netbox API and get a list of interfaces, then it means they must be in the Netbox database. They will appear in the GUI as well, when you go to the device or VM they are attached to.
>
> --
> You received this message because you are subscribed to the Google Groups "NetBox" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/85c165a4-dfb2-44de-abcc-7170bfa0bcf6%40googlegroups.com.

Brian Candler

unread,
Aug 25, 2019, 3:15:38 AM8/25/19
to NetBox
On Sunday, 25 August 2019 07:14:44 UTC+1, Tony Pearce wrote:
The interfaces are not appearing in the gui unless I
manually create them using the gui.

Alternatively:

- you can create interfaces using the API

- you can add template interfaces onto a Device Type.  Then every time you create a new Device of that Device Type, the correct set of interfaces are created from the template.

 
I can use an expression like
"Gigabit0/[1-48]" but would be much more convenient if it could be
automatically populated based on the discovery.


Netbox doesn't do any discovery.

The integration with napalm is minimal: once a device has been recorded in Netbox, you can then use the Netbox API to send Napalm commands to the device.  There is also a small amount of Napalm integration in the GUI for viewing device status, LLDP neighbors, and config.

But Netbox won't query the device to populate the database.  That's against the Netbox philosophy: it's a database that you manually curate with information about how you intend your network to be.

Brian Candler

unread,
Aug 25, 2019, 11:53:09 AM8/25/19
to NetBox
OK I think I finally twigged: I am guessing the list of interfaces you originally quoted must have come from querying the napalm endpoint of the netbox API.

"interface_list": [
            "Ethernet1/1",
            "Ethernet1/2",
            "Ethernet1/3",
            "Ethernet1/4",

That explains my confusion. You can either ask napalm for what interfaces it *sees* on the device (by talking to the device), or you can ask netbox for what interfaces *should be* on the device (by querying the database).

If you want napalm to populate the database, it would be up to you to read and reformat the napalm data and then write it to the netbox API.

Tony Pearce

unread,
Aug 25, 2019, 9:19:36 PM8/25/19
to NetBox
Thanks for the help.

So I think in summary, netbox wont auto populate anything and I need to populate it myself.


Amy Bai

unread,
Jan 10, 2020, 1:49:35 AM1/10/20
to NetBox
you can create a device type, this device type is a template. You can add interface like Ethernet1/[1-48], then you can got like:
            "Ethernet1/1",
            "Ethernet1/2",
            "Ethernet1/3",
            "Ethernet1/4",
             ...
            "Ethernet1/48"

在 2019年8月24日星期六 UTC+8下午5:05:10,Tony Pearce写道:
Reply all
Reply to author
Forward
0 new messages