Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. class Device(object):
  2. """ Connects to a Cisco device through telnet """
  3.  
  4. def __init__(self, host=None, password=None, username=None, enable_password=None):
  5. self.host = host
  6. self.username = username
  7. self.password = password
  8. self.enable_password = enable_password
  9.  
  10. self.connected = False
  11. self._connection = None
  12.  
  13. if self.username == '':
  14. self.username = None
  15.  
  16.  
  17. def connect(self, host=None, port=23, timeout=5):
  18. if host is None:
  19. host = self.host
  20.  
  21. self._connection = telnetlib.Telnet(host, port, timeout)
  22. self._authenticate()
  23. self._get_hostname()
  24.  
  25. self.cmd("term len 0")
  26.  
  27. self.connected = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement