Closed nexty5870 closed 5 years ago
@nexty5870 You might want to turn on the session_log
and see what is going on. You can add this as an argument to ConnectHandler...so
ConnectHandler = {
# normal args
'session_log': 'output.txt',
}
This will write this output file "output.txt" into your current working directory.
You probably should look at the autodetect code and see if you can add your device types into there (as it looks like you are trying to recreate this).
The error above indicates that show version
was sent and that Netmiko expected SSH@BOH-switch#
to come back (to indicate the command was done) and that response never came back.
@nexty5870 You might want to turn on the
session_log
and see what is going on. You can add this as an argument to ConnectHandler...soConnectHandler = { # normal args 'session_log': 'output.txt', }
This will write this output file "output.txt" into your current working directory.
You probably should look at the autodetect code and see if you can add your device types into there (as it looks like you are trying to recreate this).
The error above indicates that
show version
was sent and that Netmiko expectedSSH@BOH-switch#
to come back (to indicate the command was done) and that response never came back.
Very usefull command, added and it seems that the script do not go to the next page, hence why it got "stuck" ?
SSH@BOH-switch#
SSH@BOH-switch#
SSH@BOH-switch#
SSH@BOH-switch#no page
Invalid input -> page
Type ? for a list
SSH@BOH-switch#terminal width 511
Invalid input -> width 511
Type ? for
SSH@BOH-switch#show version
Copyright (c) 2017 Ruckus Wireless, Inc. All rights reserved.
UNIT 1: compiled on Apr 3 2018 at 15:38:37 labeled as SPR08070b
(29341752 bytes) from Primary SPR08070b.bin
SW: Version 08.0.70bT213
Compressed Boot-Monitor Image size = 786944, Version:10.1.11T225 (mnz10111)
Compiled on Wed Dec 13 13:13:34 2017
HW: Stackable ICX7150-48
==========================================================================
UNIT 1: SL 1: ICX7150-48-4X1G 48-port Management Module
Serial #:FEH3218P03X
Current License: 4X1G
P-ASIC 0: type B160, rev 11 Chip BCM56160_B0
==========================================================================
UNIT 1: SL 2: ICX7150-2X1GC 2-port 2G Module
==========================================================================
UNIT 1: SL 3: ICX7150-4X10GF 4-port 40G Module
==========================================================================
1000 MHz ARM processor ARMv7 88 MHz bus
8192 KB boot flash memory
2048 MB code flash memory
1024 MB DRAM
STACKID 1 system uptime is 3 hour(s) 2 minute(s) 34 second(s)
--More--, next page: Space, next line: Return key, quit: Control-c
any idea if that can be fixed within netmiko?
Which Netmiko device_type
are you using?
I'm not sure if I can have 1 script to handle multiple models, but I've done it this way
for devices in devices_list: print 'Connecting to device...'' ' + devices ip_address_of_device = devices ios_device = { 'device_type': 'cisco_ios', 'ip': ip_address_of_device, 'username': username, 'password': password, 'session_log': 'output.txt' } hp_device = { 'device_type': 'aruba_os', 'ip': ip_address_of_device, 'username': username, 'password': password, 'session_log': 'output.txt' }
try:
net_connect = ConnectHandler(**ios_device)
net_connect_hp = ConnectHandler(**hp_device)
I can see on the output that netmiko load the no paging command
But the above is not an aruba_os
device_type--correct?
It looks it should possibly be using:
https://github.com/ktbyers/netmiko/blob/develop/netmiko/ruckus/ruckus_fastiron.py
Sure Netmiko can handle multiple device_types in the same script, but they need to be the right device_type for the given device.
If you are trying to determine the device_types for given devices, then I would decouple that from other work. In other words, task1-create some script that determines the correct device_type for each device (save that information for later reuse in some way). Task2-use my device inventory including correct device_type to solve some tasks.
Netmiko has two ways to detect device_types which are the SSH autodetect that I linked to earlier and there also is an SNMP way of doing this. There are only support for certain platforms in both of these.
You can modify this pretty easily to expand it, however.
https://github.com/ktbyers/netmiko/blob/develop/netmiko/ssh_autodetect.py#L52
the switch is an ICX (Brocade) but Aruba is the closest CLI I've found, I cannot find any ICX on the ConnectHandler file
"brocade_fastiron": RuckusFastironSSH,
"brocade_netiron": ExtremeNetironSSH,
"brocade_nos": ExtremeNosSSH,
"brocade_vdx": ExtremeNosSSH,
"brocade_vyos": VyOSSSH,
Sorry, I accidentally hit
I think it is that ruckus_fastiron
which should be identical to that brocade_fastiron
...but let me know if that is not right.
Looks like we have a positive result in using ruckus_fastiron I can get the show version display, I need to troubleshoot the code since it return some other error ( I'm sure my way of handeling multiple model is wrong)
Traceback (most recent call last):
File "nettools6.py", line 97, in
for devices in devices_list:
print 'Connecting to device...'' ' + devices
ip_address_of_device = devices
hp_device = {
'device_type': 'ruckus_fastiron',
'ip': ip_address_of_device,
'username': username,
'password': password,
'session_log': 'output.txt'
}
...
try:
net_connect = ConnectHandler(**ios_device)
net_connect_hp = ConnectHandler(**hp_device)
if software_ver == 'ICX7150-48' :
print 'Running ' + software_ver + ' commands'
output = net_connect_hp.send_config_set(commands_list_icx)
print output
Looks like your logic/indentation is probably wrong (i.e. in some context you are trying to print the output
variable when it doesn't exist (i.e. hasn't been defined).
Looks like your logic/indentation is probably wrong (i.e. in some context you are trying to print the
output
variable when it doesn't exist (i.e. hasn't been defined).
indeed I've try with only one device type define and it's now working, would you have any suggestion on how to run 1 script for different models? or if you have an example of different ConnectHandler I'd be happy to get inspried
thanks a lot!
Should be able to just use a for-loop assuming the device_types are all correct:
thanks, I'll try to debug mine as it seems to be stuck somewhere down there, I'm not a python pro but I'll see what I can do, thanks again!
for software_ver in list_versions:
print 'Checking for ' + software_ver
output_version = net_connect.send_command('show version')
int_version = 0 # Reset integer value
int_version = output_version.find(software_ver) # checking software version / models type
if int_version > 0:
print 'Software version found: ' + software_ver
break
else:
print 'Did not find ' + software_ver
if software_ver == 'ICX7150-48' :
print 'Running ' + software_ver + ' commands'
output = net_connect_icx.send_config_set(commands_list_icx)
elif software_ver == 'WS-C3':
print 'Running ' + software_ver + ' commands'
output = net_connect.send_config_set(commands_list_ios)
elif software_ver == 'HP':
print 'Running ' + software_ver + ' commands'
output = net_connect_hp.send_config_set(commands_list_hp)
print output
Hi,
I've discover this weekend Netmiko and started to code some basic script that will run a certain command file based on show version, i.e: either it's a Cisco / HP / or Aruba, I can confirm that the script is successfully working for a IOS, but I was testing the connection with aruba and somwhow the script output the following:
while it seems that the SSH session is connection is established however the script cannot run the show version,
I've try different device_type ( aruba_os / brocade_fastiron ) mainly but no go - models used is an Brocade ICX7150-48
here is the script, at this point it might be an issue on how I handle different model type of switch ( I'm working in a variety of switches from Cisco to HP to ICX
pastebin of the script itself: https://pastebin.com/rWcfKVjk
the code might need a bit of cleanup but it's work in progress, any suggestion would be welcome