Repository: ktbyers/netmiko

Issue:
ssh_autodetect.py fails to detect Dell OS9 devices
I found issues with Netmiko ssh_autodetect.py feature with Dell OS9 (or dell_force10) switches but this same issues might appear with other vendor OSs as well. I'm asking for the comments and ideas for the best possible implementation.

The first issue is that the ssh_autodetect.py detects only one Dell hardware type, S4048-ON, instead of detecting the running OS. For example, it is also possible to run Dell OS10 on that specific hardware type. It would be better to match on the line 'Networking OS Version           :  9.14(0.1)' on the output of 'show version' command and it would be simple to fix.

The other, more complex, issue is that there is 'show system' command in 'SSH_MAPPER_BASE' which is valid for Dell OS9 switches but it returns paginated output and therefore breaks the detection.

I tested this with python3.6 in which dictionaries are insertion ordered. The code loops through the items in SSH_MAPPER_BASE and the cmds are checked in order ‘show system’, ‘show version’, ‘show system’, ‘show version’, ‘show version’ etc against the corresponding search patterns. 

Here's the output of the 'show system' command

```
Stack MAC                      : 00:00:00:00:00:00
Reload-Type                    : normal-reload [Next boot : normal-reload]

--  Unit 1 --
Unit Type                      : Management Unit
Status                         : online
Next Boot                      : online
Required Type                  : S3048-ON - 52-port GE/TE (SG-ON)
Current Type                   : S3048-ON - 52-port GE/TE (SG-ON)
Master priority                 : 0
Hardware Rev                   : 0.0
Num Ports                      : 52
Up Time                        : 22 wk, 1 day, 21 hr, 54 min
Networking OS Version           :  9.14(0.1)
Jumbo Capable                  : yes
POE Capable                    : no
FIPS Mode                      : disabled
Burned In MAC                  : 00:00:00:00:00:00
No Of MACs                     : 3

--  Power Supplies  --
--More--
```

and then the next command entered to the cli is ‘how version’ as the first character, ‘s’, just ‘exists’ from the previous output.

```
sw1#how version
   ^
% Error: Invalid input at "^" marker.
sw1#
```

I came up with couple of options how this could be solved;

1. Use OrderedDict for SSH_MAPPER_BASE and change the order of the commands
Currently items in SSH_MAPPER_BASE are in alphabetical order based on vendor name. There would be option to change the order of items in ‘SSH_MAPPER_BASE’ (as an ordered dict) so that the order of commands sent to the devices would be in the order of frequency in ‘SSH_MAPPER_BASE’ i.e.
'show version' -> appeares 11 times
'show system' -> appears 2 times
rest of the commands -> only once
This order would be more optimal as most of the devices can be identified based on output of 'show version'.

1. Change the commands to include only the matched line on the output
This would also solve the issue but there would be more commands to be sent to the devices which is not optimal
'show version | i ASA'
'show version | i Networking OS Version'
etc

1. Add the support for the paginated output
I suppose this would be rather complicated as the OS and the corresponding command is unknown.

Any other ideas, recommendations, comments etc?


Discussion:

Resolving patch:
diff --git a/netmiko/ssh_autodetect.py b/netmiko/ssh_autodetect.py
--- a/netmiko/ssh_autodetect.py
+++ b/netmiko/ssh_autodetect.py
@@ -101,7 +101,7 @@
     },
     "dell_force10": {
         "cmd": "show version",
-        "search_patterns": [r"S4048-ON"],
+        "search_patterns": [r"Real Time Operating System Software"],
         "priority": 99,
         "dispatch": "_autodetect_std",
     },


Test patch: