ktbyers/netmiko — pull request #19 by rnilekani (2014-12-18 02:27:41+00:00)
Title: Adding the functionality to issue show commands and run multiple configuration commands

show commands and configuration changes via SSH channel works. Need to work on normalizing the feed and striping the prompt.

>>>
>>>
>>> import netmiko
>>>
>>> SSHClass = netmiko.ssh_dispatcher(device_type='f5_ltm')
>>>
>>>
>>> SSHClass

>>>
>>> net_connect = SSHClass(ip = ‘X.X.X.X', username='root', password =‘XXX', secret = '')
SSH connection established to X.X.X.X:22
Interactive SSH session established
Paging has been disabled

>>>
>>>
>>>
>>> config_commands = ['clock', 'tmsh create ltm node server1 address 10.10.10.10', 'tmsh create ltm pool SERVERS members add { server1:80 }', 'tmsh show ltm pool SERVERS']
>>>
>>>
>>>
>>>
>>> net_connect.send_config_set(config_commands)
"clock\r\nWed 17 Dec 2014 08:12:38 PM CST -0.001293 seconds\r\n[root@f5-inova-1a:Active] config # tmsh create ltm node server1 address 10.10.10 \r.10\r\n[root@f5-inova-1a:Active] config # tmsh create ltm pool SERVERS members add { se \rrver1:80 }\r\n[root@f5-inova-1a:Active] config # tmsh show ltm pool SERVERS\r\n\r\n---------------------------------------------------------------------\r\nLtm::Pool: SERVERS \r\n---------------------------------------------------------------------\r\nStatus \r\n Availability : unknown \r\n State : enabled \r\n Reason : The children pool member(s) either don't have service checking enabled, or service check results are not available yet\r\n Monitor : none \r\n Minimum Active Members : 0 \r\n Current Active Members : 0 \r\n \r\nTraffic ServerSide\r\n Bits In 0\r\n Bits Out 0\r\n Packets In 0\r\n Packets Out 0\r\n Current Connections 0\r\n Maximum Connections 0\r\n Total Connections 0\r\n \r\nConnection Queue Pool Pool and members\r\n Number of connections queued now 0 0\r\n Number of connections serviced 0 0\r\n Queue head entry age (ms) 0 0\r\n Maximum queue entry age ever (ms) 0 0\r\n Maximum queue entry age recently (ms) 0 0\r\n Average queue entry age (ms) 0 0\r\n\r\n[root@f5-inova-1a:Active] config # "
>>>
>>>
>>>
>>>
>>>
>>> net_connect.send_command('tmsh show ltm pool TEST')
'tmsh show ltm pool TEST\r\n\r\n---------------------------------------------------------------------\r\nLtm::Pool: TEST \r\n---------------------------------------------------------------------\r\nStatus \r\n Availability : offline \r\n State : enabled \r\n Reason : \r\n Monitor : none \r\n Minimum Active Members : 0 \r\n Current Active Members : 0 \r\n \r\nTraffic ServerSide\r\n Bits In 0\r\n Bits Out 0\r\n Packets In 0\r\n Packets Out 0\r\n Current Connections 0\r\n Maximum Connections 0\r\n Total Connections 0\r\n \r\nConnection Queue Pool Pool and members\r\n Number of connections queued now 0 0\r\n Number of connections serviced 0 0\r\n Queue head entry age (ms) 0 0\r\n Maximum queue entry age ever (ms) 0 0\r\n Maximum queue entry age recently (ms) 0 0\r\n Average queue entry age (ms) 0 0\r\n\