def _establish_connection(cls, remote_access_data):
"""Establish telnet connection"""
try:
time.sleep(cls.SLEEP_TIME)
tnet = telnetlib.Telnet(remote_access_data.address, timeout=cls.TIMEOUT)
except EnvironmentError:
# print "Telnet: Error connecting to remote device"
return None
if remote_access_data.username != 'None':
tnet.read_until("login:")
tnet.write("\r\n" + remote_access_data.username + "\r\n")
if remote_access_data.identifier != 'None':
tnet.read_until("Password: ")
tnet.write("\r\n" + remote_access_data.identifier + "\r\n")
tnet.read_until(">")
return tnet
评论列表
文章目录