Solvik / netbox-agent

Netbox agent to run on your infrastructure's servers
Apache License 2.0
273 stars 67 forks source link

Guess primary address #23

Open Solvik opened 4 years ago

Solvik commented 4 years ago

Netbox has the ability to flag an IP as Primary address for a Device

Since it's tied to the user workflow, I'd say we could enable this guess with a config argument and use the following workflow

ThomasADavis commented 4 years ago

interface = netifaces.gateways()['default'][netifaces.AF_INET][1]

will tell you which interface has the default route.

Solvik commented 4 years ago

Doesn't seem to handle every case:

>>> import netifaces
>>> netifaces.gateways()
{'default': {}}

In my case IP are announced via exabgp