scaleway / netbox-netprod-importer

Poll data from network devices in production and import it into netbox
GNU General Public License v3.0
101 stars 31 forks source link

Error trying to set up interfaces on netbox #32

Closed wakarim closed 4 years ago

wakarim commented 4 years ago

Hi, I am trying to test how the software works and all. The readthedocs does not do much by helping to understand how the software itself works.

My yml file looks like this: name: driver: "ios" target: "172.21.6.129"

However when I run the command netbox-netprod-importer import -u admin -p ~/importer/devices.yml

I get the following error: ERROR: netbox_importer: Error when polling device name: Interface FastEthernet0 could not be created: 400 Client Error: Bad Request for url: http://10.61.172.246/api/dcim/interfaces/267/ -- {'type': ['This field may not be null.']}

I have checked the link and the type field in the api is indeed null.

Is there anything I am missing?

Thanks

aruhier commented 4 years ago

Hi, Thanks for the bug report! Indeed, Netbox changed its API, and now form_factor has been renamed to type in their network interfaces API, and is now mandatory. Can you test the nb_2.7.1 branch and tell me if it fixes your issue?

wakarim commented 4 years ago

Hi, Sorry mate, I am extremely new to this. not 100% sure on how to test that specific branch? I installed the package using the README which said to use pip3 install... Please could you let me know how to test that specific branch you mentioned.

Also, just checking but managed to fix that issue. My new issue is that if I set an interface to be of type 'virtual' it gives a rather large error. The error is as per below:

image

Was just wondering if this update will fix that?

Thanks

aruhier commented 4 years ago

Sure, you can clone the repository, go in it, then run

git checkout nb_2.7.1
pip3 install -U .
wakarim commented 4 years ago

Hi,

Just wondering if there's been any progress on the above error with the http error 500?

I am using the nb_2.7.1 branch.

It is creating the Vlan1 that it mentions, but not populating it.

Thanks

aruhier commented 4 years ago

It seems to be an issue in Netbox, as the API shouldn't 500 in case of an input error. Do you get something from your logs?

Also, please know that I cannot test it anymore with some real devices (explained in the readme), so I'll not be able to push the debug really far.

emr-arvig commented 4 years ago

I can help with debugging on this. I have been using the importer tool for thousands of devices and added some things here and there for different devices. (Thank you for the fantastic work you have done on this @aruhier, we have found it invaluable.)

For this particular problem I am working on Cisco ASR 920 devices, which do not have a napalm driver (since they are IOS-XE). They really do not have "tagged" or "access" ports since with IOS-XE and IOS-XR they are using Ethernet Flow Point (EFP).

I am not sure the "right" way to do this but I was able to get past the null mode error by hard-coding it and not popping it.

        # if not self.overwrite and "mode" in if_prop:
        #     if_prop.pop("mode")
        # elif if_prop.get("mode"):
        #     # cannot really guess (yet) the interface mode, so only set it
        #     # if overwrite
        #     self._handle_interface_mode(interface, if_prop["mode"])
        #     if_prop.pop("mode")

        if not if_prop.get("mode"):
            if_prop["mode"] = "access"

Unfortunately now it is complaining that "role" cannot be null either:

null value in column "role" violates not-null constraint DETAIL: Failing row contains (38751, 2020-02-14, 2020-02-14 21:27:16.859945+00, 4, 10.224.0.187/21, , 307028, null, null, null, active, null, ).

This is strange as the api documentation for netbox does not mention "role" being required anywhere for the interface model.

image

We were working fine until we went from 2.6.2 to 2.7.3.

I am not really sure where to go from here - if this is a netbox problem I am happy to open an issue there or continue to do some more debugging to get to the root of the problem.

emr-arvig commented 4 years ago

I will note all of our problems were fixed by upgrading to the newest version of netbox.

aruhier commented 4 years ago

Thanks, this kind of issue already happened to me before, and I fixed it in the Netbox API, that wasn't compliant with their Swagger doc.

Can I close the issue?

brianpr commented 4 years ago

I will note all of our problems were fixed by upgrading to the newest version of netbox.

the same for me

aruhier commented 4 years ago

Thanks for your feedback, I'm closing this issue then.