Last active
June 17, 2019 20:06
-
-
Save bDrwx/36a2cd038d135826d5da9b0d71f8a8ec to your computer and use it in GitHub Desktop.
Simple example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import getpass | |
import sys | |
import re | |
from netmiko import ConnectHandler | |
pattern = re.compile(r'Huawei\s\w+\s\w+\suptime') | |
COMMAND = sys.argv[1] | |
USER = input('Username: ') | |
PASSWORD = getpass.getpass() | |
DEVICES_IP = ['192.168.1.2'] | |
for IP in DEVICES_IP: | |
print('Connection to device {}'.format(IP)) | |
DEVICES_PARAMS = {'device_type': 'huawei', | |
'ip': IP, | |
'username': USER, | |
'password': PASSWORD} | |
with ConnectHandler(**DEVICES_PARAMS) as ssh: | |
ssh.enable() | |
result = pattern.findall(ssh.send_command('display version')) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment