question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instantiate driver based on driver string

See original GitHub issue

With a multi-vendor inventory, we would usually have the device type as a string such as ios or eos. In netmiko, this works well because we pass the driver as a string to ConnectHandler but it seems that in scrapli, the only way is to explicitly import all drivers from scrapli.driver.core (without using a workaround like __import__).

With the current code it doesn’t seem straightforward to add a driver key like in netmiko, but is there (or could there be) something like netmiko CLASS_MAPPER (https://github.com/ktbyers/netmiko/blob/develop/netmiko/ssh_dispatcher.py#L98-L197) that associates driver names to their class so that we can instantiate a driver programmatically (with MAPPER[driver_name](**device) as...) ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
afourmycommented, Jul 19, 2020

@carlmontanari I just tested and it works fine. Thanks !

1reaction
afourmycommented, Jul 13, 2020

Hello @carlmontanari

Thanks for the detailed answer ! I’ll create the driver mapping myself for now until this next release. I think the community driver repo is a great idea, it worked well for napalm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is string DRIVER being set? - java - Stack Overflow
The line is useless. In the early days of Java it was necessary to "initialize" the driver by running Class.forName(...) with the driver...
Read more >
Loading JDBC Drivers - Baeldung
A typical driver registration routine will instantiate the driver instance and pass it over to the DriverManager.registerDriver method:
Read more >
Initializing the Driver - PostgreSQL JDBC Driver
This section describes how to load and initialize the JDBC driver in your programs. Importing JDBC. Any source file that uses JDBC needs...
Read more >
Creating a class driver - IBM
With a class driver, you can implement a dynamic class using any type of class, such as implementing all the dynamic classes of...
Read more >
Establishing a Connection (The Java™ Tutorials > JDBC ...
This JDBC Java tutorial describes how to use JDBC API to create, insert into, ... A database connection URL is a string that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found