标签:start current spec cat div base vrp ice image
from netmiko import ConnectHandler
import logging
logging.basicConfig(filename="test.log", level=logging.DEBUG)
huawei = {‘device_type‘: ‘huawei‘, ‘ip‘: ‘10.10.30.253‘, ‘username‘: ‘root@default‘, ‘password‘: ‘Admin123_.‘,‘port‘: 22}
#huawei = {‘device_type‘: ‘huawei_vrpv8‘, ‘ip‘: ‘10.10.30.253‘, ‘username‘: ‘root@default‘, ‘password‘: ‘Admin123_.‘,‘port‘: 22}
net_connect = ConnectHandler(**huawei)
sshConfirm = net_connect.find_prompt()
print(‘login ‘ + sshConfirm)
#current_view = net_connect.find_prompt()
#print(current_view)
commands = [‘dis arp‘]
output = net_connect.send_config_set(commands)
## not support commit
#output += net_connect.commit()
print(output)
net_connect.disconnect()
[root@bogon ironic]#
[root@bogon ironic]# cat test.log DEBUG:paramiko.transport:starting thread (client mode): 0x8f9c0290L DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.7.1 DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-- INFO:paramiko.transport:Connected (version 2.0, client -) DEBUG:paramiko.transport:kex algos:[u‘diffie-hellman-group-exchange-sha256‘, u‘ecdh-sha2-nistp521‘, u‘ecdh-sha2-nistp384‘, u‘ecdh-sha2-nistp256‘, u‘diffie-hellman-group-exchange-sha1‘, u‘sm2kep-sha2-nistp256‘] server key:[u‘ssh-dss‘, u‘ssh-rsa‘, u‘ecdsa-sha2-nistp521‘] client encrypt:[u‘aes256-ctr‘, u‘aes128-ctr‘] server encrypt:[u‘aes256-ctr‘, u‘aes128-ctr‘] client mac:[u‘hmac-sha2-256‘, u‘hmac-sha2-256-96‘, u‘hmac-sha1-96‘] server mac:[u‘hmac-sha2-256‘, u‘hmac-sha2-256-96‘, u‘hmac-sha1-96‘] client compress:[u‘none‘, u‘zlib‘] server compress:[u‘none‘, u‘zlib‘] client lang:[u‘‘] server lang:[u‘‘] kex follows?False DEBUG:paramiko.transport:Kex agreed: ecdh-sha2-nistp256 DEBUG:paramiko.transport:HostKey agreed: ecdsa-sha2-nistp521 DEBUG:paramiko.transport:Cipher agreed: aes128-ctr DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256 DEBUG:paramiko.transport:Compression agreed: none DEBUG:paramiko.transport:kex engine KexNistp256 specified hash_algo <built-in function openssl_sha256> DEBUG:paramiko.transport:Switch to new keys ... DEBUG:paramiko.transport:Adding ecdsa-sha2-nistp521 host key for 10.10.30.253: b6d87e3a5fee634c324c9699dcb14012 DEBUG:paramiko.transport:userauth is OK INFO:paramiko.transport:Authentication (password) successful! DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes DEBUG:paramiko.transport:Secsh channel 0 opened. DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok DEBUG:netmiko:read_channel: Warning: The initial password poses security risks. The password needs to be changed. Change now? [Y/N]: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:In set_base_prompt DEBUG:netmiko:read_channel: DEBUG:netmiko:write_channel: DEBUG:netmiko:read_channel: Error: Please choose ‘YES‘ or ‘NO‘ first before pressing ‘Enter‘. [Y/N]: DEBUG:netmiko:write_channel: DEBUG:netmiko:read_channel: Error: Please choose ‘YES‘ or ‘NO‘ first before pressing ‘Enter‘. [Y/N]: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:write_channel: return DEBUG:netmiko:Pattern is: > DEBUG:netmiko:write_channel: exit DEBUG:paramiko.transport:EOF in transport thread [root@bogon ironic]#
67 if "[Y/N]" in prompt: 68 log.debug("First time logging in") 69 self.write_channel("N"+self.RETURN) 70 return self.base_prompt
标签:start current spec cat div base vrp ice image
原文地址:https://www.cnblogs.com/dream397/p/13052506.html