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

'StubParser' object has no attribute 'get_interface_mode' #38

Closed mailorderbribes closed 4 years ago

mailorderbribes commented 4 years ago

Hi Scaleway,

When using the napalm community driver Huawei-CE i get this error. 'StubParser' object has no attribute 'get_interface_mode'

Running napalm from commandline with same driver gives me no errors.

Best,

I4Networks

aruhier commented 4 years ago

Hi, Isn't it more an issue with the driver itself? If it is, you should open a bugreport directly on its repository.

mailorderbribes commented 4 years ago

Hi, why is it using the stubparser? i have a driver installed. Do i need to install the driver also under vendors in the importer dir?

The Junos driver also has no attribute get_interface mode

aruhier commented 4 years ago

Can you try the dev branch and tell me if it fixes it?

Edit: I'm sorry I've misread your bug report, I've read that using napalm directly gave you the same error… Indeed it was calling a missing method in the StubParser (which is used because your device is not supported by a more specific parser).

i4networks commented 4 years ago

ERROR: netbox_importer: Error when polling device huaweicloudenginge : 'StubParser' object has no attribute 'get_interface_vlans' 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:19<00:00, 19.66s/it]

getting closer :)

aruhier commented 4 years ago

Hmm, ok, I'm going to see everything missing in the abstract class.

Thanks for testing it!

i4networks commented 4 years ago

Happy to test for you. I am active again with this project.

rvandenbergh commented 4 years ago

Hi,

i4networks asked me to look into this and tested a small fix in a clone of this project. This worked well for i4networks on two different Huawei devices. Maybe others can also benefit from this fix. What is the way to contribute this fix to this project?

With the fix in the dev branch as a guideline I made these changes:

In vendors.base._AbstractVendorParser I've added the method:

    @abstractmethod
    def get_interface_vlans(self, interface):
        pass

In vendors.__init__.StubParser:

    def get_interface_vlans(self, interface):
        raise NotImplementedError

Best, Remco

aruhier commented 4 years ago

@rvandenbergh: Ok, thanks, I will check if no other abstract method is missing. Indeed the fix is pretty trivial, I just didn't take the time to look at it this week.

aruhier commented 4 years ago

Can you test again the dev branch please? I added a few methods in the StubParser to avoid the issue.

rvandenbergh commented 4 years ago

Thanks. I don't have access to the devices so I've asked @i4networks to test your dev branch.

i4networks commented 4 years ago

Works like a charm :) Thnx

aruhier commented 4 years ago

Thanks, I'm doing a new release with that fix.