Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new platform netmiko_auto #44

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion nornir_netmiko/connections/netmiko.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, Dict, Optional

from netmiko import ConnectHandler
from netmiko.ssh_autodetect import SSHDetect

from nornir.core.configuration import Config

Expand All @@ -14,6 +15,7 @@
"eos": "arista_eos",
"junos": "juniper_junos",
"iosxr": "cisco_xr",
"netmiko_auto": "autodetect",
}


Expand Down Expand Up @@ -52,7 +54,16 @@ def open(
if platform is not None:
# Look platform up in corresponding map, if no entry return the host.nos unmodified
platform = napalm_to_netmiko_map.get(platform, platform)
parameters["device_type"] = platform
if platform == "autodetect": # If we are using autodect
parameters["device_type"] = platform
guesser = SSHDetect(**parameters)
best_match = guesser.autodetect()
if best_match: # If we find a device_type
parameters["device_type"] = best_match
else:
raise ValueError("Netmiko cannot detect the device_type")
else:
parameters["device_type"] = platform

extras = extras or {}
parameters.update(extras)
Expand Down